@productbrain/mcp 0.0.1-beta.3503 → 0.0.1-beta.3516
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/dist/{chunk-W66ODVGP.js → chunk-PEAWB3EE.js} +1286 -1102
- package/dist/chunk-PEAWB3EE.js.map +1 -0
- package/dist/{chunk-U7YKAA66.js → chunk-VCTFH2U7.js} +581 -83
- package/dist/chunk-VCTFH2U7.js.map +1 -0
- package/dist/cli/index.js +1 -1
- package/dist/http.js +2 -2
- package/dist/index.js +2 -2
- package/dist/{setup-X7GCBAFO.js → setup-UB6UNYTS.js} +2 -2
- package/package.json +2 -2
- package/dist/chunk-U7YKAA66.js.map +0 -1
- package/dist/chunk-W66ODVGP.js.map +0 -1
- /package/dist/{setup-X7GCBAFO.js.map → setup-UB6UNYTS.js.map} +0 -0
|
@@ -2,10 +2,12 @@ import {
|
|
|
2
2
|
KernelCallError,
|
|
3
3
|
cacheScope,
|
|
4
4
|
closeAgentSession,
|
|
5
|
+
formatGatewaySeamSummary,
|
|
5
6
|
getAgentSessionId,
|
|
6
7
|
getApiKeyScope,
|
|
7
8
|
getAuditLog,
|
|
8
9
|
getConversationId,
|
|
10
|
+
getMergedGatewaySeamCounters,
|
|
9
11
|
getRequestApiKey,
|
|
10
12
|
getWorkspaceContext,
|
|
11
13
|
getWorkspaceId,
|
|
@@ -40,13 +42,13 @@ import {
|
|
|
40
42
|
trackSessionCaptureRate,
|
|
41
43
|
trackWriteBackHintServed,
|
|
42
44
|
trackZeroCaptureAuditFired
|
|
43
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-VCTFH2U7.js";
|
|
44
46
|
|
|
45
47
|
// src/server.ts
|
|
46
48
|
import { McpServer as McpServer2 } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
47
49
|
|
|
48
50
|
// src/tools/entries.ts
|
|
49
|
-
import { z as
|
|
51
|
+
import { z as z10 } from "zod/v3";
|
|
50
52
|
|
|
51
53
|
// src/envelope.ts
|
|
52
54
|
import { z } from "zod/v3";
|
|
@@ -178,6 +180,14 @@ function classifyError(err) {
|
|
|
178
180
|
return { code, message, recovery, availableActions: [action] };
|
|
179
181
|
}
|
|
180
182
|
}
|
|
183
|
+
if (err?.name === "GatewayTimeoutError") {
|
|
184
|
+
const mayHaveLanded = err.mayHaveLanded === true;
|
|
185
|
+
return {
|
|
186
|
+
code: "GATEWAY_TIMEOUT",
|
|
187
|
+
message,
|
|
188
|
+
recovery: mayHaveLanded ? "The server was reachable and may have completed this write \u2014 verify before retrying, since a blind retry can duplicate it." : "The server was reachable but did not answer in time. Nothing was written \u2014 safe to retry."
|
|
189
|
+
};
|
|
190
|
+
}
|
|
181
191
|
if (/network error|fetch failed|ECONNREFUSED|ETIMEDOUT/i.test(message)) {
|
|
182
192
|
return { code: "BACKEND_UNAVAILABLE", message, recovery: "Retry in a few seconds." };
|
|
183
193
|
}
|
|
@@ -540,10 +550,96 @@ async function dispatchDiscriminated(toolName, union2, flatData, actionSpecs, ha
|
|
|
540
550
|
}
|
|
541
551
|
|
|
542
552
|
// src/tools/knowledge.ts
|
|
543
|
-
import { z as
|
|
553
|
+
import { z as z7 } from "zod/v3";
|
|
544
554
|
|
|
545
555
|
// src/tools/smart-capture.ts
|
|
546
|
-
import { z as
|
|
556
|
+
import { z as z5 } from "zod/v3";
|
|
557
|
+
|
|
558
|
+
// src/lib/captureTimeoutOutcome.ts
|
|
559
|
+
function isGatewayTimeout(error) {
|
|
560
|
+
return error?.name === "GatewayTimeoutError";
|
|
561
|
+
}
|
|
562
|
+
function buildCaptureOutcomeUnknownResult(error, name, msg) {
|
|
563
|
+
if (!error.mayHaveLanded) return buildDryRunTimeoutResult(error, msg);
|
|
564
|
+
const recovery = `Search for "${name}" before retrying \u2014 a retry will duplicate it if the write landed. If found, read back its commit status and coaching output before assuming either is missing.`;
|
|
565
|
+
return {
|
|
566
|
+
content: [{
|
|
567
|
+
type: "text",
|
|
568
|
+
text: `# Capture Outcome Unknown \u2014 Not Failed
|
|
569
|
+
|
|
570
|
+
${msg}
|
|
571
|
+
|
|
572
|
+
**What is known:** the request reached the server and this client gave up waiting after ${error.elapsedMs}ms. The entry **may or may not** have been written.
|
|
573
|
+
|
|
574
|
+
**What definitely did NOT run:** relation linking \u2014 a separate mutation issued after the create returns, so it is never reached when create itself times out.
|
|
575
|
+
|
|
576
|
+
**What may also have run \u2014 outcome unknown, same reason as the entry itself:** auto-commit and quality coaching. Both execute INSIDE the create call, before it returns, so if the server finished after this client stopped waiting, they ran too. Do not assume either is absent \u2014 read the entry back to find out.
|
|
577
|
+
|
|
578
|
+
**Do this next:** ${recovery}`
|
|
579
|
+
}],
|
|
580
|
+
structuredContent: failure(
|
|
581
|
+
"CAPTURE_OUTCOME_UNKNOWN",
|
|
582
|
+
msg,
|
|
583
|
+
recovery,
|
|
584
|
+
[{ tool: "entries", description: "Search for the entry before retrying", parameters: { action: "search", query: name } }],
|
|
585
|
+
{
|
|
586
|
+
// Structured so a caller can branch on this without parsing prose — the
|
|
587
|
+
// reconciliation signal TEN-1126 says the capture path never had.
|
|
588
|
+
partialSuccess: true,
|
|
589
|
+
mayHaveLanded: error.mayHaveLanded,
|
|
590
|
+
budgetMs: error.budgetMs,
|
|
591
|
+
elapsedMs: error.elapsedMs,
|
|
592
|
+
completedBeforeTimeout: [],
|
|
593
|
+
// WP-575 review (P1): genuinely definite — relation linking is a separate mutation
|
|
594
|
+
// never reached when create throws. See the doc comment above for why `commit` and
|
|
595
|
+
// `coaching` were removed from this list.
|
|
596
|
+
didNotRun: ["relations"],
|
|
597
|
+
// WP-575 review (P1): distinct from `didNotRun` on purpose — these ran INSIDE the
|
|
598
|
+
// same server call as the create, so their outcome is exactly as unknown as the
|
|
599
|
+
// entry's. A caller must read the entry back, never assume either ran or didn't.
|
|
600
|
+
mayHaveRun: ["commit", "coaching"]
|
|
601
|
+
}
|
|
602
|
+
)
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
function buildDryRunTimeoutResult(error, msg) {
|
|
606
|
+
const recovery = "Re-run the preview \u2014 nothing was written, so there is nothing to search for and nothing to duplicate.";
|
|
607
|
+
return {
|
|
608
|
+
content: [{
|
|
609
|
+
type: "text",
|
|
610
|
+
text: `# Preview Outcome Unknown \u2014 Nothing Was Written
|
|
611
|
+
|
|
612
|
+
${msg}
|
|
613
|
+
|
|
614
|
+
**What is known:** the request reached the server and this client gave up waiting after ${error.elapsedMs}ms. This was a **preview**, and the server returns its validation result before performing any write \u2014 so no entry, auto-commit, quality coaching, or relation linking happened.
|
|
615
|
+
|
|
616
|
+
**What is unknown:** the validation verdict this preview was asked for.
|
|
617
|
+
|
|
618
|
+
**Do this next:** ${recovery}`
|
|
619
|
+
}],
|
|
620
|
+
structuredContent: failure(
|
|
621
|
+
"CAPTURE_OUTCOME_UNKNOWN",
|
|
622
|
+
msg,
|
|
623
|
+
recovery,
|
|
624
|
+
[],
|
|
625
|
+
{
|
|
626
|
+
// No partial success to reconcile: a dry run has no server-side state to converge on.
|
|
627
|
+
partialSuccess: false,
|
|
628
|
+
mayHaveLanded: false,
|
|
629
|
+
budgetMs: error.budgetMs,
|
|
630
|
+
elapsedMs: error.elapsedMs,
|
|
631
|
+
completedBeforeTimeout: [],
|
|
632
|
+
didNotRun: ["entry", "relations", "commit", "coaching"],
|
|
633
|
+
mayHaveRun: []
|
|
634
|
+
}
|
|
635
|
+
)
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
function describeBatchEntryError(error, entryName) {
|
|
639
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
640
|
+
if (!isGatewayTimeout(error)) return msg;
|
|
641
|
+
return error.mayHaveLanded ? `${msg} Outcome unknown for this entry \u2014 search for "${entryName}" before re-running the batch, or it may be captured twice.` : `${msg} This was a preview, so nothing was written for this entry \u2014 safe to re-run the batch.`;
|
|
642
|
+
}
|
|
547
643
|
|
|
548
644
|
// src/lib/scopedCache.ts
|
|
549
645
|
var ScopedCache = class {
|
|
@@ -837,110 +933,167 @@ function tokenizeText(input) {
|
|
|
837
933
|
}
|
|
838
934
|
|
|
839
935
|
// src/lib/batchCaptureOutput.ts
|
|
936
|
+
import { z as z3 } from "zod/v3";
|
|
937
|
+
|
|
938
|
+
// src/lib/batchTimeoutCohort.ts
|
|
840
939
|
import { z as z2 } from "zod/v3";
|
|
841
|
-
var
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
940
|
+
var unknownOutcomeEntrySchema = z2.object({
|
|
941
|
+
index: z2.number(),
|
|
942
|
+
collection: z2.string(),
|
|
943
|
+
name: z2.string(),
|
|
944
|
+
error: z2.string(),
|
|
945
|
+
mayHaveLanded: z2.boolean(),
|
|
946
|
+
budgetMs: z2.number(),
|
|
947
|
+
elapsedMs: z2.number()
|
|
948
|
+
});
|
|
949
|
+
function deriveTimeoutOutcome(error) {
|
|
950
|
+
return isGatewayTimeout(error) ? { mayHaveLanded: error.mayHaveLanded, budgetMs: error.budgetMs, elapsedMs: error.elapsedMs } : void 0;
|
|
951
|
+
}
|
|
952
|
+
function describeBatchEntryOutcome(error, entryName) {
|
|
953
|
+
return { error: describeBatchEntryError(error, entryName), timeoutOutcome: deriveTimeoutOutcome(error) };
|
|
954
|
+
}
|
|
955
|
+
function splitBatchNotOk(notOk) {
|
|
956
|
+
return {
|
|
957
|
+
failed: notOk.filter((r) => !r.timeoutOutcome),
|
|
958
|
+
unknownOutcome: notOk.filter((r) => r.timeoutOutcome).map((r) => ({
|
|
959
|
+
index: r.entryIdx,
|
|
960
|
+
collection: r.collection,
|
|
961
|
+
name: r.name,
|
|
962
|
+
error: r.error ?? "unknown error",
|
|
963
|
+
mayHaveLanded: r.timeoutOutcome.mayHaveLanded,
|
|
964
|
+
budgetMs: r.timeoutOutcome.budgetMs,
|
|
965
|
+
elapsedMs: r.timeoutOutcome.elapsedMs
|
|
966
|
+
}))
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
function unknownOutcomeSummaryNote(entries) {
|
|
970
|
+
return entries.length > 0 ? `, ${entries.length} outcome unknown` : "";
|
|
971
|
+
}
|
|
972
|
+
function renderOutcomeUnknownSection(entries) {
|
|
973
|
+
if (entries.length === 0) return [];
|
|
974
|
+
const anyMayHaveLanded = entries.some((e) => e.mayHaveLanded);
|
|
975
|
+
return [
|
|
976
|
+
"",
|
|
977
|
+
"## Outcome Unknown \u2014 Not Failed",
|
|
978
|
+
...entries.map((e) => `- ${e.name} [${e.collection}]: _${e.error}_`),
|
|
979
|
+
"",
|
|
980
|
+
anyMayHaveLanded ? "_Do NOT retry these individually \u2014 search for each name first (see `unknownOutcomeEntries` in the structured response); a retry may duplicate an entry that already landed._" : "_Nothing was written for these \u2014 the preview returns before any write, so re-running is safe. Only the validation verdict is missing._"
|
|
981
|
+
];
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// src/lib/batchCaptureOutput.ts
|
|
985
|
+
var batchCaptureRealOutputSchema = z3.object({
|
|
986
|
+
captured: z3.array(z3.object({
|
|
987
|
+
entryId: z3.string(),
|
|
988
|
+
collection: z3.string(),
|
|
989
|
+
name: z3.string(),
|
|
846
990
|
// "draft_on_failure" is the status emitted when an auto-commit is REFUSED/failed (the entry
|
|
847
991
|
// stays a draft) — the same path that now also emits coherencyRefusal. The strict schema must
|
|
848
992
|
// accept it or a refused response fails to validate on `status` (codex review, completing the
|
|
849
993
|
// coherencyRefusal contract fix).
|
|
850
|
-
status:
|
|
851
|
-
classifiedBy:
|
|
852
|
-
confidence:
|
|
853
|
-
confidenceTier:
|
|
854
|
-
warnings:
|
|
855
|
-
normalization:
|
|
856
|
-
remapped:
|
|
857
|
-
rejected:
|
|
994
|
+
status: z3.enum(["draft", "committed", "proposed", "draft_on_failure"]),
|
|
995
|
+
classifiedBy: z3.enum(["llm", "heuristic", "explicit"]).optional(),
|
|
996
|
+
confidence: z3.number().optional(),
|
|
997
|
+
confidenceTier: z3.enum(["high", "medium", "low"]).optional(),
|
|
998
|
+
warnings: z3.array(z3.string()).optional(),
|
|
999
|
+
normalization: z3.object({
|
|
1000
|
+
remapped: z3.record(z3.string()).optional(),
|
|
1001
|
+
rejected: z3.array(z3.string()).optional()
|
|
858
1002
|
}).optional(),
|
|
859
1003
|
// TEN-2365: capture-time authority-domain proposal slug (PENDING ratification), when filed.
|
|
860
|
-
domain:
|
|
1004
|
+
domain: z3.string().optional(),
|
|
861
1005
|
// WP-465 surface parity: structured coherency refusal for a gate-refused auto-commit (batch
|
|
862
1006
|
// shape). Loose record — same single-source rationale as captureSuccessOutputSchema.
|
|
863
|
-
coherencyRefusal:
|
|
1007
|
+
coherencyRefusal: z3.record(z3.unknown()).optional(),
|
|
864
1008
|
// WP-485 Slice 2b round 4 (Codex P2, FEAT-1370): per-entry contradiction advisory, emitted
|
|
865
1009
|
// into structuredContent but previously undeclared here. Not `.strict()` so this one was
|
|
866
1010
|
// silently stripped rather than rejected — declared anyway so batch consumers actually see it.
|
|
867
|
-
contradictionAdvisory:
|
|
1011
|
+
contradictionAdvisory: z3.record(z3.unknown()).optional()
|
|
868
1012
|
})),
|
|
869
|
-
total:
|
|
870
|
-
failed:
|
|
871
|
-
committed:
|
|
872
|
-
proposed:
|
|
873
|
-
drafts:
|
|
874
|
-
classified:
|
|
875
|
-
autoCommitApplied:
|
|
876
|
-
skippedLowConfidence:
|
|
877
|
-
index:
|
|
878
|
-
name:
|
|
879
|
-
suggestedCollection:
|
|
880
|
-
confidence:
|
|
881
|
-
alternatives:
|
|
882
|
-
collection:
|
|
883
|
-
confidence:
|
|
1013
|
+
total: z3.number(),
|
|
1014
|
+
failed: z3.number(),
|
|
1015
|
+
committed: z3.number(),
|
|
1016
|
+
proposed: z3.number(),
|
|
1017
|
+
drafts: z3.number(),
|
|
1018
|
+
classified: z3.number().optional(),
|
|
1019
|
+
autoCommitApplied: z3.boolean(),
|
|
1020
|
+
skippedLowConfidence: z3.array(z3.object({
|
|
1021
|
+
index: z3.number(),
|
|
1022
|
+
name: z3.string(),
|
|
1023
|
+
suggestedCollection: z3.string().optional(),
|
|
1024
|
+
confidence: z3.number().optional(),
|
|
1025
|
+
alternatives: z3.array(z3.object({
|
|
1026
|
+
collection: z3.string(),
|
|
1027
|
+
confidence: z3.number()
|
|
884
1028
|
})).optional()
|
|
885
1029
|
})).optional(),
|
|
886
|
-
failedEntries:
|
|
887
|
-
index:
|
|
888
|
-
collection:
|
|
889
|
-
name:
|
|
890
|
-
error:
|
|
891
|
-
})).optional()
|
|
1030
|
+
failedEntries: z3.array(z3.object({
|
|
1031
|
+
index: z3.number(),
|
|
1032
|
+
collection: z3.string(),
|
|
1033
|
+
name: z3.string(),
|
|
1034
|
+
error: z3.string()
|
|
1035
|
+
})).optional(),
|
|
1036
|
+
// WP-575 review round (P1, TEN-1126): a DISTINCT cohort from `failedEntries` — additive,
|
|
1037
|
+
// never removes or retypes an existing field (repo's schema rule). See
|
|
1038
|
+
// lib/batchTimeoutCohort.ts's doc comment for why this must stay separate.
|
|
1039
|
+
unknownOutcomeEntries: z3.array(unknownOutcomeEntrySchema).optional()
|
|
892
1040
|
});
|
|
893
|
-
var batchCapturePreviewOutputSchema =
|
|
894
|
-
outcome:
|
|
895
|
-
wouldCapture:
|
|
1041
|
+
var batchCapturePreviewOutputSchema = z3.object({
|
|
1042
|
+
outcome: z3.literal("preview"),
|
|
1043
|
+
wouldCapture: z3.array(z3.object({
|
|
896
1044
|
// Fix 1 (WP-577 review re-review, TEN-2918 follow-up): optional, not required — see
|
|
897
1045
|
// WouldCaptureEntry's doc comment. Absent exactly when `entryIdAssignedAtCapture` is true.
|
|
898
|
-
entryId:
|
|
899
|
-
entryIdAssignedAtCapture:
|
|
900
|
-
collection:
|
|
901
|
-
name:
|
|
902
|
-
classifiedBy:
|
|
903
|
-
confidence:
|
|
904
|
-
warnings:
|
|
1046
|
+
entryId: z3.string().optional(),
|
|
1047
|
+
entryIdAssignedAtCapture: z3.literal(true).optional(),
|
|
1048
|
+
collection: z3.string(),
|
|
1049
|
+
name: z3.string(),
|
|
1050
|
+
classifiedBy: z3.string().optional(),
|
|
1051
|
+
confidence: z3.number().optional(),
|
|
1052
|
+
warnings: z3.array(z3.string()).optional()
|
|
905
1053
|
})),
|
|
906
1054
|
// WP-577 review follow-up (P2, TEN-2918): entries the server's WHY/glossary gate says would
|
|
907
1055
|
// be BLOCKED on a real (non-preview) create — a distinct cohort from `wouldCapture` so the
|
|
908
1056
|
// structured response never claims a governance-refused capture would succeed. Optional/
|
|
909
1057
|
// additive: absent (or empty) on every response this route produced before this fix.
|
|
910
|
-
wouldBlock:
|
|
911
|
-
entryId:
|
|
912
|
-
entryIdAssignedAtCapture:
|
|
913
|
-
collection:
|
|
914
|
-
name:
|
|
915
|
-
blockingReason:
|
|
916
|
-
warnings:
|
|
1058
|
+
wouldBlock: z3.array(z3.object({
|
|
1059
|
+
entryId: z3.string().optional(),
|
|
1060
|
+
entryIdAssignedAtCapture: z3.literal(true).optional(),
|
|
1061
|
+
collection: z3.string(),
|
|
1062
|
+
name: z3.string(),
|
|
1063
|
+
blockingReason: z3.string().optional(),
|
|
1064
|
+
warnings: z3.array(z3.string()).optional()
|
|
1065
|
+
})).optional(),
|
|
1066
|
+
requested: z3.number(),
|
|
1067
|
+
total: z3.number(),
|
|
1068
|
+
failed: z3.number(),
|
|
1069
|
+
skippedLowConfidence: z3.array(z3.object({
|
|
1070
|
+
index: z3.number(),
|
|
1071
|
+
name: z3.string(),
|
|
1072
|
+
suggestedCollection: z3.string().optional(),
|
|
1073
|
+
confidence: z3.number().optional()
|
|
917
1074
|
})).optional(),
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
name: z2.string(),
|
|
924
|
-
suggestedCollection: z2.string().optional(),
|
|
925
|
-
confidence: z2.number().optional()
|
|
1075
|
+
failedEntries: z3.array(z3.object({
|
|
1076
|
+
index: z3.number(),
|
|
1077
|
+
collection: z3.string(),
|
|
1078
|
+
name: z3.string(),
|
|
1079
|
+
error: z3.string()
|
|
926
1080
|
})).optional(),
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
error: z2.string()
|
|
932
|
-
})).optional()
|
|
1081
|
+
// WP-575 review round (P1, TEN-1126): sibling of the same field on
|
|
1082
|
+
// batchCaptureRealOutputSchema — preview batches reach the SAME unconditional
|
|
1083
|
+
// `chain.createEntry` catch a real batch does, so the discriminator exists here too.
|
|
1084
|
+
unknownOutcomeEntries: z3.array(unknownOutcomeEntrySchema).optional()
|
|
933
1085
|
});
|
|
934
|
-
var batchCaptureOutputSchema =
|
|
1086
|
+
var batchCaptureOutputSchema = z3.union([
|
|
935
1087
|
batchCaptureRealOutputSchema,
|
|
936
1088
|
batchCapturePreviewOutputSchema
|
|
937
1089
|
]);
|
|
938
|
-
function buildBatchPreviewSummary({ wouldCapture, wouldBlock = [], failed, skipped, requested }) {
|
|
1090
|
+
function buildBatchPreviewSummary({ wouldCapture, wouldBlock = [], failed, unknownOutcome = [], skipped, requested }) {
|
|
939
1091
|
const noun = requested === 1 ? "entry" : "entries";
|
|
940
1092
|
const blockedNote = wouldBlock.length > 0 ? `, ${wouldBlock.length} would be BLOCKED` : "";
|
|
941
1093
|
const failedNote = failed.length > 0 ? `, ${failed.length} would fail` : "";
|
|
1094
|
+
const unknownNote = unknownOutcomeSummaryNote(unknownOutcome);
|
|
942
1095
|
const skippedNote = skipped.length > 0 ? `, ${skipped.length} skipped (low confidence)` : "";
|
|
943
|
-
return `Preview: would capture ${wouldCapture.length} of ${requested} ${noun}${blockedNote}${failedNote}${skippedNote} \u2014 no DB writes.`;
|
|
1096
|
+
return `Preview: would capture ${wouldCapture.length} of ${requested} ${noun}${blockedNote}${failedNote}${unknownNote}${skippedNote} \u2014 no DB writes.`;
|
|
944
1097
|
}
|
|
945
1098
|
function buildBatchEntryFailure(args) {
|
|
946
1099
|
return {
|
|
@@ -955,12 +1108,14 @@ function buildBatchEntryFailure(args) {
|
|
|
955
1108
|
classifiedBy: args.classifiedBy,
|
|
956
1109
|
confidence: args.confidence,
|
|
957
1110
|
confidenceTier: args.confidenceTier,
|
|
958
|
-
error: args.error
|
|
1111
|
+
error: args.error,
|
|
1112
|
+
...args.timeoutOutcome ? { timeoutOutcome: args.timeoutOutcome } : {}
|
|
959
1113
|
};
|
|
960
1114
|
}
|
|
961
1115
|
function buildBatchPreviewFromResults(created, failed, skipped, requested, originalItems, originalAutoCommit) {
|
|
962
1116
|
const wouldCaptureEntries = created.filter((r) => !r.wouldBlock);
|
|
963
1117
|
const wouldBlockEntries = created.filter((r) => r.wouldBlock);
|
|
1118
|
+
const { failed: genuinelyFailed, unknownOutcome: timedOut } = splitBatchNotOk(failed);
|
|
964
1119
|
return buildBatchPreviewResult({
|
|
965
1120
|
// Fix 1 (TEN-2918 follow-up): report the concrete `entryId` only when it was NOT
|
|
966
1121
|
// auto-allocated (i.e. the caller supplied it for this item) — see WouldCaptureEntry's
|
|
@@ -980,7 +1135,9 @@ function buildBatchPreviewFromResults(created, failed, skipped, requested, origi
|
|
|
980
1135
|
...r.blockingReason ? { blockingReason: r.blockingReason } : {},
|
|
981
1136
|
...r.warnings?.length ? { warnings: r.warnings } : {}
|
|
982
1137
|
})),
|
|
983
|
-
failed:
|
|
1138
|
+
failed: genuinelyFailed.map((r) => ({ index: r.entryIdx, collection: r.collection, name: r.name, error: r.error ?? "unknown error" })),
|
|
1139
|
+
unknownOutcome: timedOut,
|
|
1140
|
+
// WP-575 review (P1, TEN-1126) — see lib/batchTimeoutCohort.ts.
|
|
984
1141
|
skipped: skipped.map((s) => ({ index: s.index, name: s.name, ...s.suggestedCollection ? { suggestedCollection: s.suggestedCollection } : {}, ...s.confidence != null ? { confidence: s.confidence } : {} })),
|
|
985
1142
|
requested,
|
|
986
1143
|
// WP-577 review follow-up (P2, TEN-2918): thread the caller's original batch payload
|
|
@@ -993,7 +1150,7 @@ function buildBatchPreviewFromResults(created, failed, skipped, requested, origi
|
|
|
993
1150
|
});
|
|
994
1151
|
}
|
|
995
1152
|
function buildBatchPreviewResult(input) {
|
|
996
|
-
const { wouldCapture, wouldBlock = [], failed, skipped, requested, originalItems, originalAutoCommit } = input;
|
|
1153
|
+
const { wouldCapture, wouldBlock = [], failed, unknownOutcome = [], skipped, requested, originalItems, originalAutoCommit } = input;
|
|
997
1154
|
const summary = buildBatchPreviewSummary(input);
|
|
998
1155
|
const lines = [`# Batch Preview \u2014 No Entries Created`, summary, ""];
|
|
999
1156
|
if (wouldCapture.length > 0) {
|
|
@@ -1032,6 +1189,7 @@ function buildBatchPreviewResult(input) {
|
|
|
1032
1189
|
}
|
|
1033
1190
|
lines.push("");
|
|
1034
1191
|
}
|
|
1192
|
+
lines.push(...renderOutcomeUnknownSection(unknownOutcome));
|
|
1035
1193
|
lines.push("_No DB writes \u2014 call `capture action=batch` without `preview:true` to capture for real._");
|
|
1036
1194
|
const next = originalItems && originalItems.length > 0 ? [{
|
|
1037
1195
|
tool: "capture",
|
|
@@ -1058,7 +1216,10 @@ function buildBatchPreviewResult(input) {
|
|
|
1058
1216
|
total: wouldCapture.length,
|
|
1059
1217
|
failed: failed.length,
|
|
1060
1218
|
...skipped.length > 0 ? { skippedLowConfidence: skipped } : {},
|
|
1061
|
-
...failed.length > 0 ? { failedEntries: failed } : {}
|
|
1219
|
+
...failed.length > 0 ? { failedEntries: failed } : {},
|
|
1220
|
+
// WP-575 review round (P1, TEN-1126): structured sibling of `failedEntries` — see
|
|
1221
|
+
// `UnknownOutcomeEntry`'s doc comment for why these are never merged into it.
|
|
1222
|
+
...unknownOutcome.length > 0 ? { unknownOutcomeEntries: unknownOutcome } : {}
|
|
1062
1223
|
},
|
|
1063
1224
|
next
|
|
1064
1225
|
)
|
|
@@ -1295,42 +1456,42 @@ function formatRubricVerdictSection(verdict) {
|
|
|
1295
1456
|
}
|
|
1296
1457
|
|
|
1297
1458
|
// src/lib/captureSinglePreviewOutput.ts
|
|
1298
|
-
import { z as
|
|
1299
|
-
var groundingRelatedEntrySchema =
|
|
1300
|
-
entryId:
|
|
1301
|
-
name:
|
|
1302
|
-
collectionSlug:
|
|
1303
|
-
overlapRatio:
|
|
1304
|
-
recommendedRelationType:
|
|
1305
|
-
reasoning:
|
|
1459
|
+
import { z as z4 } from "zod/v3";
|
|
1460
|
+
var groundingRelatedEntrySchema = z4.object({
|
|
1461
|
+
entryId: z4.string(),
|
|
1462
|
+
name: z4.string(),
|
|
1463
|
+
collectionSlug: z4.string(),
|
|
1464
|
+
overlapRatio: z4.number(),
|
|
1465
|
+
recommendedRelationType: z4.string(),
|
|
1466
|
+
reasoning: z4.string()
|
|
1306
1467
|
});
|
|
1307
|
-
var groundingDuplicateEntrySchema =
|
|
1308
|
-
entryId:
|
|
1309
|
-
name:
|
|
1310
|
-
collectionSlug:
|
|
1311
|
-
matchType:
|
|
1312
|
-
overlapRatio:
|
|
1468
|
+
var groundingDuplicateEntrySchema = z4.object({
|
|
1469
|
+
entryId: z4.string(),
|
|
1470
|
+
name: z4.string(),
|
|
1471
|
+
collectionSlug: z4.string(),
|
|
1472
|
+
matchType: z4.enum(["related", "possible_duplicate"]),
|
|
1473
|
+
overlapRatio: z4.number()
|
|
1313
1474
|
});
|
|
1314
|
-
var groundingGovernanceEntrySchema =
|
|
1315
|
-
entryId:
|
|
1316
|
-
name:
|
|
1317
|
-
collectionSlug:
|
|
1475
|
+
var groundingGovernanceEntrySchema = z4.object({
|
|
1476
|
+
entryId: z4.string(),
|
|
1477
|
+
name: z4.string(),
|
|
1478
|
+
collectionSlug: z4.string()
|
|
1318
1479
|
});
|
|
1319
|
-
var groundingReportSchema =
|
|
1320
|
-
related:
|
|
1321
|
-
duplicates:
|
|
1322
|
-
governance:
|
|
1480
|
+
var groundingReportSchema = z4.object({
|
|
1481
|
+
related: z4.array(groundingRelatedEntrySchema),
|
|
1482
|
+
duplicates: z4.array(groundingDuplicateEntrySchema),
|
|
1483
|
+
governance: z4.array(groundingGovernanceEntrySchema)
|
|
1323
1484
|
});
|
|
1324
|
-
var taskAlignmentSchema =
|
|
1325
|
-
var captureSinglePreviewOutputSchema =
|
|
1326
|
-
entryId:
|
|
1327
|
-
name:
|
|
1328
|
-
collection:
|
|
1329
|
-
outcome:
|
|
1485
|
+
var taskAlignmentSchema = z4.record(z4.unknown());
|
|
1486
|
+
var captureSinglePreviewOutputSchema = z4.object({
|
|
1487
|
+
entryId: z4.string(),
|
|
1488
|
+
name: z4.string(),
|
|
1489
|
+
collection: z4.string(),
|
|
1490
|
+
outcome: z4.enum(["preview", "blocked"]),
|
|
1330
1491
|
// Present only when `outcome: "blocked"` AND the server supplied a reason.
|
|
1331
|
-
blockingReason:
|
|
1492
|
+
blockingReason: z4.string().optional(),
|
|
1332
1493
|
// Always present — `result.warnings ?? []`, never omitted.
|
|
1333
|
-
warnings:
|
|
1494
|
+
warnings: z4.array(z4.string()),
|
|
1334
1495
|
groundingReport: groundingReportSchema,
|
|
1335
1496
|
// TEN-2458: only present when the kernel computed a librarian verdict for this preview.
|
|
1336
1497
|
taskAlignment: taskAlignmentSchema.optional()
|
|
@@ -1522,81 +1683,81 @@ var AUTO_LINK_CONFIDENCE_THRESHOLD = 35;
|
|
|
1522
1683
|
var MAX_AUTO_LINKS = 5;
|
|
1523
1684
|
var MAX_SUGGESTIONS = 5;
|
|
1524
1685
|
var BR_STD_ENTRY_ID_REGEX = /^(BR|STD)-\d+$/;
|
|
1525
|
-
var entryIdSchema =
|
|
1526
|
-
var captureSchema =
|
|
1527
|
-
collection:
|
|
1528
|
-
name:
|
|
1529
|
-
description:
|
|
1530
|
-
context:
|
|
1686
|
+
var entryIdSchema = z5.string().regex(BR_STD_ENTRY_ID_REGEX).optional().describe("Only for business-rules and standards. Must match BR-NNN or STD-NNN. Omit for all other collections \u2014 IDs are auto-generated.");
|
|
1687
|
+
var captureSchema = z5.object({
|
|
1688
|
+
collection: z5.string().optional().describe("Collection slug, e.g. 'tensions', 'business-rules', 'glossary', 'decisions'. Optional \u2014 classifier auto-routes when omitted."),
|
|
1689
|
+
name: z5.string().describe("Display name \u2014 be specific (e.g. 'Convex adjacency list won't scale for graph traversal')"),
|
|
1690
|
+
description: z5.string().describe("Full context \u2014 what's happening, why it matters, what you observed"),
|
|
1691
|
+
context: z5.string().optional().describe("Optional additional context (e.g. 'Observed during context gather calls taking 700ms+')"),
|
|
1531
1692
|
entryId: entryIdSchema,
|
|
1532
|
-
canonicalKey:
|
|
1533
|
-
data:
|
|
1534
|
-
links:
|
|
1535
|
-
to:
|
|
1536
|
-
type:
|
|
1693
|
+
canonicalKey: z5.string().optional().describe("Semantic type (e.g. 'decision', 'tension', 'vision'). Auto-assigned from collection if omitted."),
|
|
1694
|
+
data: z5.record(z5.unknown()).optional().describe("Explicit field values when you know the schema (e.g. canonical_key, cardinality_rule, required_fields). Merged with inferred values; user-provided wins."),
|
|
1695
|
+
links: z5.array(z5.object({
|
|
1696
|
+
to: z5.string().describe("Target entry ID (e.g. '<PREFIX>-<n>')"),
|
|
1697
|
+
type: z5.string().describe("Relation type (e.g. 'governs', 'related_to', 'informs')")
|
|
1537
1698
|
})).optional().describe("Relations to create after capture. Skips auto-link discovery when provided."),
|
|
1538
|
-
autoCommit:
|
|
1539
|
-
sourceRef:
|
|
1540
|
-
sourceExcerpt:
|
|
1699
|
+
autoCommit: z5.boolean().optional().describe("If true, commits the entry immediately after capture + linking. If omitted, Open mode workspaces auto-commit by default and consensus/role modes stay draft-first."),
|
|
1700
|
+
sourceRef: z5.string().optional().describe("URI or path of the source document backing this entry (e.g. 'meeting-2026-03-28.md', 'import://batch-5'). Stored as top-level entry field, not in data."),
|
|
1701
|
+
sourceExcerpt: z5.string().optional().describe("Verbatim excerpt from the source that backs this entry's claims. Stored as top-level entry field, not in data."),
|
|
1541
1702
|
// WP-316 S3: Preview gate — dry-run mode. Returns what would happen, no DB writes.
|
|
1542
|
-
preview:
|
|
1703
|
+
preview: z5.boolean().optional().describe("If true, validates the capture without writing. Returns what would happen. Default false."),
|
|
1543
1704
|
// WP-318 S2: Pre-write grounding — run link suggestion before creating entry.
|
|
1544
|
-
suggestOnly:
|
|
1705
|
+
suggestOnly: z5.boolean().optional().describe("If true, runs pre-write grounding (suggestLinksForCapture) and returns a groundingReport WITHOUT creating any entry. Use to preview graph participation before accepting. Default false."),
|
|
1545
1706
|
// WP-318 S2: Format for groundingReport in response.
|
|
1546
|
-
format:
|
|
1707
|
+
format: z5.enum(["agent", "human"]).optional().describe("Response format for grounding data. 'agent' (default): full JSON groundingReport. 'human': compressed summary string appended to the capture summary."),
|
|
1547
1708
|
// WP-513: team+role to create AS OWNER of (rung 2 only); no-op pre-rung-2.
|
|
1548
|
-
ownerTeamEntryId:
|
|
1549
|
-
ownerRoleEntryId:
|
|
1709
|
+
ownerTeamEntryId: z5.string().max(200).optional().describe("Owning team entry ID/ref (rung 2)."),
|
|
1710
|
+
ownerRoleEntryId: z5.string().max(200).optional().describe("Owning role entry ID/ref (rung 2).")
|
|
1550
1711
|
});
|
|
1551
|
-
var batchCaptureRelationSchema =
|
|
1552
|
-
to:
|
|
1553
|
-
type:
|
|
1712
|
+
var batchCaptureRelationSchema = z5.object({
|
|
1713
|
+
to: z5.string().max(200).describe("Target entry ID already on the Chain, e.g. '<PREFIX>-<n>'."),
|
|
1714
|
+
type: z5.string().max(200).describe("Relation type, e.g. 'related_to', 'informed_by', 'governs'.")
|
|
1554
1715
|
});
|
|
1555
|
-
var batchCaptureSchema =
|
|
1556
|
-
entries:
|
|
1716
|
+
var batchCaptureSchema = z5.object({
|
|
1717
|
+
entries: z5.array(z5.object({
|
|
1557
1718
|
// FEAT-160
|
|
1558
|
-
collection:
|
|
1559
|
-
name:
|
|
1560
|
-
description:
|
|
1719
|
+
collection: z5.string().max(200).optional().describe("Collection slug. Optional \u2014 auto-classified via LLM when omitted."),
|
|
1720
|
+
name: z5.string().max(500).describe("Display name"),
|
|
1721
|
+
description: z5.string().max(2e4).describe("Full context / definition"),
|
|
1561
1722
|
entryId: entryIdSchema,
|
|
1562
|
-
data:
|
|
1563
|
-
canonicalKey:
|
|
1564
|
-
sourceRef:
|
|
1565
|
-
sourceExcerpt:
|
|
1723
|
+
data: z5.record(z5.unknown()).optional().describe("Explicit field values (e.g. urgency, status, assignee). Merged with inferred values; user-provided wins."),
|
|
1724
|
+
canonicalKey: z5.string().max(200).optional().describe("Semantic type (e.g. 'decision', 'tension', 'work_package'). Enables work-package redirect in createEntry when collection is 'chains'."),
|
|
1725
|
+
sourceRef: z5.string().max(2e3).optional().describe("URI or path of the source document backing this entry (e.g. 'meeting-2026-03-28.md', 'import://batch-5'). Stored as top-level entry field, not in data."),
|
|
1726
|
+
sourceExcerpt: z5.string().max(5e3).optional().describe("Verbatim excerpt from the source that backs this entry's claims. Stored as top-level entry field, not in data."),
|
|
1566
1727
|
// TEN-957 (WP-484 S2): relations to create right after this entry is captured.
|
|
1567
|
-
relations:
|
|
1728
|
+
relations: z5.array(batchCaptureRelationSchema).max(10).optional().describe("Relations to create right after this entry is captured \u2014 each {to, type} links the NEW entry to an existing Chain entry."),
|
|
1568
1729
|
// WP-513: team+role to create THIS entry AS OWNER of (rung 2 only).
|
|
1569
|
-
ownerTeamEntryId:
|
|
1570
|
-
ownerRoleEntryId:
|
|
1730
|
+
ownerTeamEntryId: z5.string().max(200).optional().describe("Owning team entry ID/ref (rung 2)."),
|
|
1731
|
+
ownerRoleEntryId: z5.string().max(200).optional().describe("Owning role entry ID/ref (rung 2).")
|
|
1571
1732
|
})).min(1).max(50).describe("Array of entries to capture"),
|
|
1572
|
-
autoCommit:
|
|
1733
|
+
autoCommit: z5.boolean().optional().describe(
|
|
1573
1734
|
"If true, commits created entries immediately after linking. If omitted, Open mode workspaces commit by default and consensus/role modes stay draft-first."
|
|
1574
1735
|
),
|
|
1575
1736
|
// WP-316 S3: Preview gate — dry-run mode. Returns what would happen, no DB writes.
|
|
1576
|
-
preview:
|
|
1737
|
+
preview: z5.boolean().optional().describe("If true, validates all captures without writing. Returns what would happen. Default false.")
|
|
1577
1738
|
});
|
|
1578
|
-
var captureClassifierSchema =
|
|
1579
|
-
enabled:
|
|
1580
|
-
autoRouted:
|
|
1581
|
-
agrees:
|
|
1582
|
-
abstained:
|
|
1583
|
-
topConfidence:
|
|
1584
|
-
confidence:
|
|
1585
|
-
reasons:
|
|
1586
|
-
candidates:
|
|
1587
|
-
|
|
1588
|
-
collection:
|
|
1589
|
-
signalScore:
|
|
1590
|
-
confidence:
|
|
1739
|
+
var captureClassifierSchema = z5.object({
|
|
1740
|
+
enabled: z5.boolean(),
|
|
1741
|
+
autoRouted: z5.boolean(),
|
|
1742
|
+
agrees: z5.boolean(),
|
|
1743
|
+
abstained: z5.boolean(),
|
|
1744
|
+
topConfidence: z5.number(),
|
|
1745
|
+
confidence: z5.number(),
|
|
1746
|
+
reasons: z5.array(z5.string()),
|
|
1747
|
+
candidates: z5.array(
|
|
1748
|
+
z5.object({
|
|
1749
|
+
collection: z5.string(),
|
|
1750
|
+
signalScore: z5.number().optional(),
|
|
1751
|
+
confidence: z5.number(),
|
|
1591
1752
|
/** WP-316 S2: required-field cost — how many fields the agent must supply for this collection. */
|
|
1592
|
-
requiredFieldCount:
|
|
1753
|
+
requiredFieldCount: z5.number().optional()
|
|
1593
1754
|
})
|
|
1594
1755
|
),
|
|
1595
|
-
agentProvidedCollection:
|
|
1596
|
-
overrideCommand:
|
|
1597
|
-
classifiedBy:
|
|
1598
|
-
confidenceTier:
|
|
1599
|
-
reasoning:
|
|
1756
|
+
agentProvidedCollection: z5.string().optional(),
|
|
1757
|
+
overrideCommand: z5.string().optional(),
|
|
1758
|
+
classifiedBy: z5.enum(["llm", "heuristic", "explicit"]).optional(),
|
|
1759
|
+
confidenceTier: z5.enum(["high", "medium", "low"]).optional(),
|
|
1760
|
+
reasoning: z5.string().optional()
|
|
1600
1761
|
});
|
|
1601
1762
|
function trackClassifierTelemetry(params) {
|
|
1602
1763
|
const telemetry = {
|
|
@@ -1824,51 +1985,51 @@ async function resolveCaptureCollection(params) {
|
|
|
1824
1985
|
classifierMeta
|
|
1825
1986
|
};
|
|
1826
1987
|
}
|
|
1827
|
-
var captureSuccessOutputSchema =
|
|
1828
|
-
entryId:
|
|
1829
|
-
collection:
|
|
1830
|
-
name:
|
|
1988
|
+
var captureSuccessOutputSchema = z5.object({
|
|
1989
|
+
entryId: z5.string(),
|
|
1990
|
+
collection: z5.string(),
|
|
1991
|
+
name: z5.string(),
|
|
1831
1992
|
// "draft_on_failure" is the status emitted when an auto-commit is REFUSED/failed (the entry
|
|
1832
1993
|
// stays a draft) — the same path that now also emits coherencyRefusal. The strict schema must
|
|
1833
1994
|
// accept it or a refused response fails to validate on `status` (codex review, completing the
|
|
1834
1995
|
// coherencyRefusal contract fix).
|
|
1835
|
-
status:
|
|
1996
|
+
status: z5.enum(["draft", "committed", "proposed", "draft_on_failure"]),
|
|
1836
1997
|
// WP-480 S1: `qualityScore` (required, client N/10) deleted — a named, accepted
|
|
1837
1998
|
// breaking output-contract change. The server verdict stays as `qualityVerdict`.
|
|
1838
|
-
qualityVerdict:
|
|
1999
|
+
qualityVerdict: z5.record(z5.unknown()).optional(),
|
|
1839
2000
|
classifier: captureClassifierSchema.optional(),
|
|
1840
|
-
studioUrl:
|
|
1841
|
-
warnings:
|
|
1842
|
-
normalization:
|
|
1843
|
-
remapped:
|
|
1844
|
-
rejected:
|
|
2001
|
+
studioUrl: z5.string().optional(),
|
|
2002
|
+
warnings: z5.array(z5.string()).optional(),
|
|
2003
|
+
normalization: z5.object({
|
|
2004
|
+
remapped: z5.record(z5.string()).optional(),
|
|
2005
|
+
rejected: z5.array(z5.string()).optional()
|
|
1845
2006
|
}).optional(),
|
|
1846
|
-
expectedFields:
|
|
1847
|
-
key:
|
|
1848
|
-
type:
|
|
1849
|
-
required:
|
|
2007
|
+
expectedFields: z5.array(z5.object({
|
|
2008
|
+
key: z5.string(),
|
|
2009
|
+
type: z5.string(),
|
|
2010
|
+
required: z5.boolean().optional()
|
|
1850
2011
|
})).optional(),
|
|
1851
2012
|
// TEN-2365: capture-time authority-domain proposal (PENDING ratification), when one was filed.
|
|
1852
|
-
authorityDomain:
|
|
1853
|
-
slug:
|
|
1854
|
-
status:
|
|
2013
|
+
authorityDomain: z5.object({
|
|
2014
|
+
slug: z5.string(),
|
|
2015
|
+
status: z5.literal("proposal-pending")
|
|
1855
2016
|
}).optional(),
|
|
1856
2017
|
// WP-465 surface parity: structured coherency refusal when an auto-commit is gate-refused.
|
|
1857
2018
|
// Loose record (matching the qualityVerdict convention above) — the CoherencyRefusal contract
|
|
1858
2019
|
// is authored in convex/lib/gates/coherencyControls.ts; re-declaring its shape here would create
|
|
1859
2020
|
// a second source of truth. Required because the schema is `.strict()` (an undeclared key throws).
|
|
1860
|
-
coherencyRefusal:
|
|
2021
|
+
coherencyRefusal: z5.record(z5.unknown()).optional(),
|
|
1861
2022
|
// WP-485 Slice 2b round 4 (Codex P2, FEAT-1370): the server's contradiction advisory
|
|
1862
2023
|
// (ContradictionAdvisory, declared below) is emitted into structuredContent at line ~2203
|
|
1863
2024
|
// but was missing here — since this schema is `.strict()`, any real capture response
|
|
1864
2025
|
// carrying the advisory failed validation outright with `unrecognized_keys`. Loose record,
|
|
1865
2026
|
// same single-source-of-truth rationale as coherencyRefusal above.
|
|
1866
|
-
contradictionAdvisory:
|
|
2027
|
+
contradictionAdvisory: z5.record(z5.unknown()).optional()
|
|
1867
2028
|
}).strict();
|
|
1868
|
-
var captureClassifierOnlyOutputSchema =
|
|
2029
|
+
var captureClassifierOnlyOutputSchema = z5.object({
|
|
1869
2030
|
classifier: captureClassifierSchema
|
|
1870
2031
|
}).strict();
|
|
1871
|
-
var captureOutputSchema =
|
|
2032
|
+
var captureOutputSchema = z5.union([
|
|
1872
2033
|
captureSuccessOutputSchema,
|
|
1873
2034
|
captureSinglePreviewOutputSchema,
|
|
1874
2035
|
captureClassifierOnlyOutputSchema
|
|
@@ -1890,40 +2051,40 @@ function buildDataFromFields(fields, descriptionField, descriptionValue) {
|
|
|
1890
2051
|
}
|
|
1891
2052
|
var CAPTURE_ACTIONS = ["capture", "batch"];
|
|
1892
2053
|
var captureItemSchema = batchCaptureSchema.shape.entries.element;
|
|
1893
|
-
var captureCompoundSchema =
|
|
1894
|
-
action:
|
|
2054
|
+
var captureCompoundSchema = z5.object({
|
|
2055
|
+
action: z5.enum(CAPTURE_ACTIONS).optional().default("capture").describe("'capture': create a single knowledge entry (the original capture behavior). 'batch': create multiple entries in one call via `items[]` (absorbs batch-capture; each item may carry inline `relations`)."),
|
|
1895
2056
|
// For 'capture' — mirrors captureSchema, relaxed to optional (batch omits these).
|
|
1896
|
-
collection:
|
|
1897
|
-
name:
|
|
1898
|
-
description:
|
|
1899
|
-
context:
|
|
2057
|
+
collection: z5.string().max(200).optional().describe("For 'capture': collection slug, e.g. 'tensions', 'business-rules', 'glossary', 'decisions'. Optional \u2014 classifier auto-routes when omitted."),
|
|
2058
|
+
name: z5.string().max(500).optional().describe("For 'capture': display name \u2014 required for this action."),
|
|
2059
|
+
description: z5.string().max(2e4).optional().describe("For 'capture': full context \u2014 required for this action."),
|
|
2060
|
+
context: z5.string().max(5e3).optional().describe("For 'capture': optional additional context."),
|
|
1900
2061
|
entryId: entryIdSchema,
|
|
1901
|
-
canonicalKey:
|
|
1902
|
-
data:
|
|
1903
|
-
links:
|
|
1904
|
-
to:
|
|
1905
|
-
type:
|
|
2062
|
+
canonicalKey: z5.string().max(200).optional().describe("For 'capture': semantic type (e.g. 'decision', 'tension', 'vision'). Auto-assigned from collection if omitted."),
|
|
2063
|
+
data: z5.record(z5.unknown()).optional().describe("For 'capture': explicit field values. Merged with inferred values; user-provided wins."),
|
|
2064
|
+
links: z5.array(z5.object({
|
|
2065
|
+
to: z5.string().max(200).describe("Target entry ID (e.g. '<PREFIX>-<n>')"),
|
|
2066
|
+
type: z5.string().max(200).describe("Relation type (e.g. 'governs', 'related_to', 'informs')")
|
|
1906
2067
|
})).max(20).optional().describe("For 'capture': relations to create after capture. Skips auto-link discovery when provided."),
|
|
1907
|
-
autoCommit:
|
|
1908
|
-
sourceRef:
|
|
1909
|
-
sourceExcerpt:
|
|
1910
|
-
preview:
|
|
1911
|
-
suggestOnly:
|
|
1912
|
-
format:
|
|
2068
|
+
autoCommit: z5.boolean().optional().describe("For 'capture'/'batch': if true, commits immediately after capture + linking."),
|
|
2069
|
+
sourceRef: z5.string().max(2e3).optional().describe("For 'capture': URI or path of the source document backing this entry."),
|
|
2070
|
+
sourceExcerpt: z5.string().max(5e3).optional().describe("For 'capture': verbatim excerpt from the source backing this entry's claims."),
|
|
2071
|
+
preview: z5.boolean().optional().describe("For 'capture'/'batch': if true, validates without writing."),
|
|
2072
|
+
suggestOnly: z5.boolean().optional().describe("For 'capture': if true, runs pre-write grounding and returns a groundingReport WITHOUT creating any entry."),
|
|
2073
|
+
format: z5.enum(["agent", "human"]).optional().describe("For 'capture': response format for grounding data."),
|
|
1913
2074
|
// For 'batch' — mirrors batchCaptureSchema's `entries`, renamed `items` per §3.
|
|
1914
|
-
items:
|
|
2075
|
+
items: z5.array(captureItemSchema).min(1).max(50).optional().describe("For 'batch': array of entries to capture, each may carry inline `relations`."),
|
|
1915
2076
|
// WP-513: team+role to create AS OWNER of (rung 2 only).
|
|
1916
|
-
ownerTeamEntryId:
|
|
1917
|
-
ownerRoleEntryId:
|
|
2077
|
+
ownerTeamEntryId: z5.string().max(200).optional().describe("For 'capture': owning team (rung-2)."),
|
|
2078
|
+
ownerRoleEntryId: z5.string().max(200).optional().describe("For 'capture': owning role (rung-2).")
|
|
1918
2079
|
});
|
|
1919
|
-
var captureSingleVariant = captureSchema.extend({ action:
|
|
1920
|
-
var captureBatchVariant =
|
|
1921
|
-
action:
|
|
1922
|
-
items:
|
|
1923
|
-
autoCommit:
|
|
1924
|
-
preview:
|
|
2080
|
+
var captureSingleVariant = captureSchema.extend({ action: z5.literal("capture") });
|
|
2081
|
+
var captureBatchVariant = z5.object({
|
|
2082
|
+
action: z5.literal("batch"),
|
|
2083
|
+
items: z5.array(captureItemSchema).min(1).max(50),
|
|
2084
|
+
autoCommit: z5.boolean().optional(),
|
|
2085
|
+
preview: z5.boolean().optional()
|
|
1925
2086
|
});
|
|
1926
|
-
var captureActionUnion =
|
|
2087
|
+
var captureActionUnion = z5.discriminatedUnion("action", [
|
|
1927
2088
|
captureSingleVariant,
|
|
1928
2089
|
captureBatchVariant
|
|
1929
2090
|
]);
|
|
@@ -2288,6 +2449,7 @@ No DB writes \u2014 call without \`preview:true\` to capture for real.${result2.
|
|
|
2288
2449
|
}
|
|
2289
2450
|
} catch (error) {
|
|
2290
2451
|
const msg = error instanceof Error ? error.message : String(error);
|
|
2452
|
+
if (isGatewayTimeout(error)) return buildCaptureOutcomeUnknownResult(error, name, msg);
|
|
2291
2453
|
if (msg.includes("Duplicate") || msg.includes("already exists")) {
|
|
2292
2454
|
return {
|
|
2293
2455
|
content: [{
|
|
@@ -3328,7 +3490,6 @@ async function handleBatchCapture(server, { entries, autoCommit, preview }) {
|
|
|
3328
3490
|
});
|
|
3329
3491
|
if (job) chunkBytes += prospectiveJobBytes;
|
|
3330
3492
|
} catch (error) {
|
|
3331
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
3332
3493
|
results.push(buildBatchEntryFailure({
|
|
3333
3494
|
entryIdx,
|
|
3334
3495
|
name: entry.name,
|
|
@@ -3336,13 +3497,14 @@ async function handleBatchCapture(server, { entries, autoCommit, preview }) {
|
|
|
3336
3497
|
classifiedBy,
|
|
3337
3498
|
confidence,
|
|
3338
3499
|
confidenceTier,
|
|
3339
|
-
error
|
|
3500
|
+
...describeBatchEntryOutcome(error, entry.name)
|
|
3501
|
+
// WP-575 review (P1, TEN-1126) — see lib/batchTimeoutCohort.ts.
|
|
3340
3502
|
}));
|
|
3341
3503
|
}
|
|
3342
3504
|
}
|
|
3343
3505
|
await flushPendingChunk(pendingFinish);
|
|
3344
3506
|
const created = results.filter((r) => r.ok);
|
|
3345
|
-
const failed = results.filter((r) => !r.ok);
|
|
3507
|
+
const { failed, unknownOutcome: unknownOutcomeEntries } = splitBatchNotOk(results.filter((r) => !r.ok));
|
|
3346
3508
|
const committed = created.filter((r) => r.status === "committed");
|
|
3347
3509
|
const proposed = created.filter((r) => r.status === "proposed");
|
|
3348
3510
|
const drafts = created.filter((r) => r.status === "draft");
|
|
@@ -3471,6 +3633,7 @@ _Use \`entries action=move\` to correct any misclassified entries._`);
|
|
|
3471
3633
|
lines.push("");
|
|
3472
3634
|
lines.push(`_If failed > 0, inspect \`failedEntries\` in the structured response and retry individually._`);
|
|
3473
3635
|
}
|
|
3636
|
+
lines.push(...renderOutcomeUnknownSection(unknownOutcomeEntries));
|
|
3474
3637
|
const entryIds = created.map((r) => r.entryId);
|
|
3475
3638
|
if (entryIds.length > 0 || skippedLowConfidence.length > 0) {
|
|
3476
3639
|
lines.push("");
|
|
@@ -3491,7 +3654,7 @@ _Use \`entries action=move\` to correct any misclassified entries._`);
|
|
|
3491
3654
|
const skippedNote = skippedLowConfidence.length > 0 ? `, ${skippedLowConfidence.length} skipped (low confidence)` : "";
|
|
3492
3655
|
const classifiedNote = classifiedCount > 0 ? `, ${classifiedCount} auto-classified` : "";
|
|
3493
3656
|
const commitFailedNote = commitFailed.length > 0 ? `, ${commitFailed.length} commit-failed` : "";
|
|
3494
|
-
const summary = failed.length > 0 || skippedLowConfidence.length > 0 || commitFailed.length > 0 ? `Batch captured ${created.length}/${entries.length} entries (${failed.length} failed${skippedNote}, ${committed.length} committed, ${proposed.length} proposed, ${drafts.length} draft${commitFailedNote}${classifiedNote}).` : `Batch captured ${created.length} entries successfully (${committed.length} committed, ${proposed.length} proposed, ${drafts.length} draft${classifiedNote}).`;
|
|
3657
|
+
const summary = failed.length > 0 || unknownOutcomeEntries.length > 0 || skippedLowConfidence.length > 0 || commitFailed.length > 0 ? `Batch captured ${created.length}/${entries.length} entries (${failed.length} failed${unknownOutcomeSummaryNote(unknownOutcomeEntries)}${skippedNote}, ${committed.length} committed, ${proposed.length} proposed, ${drafts.length} draft${commitFailedNote}${classifiedNote}).` : `Batch captured ${created.length} entries successfully (${committed.length} committed, ${proposed.length} proposed, ${drafts.length} draft${classifiedNote}).`;
|
|
3495
3658
|
const firstDraft = drafts[0];
|
|
3496
3659
|
const next = [];
|
|
3497
3660
|
if (created.length > 0) {
|
|
@@ -3566,7 +3729,9 @@ _Use \`entries action=move\` to correct any misclassified entries._`);
|
|
|
3566
3729
|
name: r.name,
|
|
3567
3730
|
error: r.error ?? "unknown error"
|
|
3568
3731
|
}))
|
|
3569
|
-
}
|
|
3732
|
+
},
|
|
3733
|
+
...unknownOutcomeEntries.length > 0 && { unknownOutcomeEntries }
|
|
3734
|
+
// WP-575 review (P1, TEN-1126) — kept OUT of failedEntries.
|
|
3570
3735
|
},
|
|
3571
3736
|
next
|
|
3572
3737
|
),
|
|
@@ -3693,9 +3858,9 @@ async function runConflictPreflight(name, description, collectionHint) {
|
|
|
3693
3858
|
}
|
|
3694
3859
|
|
|
3695
3860
|
// src/tools/knowledge/getHistory.ts
|
|
3696
|
-
import { z as
|
|
3697
|
-
var getHistorySchema =
|
|
3698
|
-
entryId:
|
|
3861
|
+
import { z as z6 } from "zod/v3";
|
|
3862
|
+
var getHistorySchema = z6.object({
|
|
3863
|
+
entryId: z6.string().describe("Entry ID, e.g. 'T-SUPPLIER', '<PREFIX>-<n>'")
|
|
3699
3864
|
});
|
|
3700
3865
|
async function handleGetHistory({ entryId }) {
|
|
3701
3866
|
const history = await kernelQuery("chain.listEntryHistory", { entryId });
|
|
@@ -3754,41 +3919,41 @@ var WORKFLOW_STATUS_VALUES = [
|
|
|
3754
3919
|
"evidenced"
|
|
3755
3920
|
];
|
|
3756
3921
|
var LEGACY_WORKFLOW_STATUSES = new Set(WORKFLOW_STATUS_VALUES);
|
|
3757
|
-
var updateEntrySchema =
|
|
3758
|
-
entryId:
|
|
3759
|
-
name:
|
|
3760
|
-
status:
|
|
3761
|
-
|
|
3922
|
+
var updateEntrySchema = z7.object({
|
|
3923
|
+
entryId: z7.string().describe("Entry ID to update, e.g. 'T-SUPPLIER', '<PREFIX>-<n>'"),
|
|
3924
|
+
name: z7.string().optional().describe("New display name"),
|
|
3925
|
+
status: z7.union([
|
|
3926
|
+
z7.enum(["draft", "active", "deprecated", "archived"]),
|
|
3762
3927
|
// BET-68 legacy shim: frozen historical workflow values still pass through
|
|
3763
3928
|
// `status` (auto-routed with a warning) until the ~2026-09-03 sunset.
|
|
3764
|
-
|
|
3929
|
+
z7.enum(WORKFLOW_STATUS_VALUES)
|
|
3765
3930
|
]).optional().describe("Lifecycle status: draft | active | deprecated | archived. **Workflow values are deprecated here \u2014 use `workflowStatus` instead. Passing a workflow value as `status` will be auto-routed with a warning until 2026-09-03, then hard-errored.**"),
|
|
3766
|
-
workflowStatus:
|
|
3767
|
-
data:
|
|
3768
|
-
order:
|
|
3769
|
-
canonicalKey:
|
|
3770
|
-
autoPublish:
|
|
3771
|
-
changeNote:
|
|
3772
|
-
sourceRef:
|
|
3773
|
-
sourceExcerpt:
|
|
3931
|
+
workflowStatus: z7.string().optional().describe("Collection workflow state. Valid values are collection-specific and server-owned \u2014 discover them via `collections action=describe` for the target collection. The server rejects invalid values and returns the valid set in the error."),
|
|
3932
|
+
data: z7.record(z7.unknown()).optional().describe("Fields to update (merged with existing data)"),
|
|
3933
|
+
order: z7.number().optional().describe("New sort order"),
|
|
3934
|
+
canonicalKey: z7.string().optional().describe("Semantic type (e.g. 'decision', 'tension'). Only changeable on draft/uncommitted entries."),
|
|
3935
|
+
autoPublish: z7.boolean().optional().default(false).describe("Only true when user explicitly asks to publish. Default false = draft. Never auto-publish without user confirmation."),
|
|
3936
|
+
changeNote: z7.string().optional().describe("Strongly recommended: short human-readable rationale for WHY this change was made (e.g. 'Aligned description with F1-themed copy'). Surfaces in activity feed and pb get. If omitted, falls back to session purpose or auto-generated field summary."),
|
|
3937
|
+
sourceRef: z7.string().optional().describe("URI or path of the source document backing this entry. Write-once: can only be set if currently empty."),
|
|
3938
|
+
sourceExcerpt: z7.string().optional().describe("Verbatim excerpt from the source that backs this entry's claims. Write-once: can only be set if currently empty."),
|
|
3774
3939
|
// WP-465 slice ⑤ — relay-only (TEN-2233): validation/min-length/recording live in Convex.
|
|
3775
|
-
steeringOverrideReason:
|
|
3776
|
-
coherencyAcknowledgement:
|
|
3777
|
-
response:
|
|
3778
|
-
entryId:
|
|
3779
|
-
reason:
|
|
3940
|
+
steeringOverrideReason: z7.string().optional().describe("Typed override (\u226512 chars) that clears a steering coherency block on a misaligned governance write \u2014 always recorded with author attribution."),
|
|
3941
|
+
coherencyAcknowledgement: z7.object({
|
|
3942
|
+
response: z7.enum(["linked", "accepted-fix", "diverged"]).describe("Explicit response to an acknowledge-required coherency challenge."),
|
|
3943
|
+
entryId: z7.string().optional().describe("Authorizing entry being linked/accepted (required for 'linked' and 'accepted-fix')."),
|
|
3944
|
+
reason: z7.string().optional().describe("Divergence rationale (required for 'diverged', \u226512 chars).")
|
|
3780
3945
|
}).optional().describe("Explicit response to a coherency challenge (standard/strict workspace modes). One acknowledgement per challenge per entry per session.")
|
|
3781
3946
|
});
|
|
3782
|
-
var commitEntrySchema =
|
|
3783
|
-
entryId:
|
|
3947
|
+
var commitEntrySchema = z7.object({
|
|
3948
|
+
entryId: z7.string().describe("Entry ID to accept, e.g. 'TEN-abc123', '<PREFIX>-<n>'"),
|
|
3784
3949
|
// WP-316 S3: Preview gate — dry-run mode. Returns would-succeed result, no DB writes.
|
|
3785
|
-
preview:
|
|
3950
|
+
preview: z7.boolean().optional().describe("If true, validates the accept without writing. Returns what would happen. Default false."),
|
|
3786
3951
|
// WP-465 slice ⑤ — relay-only (TEN-2233): validation/recording live in Convex.
|
|
3787
|
-
steeringOverrideReason:
|
|
3788
|
-
coherencyAcknowledgement:
|
|
3789
|
-
response:
|
|
3790
|
-
entryId:
|
|
3791
|
-
reason:
|
|
3952
|
+
steeringOverrideReason: z7.string().optional().describe("Typed override (\u226512 chars) that clears a steering coherency block at the publish chokepoint \u2014 always recorded with author attribution."),
|
|
3953
|
+
coherencyAcknowledgement: z7.object({
|
|
3954
|
+
response: z7.enum(["linked", "accepted-fix", "diverged"]).describe("Explicit response to an acknowledge-required coherency challenge."),
|
|
3955
|
+
entryId: z7.string().optional().describe("Authorizing entry being linked/accepted (required for 'linked' and 'accepted-fix')."),
|
|
3956
|
+
reason: z7.string().optional().describe("Divergence rationale (required for 'diverged', \u226512 chars).")
|
|
3792
3957
|
}).optional().describe("Explicit response to a coherency challenge (standard/strict workspace modes).")
|
|
3793
3958
|
});
|
|
3794
3959
|
async function handleUpdateEntry({ entryId, name, status: rawStatus, workflowStatus: rawWorkflowStatus, data, order, canonicalKey, autoPublish, changeNote, sourceRef, sourceExcerpt, steeringOverrideReason, coherencyAcknowledgement }, toolName = "entries") {
|
|
@@ -4177,7 +4342,7 @@ No DB writes \u2014 call without \`preview:true\` to accept for real.` }],
|
|
|
4177
4342
|
// src/tools/verify.ts
|
|
4178
4343
|
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
4179
4344
|
import { resolve as resolve2 } from "path";
|
|
4180
|
-
import { z as
|
|
4345
|
+
import { z as z8 } from "zod/v3";
|
|
4181
4346
|
|
|
4182
4347
|
// src/lib/resolve-project-root.ts
|
|
4183
4348
|
import { existsSync } from "fs";
|
|
@@ -4329,12 +4494,12 @@ function formatTrustReport(collection, entryCount, mappings, refs, fixes, mode,
|
|
|
4329
4494
|
lines.push("", "---", `_Schema: ${schemaTableCount} tables parsed from convex/schema.ts. Project root: ${projectRoot}_`);
|
|
4330
4495
|
return lines.join("\n");
|
|
4331
4496
|
}
|
|
4332
|
-
var verifySchema =
|
|
4333
|
-
collection:
|
|
4334
|
-
mode:
|
|
4497
|
+
var verifySchema = z8.object({
|
|
4498
|
+
collection: z8.string().max(200).default("glossary").describe("Collection slug to verify (default: glossary)"),
|
|
4499
|
+
mode: z8.enum(["report", "fix"]).default("report").describe("'report' = read-only trust report. 'fix' = also update drifted codeMapping statuses.")
|
|
4335
4500
|
});
|
|
4336
|
-
var verifyEntrySchema =
|
|
4337
|
-
entryId:
|
|
4501
|
+
var verifyEntrySchema = z8.object({
|
|
4502
|
+
entryId: z8.string().max(200).describe("Human entry ID (e.g. '<PREFIX>-<n>') to mark as verified")
|
|
4338
4503
|
});
|
|
4339
4504
|
async function handleVerifyChain(server, { collection, mode }) {
|
|
4340
4505
|
const projectRoot = resolveProjectRoot();
|
|
@@ -4551,10 +4716,10 @@ async function handleVerifyEntry({ entryId }) {
|
|
|
4551
4716
|
}
|
|
4552
4717
|
|
|
4553
4718
|
// src/tools/entry-move.ts
|
|
4554
|
-
import { z as
|
|
4555
|
-
var moveEntrySchema =
|
|
4556
|
-
entryId:
|
|
4557
|
-
toCollection:
|
|
4719
|
+
import { z as z9 } from "zod/v3";
|
|
4720
|
+
var moveEntrySchema = z9.object({
|
|
4721
|
+
entryId: z9.string().describe("Entry ID to move, e.g. '<PREFIX>-<n>'"),
|
|
4722
|
+
toCollection: z9.string().describe("Target collection slug, e.g. 'decisions', 'architecture'")
|
|
4558
4723
|
});
|
|
4559
4724
|
async function handleMoveEntry(entryId, toCollection) {
|
|
4560
4725
|
try {
|
|
@@ -4665,89 +4830,89 @@ var ENTRIES_ACTIONS = [
|
|
|
4665
4830
|
"move",
|
|
4666
4831
|
"verify"
|
|
4667
4832
|
];
|
|
4668
|
-
var coherencyAcknowledgementFlatSchema =
|
|
4669
|
-
response:
|
|
4670
|
-
entryId:
|
|
4671
|
-
reason:
|
|
4833
|
+
var coherencyAcknowledgementFlatSchema = z10.object({
|
|
4834
|
+
response: z10.enum(["linked", "accepted-fix", "diverged"]).describe("Explicit response to an acknowledge-required coherency challenge."),
|
|
4835
|
+
entryId: z10.string().max(200).optional().describe("Authorizing entry being linked/accepted (required for 'linked' and 'accepted-fix')."),
|
|
4836
|
+
reason: z10.string().max(2e3).optional().describe("Divergence rationale (required for 'diverged', \u226512 chars).")
|
|
4672
4837
|
});
|
|
4673
|
-
var entriesSchema =
|
|
4674
|
-
action:
|
|
4838
|
+
var entriesSchema = z10.object({
|
|
4839
|
+
action: z10.enum(ENTRIES_ACTIONS).describe(
|
|
4675
4840
|
"'list': browse entries with filters. 'get': fetch one entry by ID. 'batch': fetch multiple entries. 'search': full-text search. 'update': change fields on an existing entry (draft by default). 'commit': accept a draft entry onto the Chain. 'history': audit trail for an entry. 'move': reclassify an entry to a different collection. 'verify': mark an entry as verified (lightweight \u2014 no codebase scan; see `quality action=verify-chain` for the codebase-scanning check)."
|
|
4676
4841
|
),
|
|
4677
|
-
entryId:
|
|
4842
|
+
entryId: z10.string().max(200).optional().describe(
|
|
4678
4843
|
"Entry ID, e.g. '<PREFIX>-<n>'. Required for: get, update, commit, history, move, verify."
|
|
4679
4844
|
),
|
|
4680
|
-
entryIds:
|
|
4681
|
-
collection:
|
|
4682
|
-
status:
|
|
4845
|
+
entryIds: z10.array(z10.string().max(200)).min(1).max(20).optional().describe("Entry IDs for 'batch', e.g. ['TYPE-strategy', 'STR-jljeg7']"),
|
|
4846
|
+
collection: z10.string().max(200).optional().describe("Collection slug \u2014 for 'list'/'search': scope filter, e.g. 'glossary', 'tracking-events'."),
|
|
4847
|
+
status: z10.string().max(200).optional().describe(
|
|
4683
4848
|
"For 'list'/'search': filter string (draft | active | deprecated | archived). For 'update': lifecycle value to set (draft | active | deprecated | archived \u2014 legacy workflow values still route through here with a deprecation warning until 2026-09-03; use `workflowStatus` instead)."
|
|
4684
4849
|
),
|
|
4685
|
-
tag:
|
|
4686
|
-
label:
|
|
4687
|
-
query:
|
|
4688
|
-
name:
|
|
4689
|
-
workflowStatus:
|
|
4850
|
+
tag: z10.string().max(200).optional().describe("For 'list': filter by internal tag."),
|
|
4851
|
+
label: z10.string().max(200).optional().describe("For 'list': filter by label slug \u2014 matches entries across all collections."),
|
|
4852
|
+
query: z10.string().min(2).max(500).optional().describe("For 'search': search text (min 2 characters)."),
|
|
4853
|
+
name: z10.string().max(500).optional().describe("For 'update': new display name."),
|
|
4854
|
+
workflowStatus: z10.string().max(200).optional().describe(
|
|
4690
4855
|
"For 'update': collection workflow state. Valid values are collection-specific and server-owned \u2014 discover via `collections action=describe`. Invalid values are rejected with the valid set."
|
|
4691
4856
|
),
|
|
4692
|
-
data:
|
|
4693
|
-
order:
|
|
4694
|
-
canonicalKey:
|
|
4857
|
+
data: z10.record(z10.unknown()).optional().describe("For 'update': fields to update (merged with existing data)."),
|
|
4858
|
+
order: z10.number().optional().describe("For 'update': new sort order."),
|
|
4859
|
+
canonicalKey: z10.string().max(200).optional().describe(
|
|
4695
4860
|
"For 'update': semantic type (e.g. 'decision', 'tension'). Only changeable on draft/uncommitted entries."
|
|
4696
4861
|
),
|
|
4697
|
-
autoPublish:
|
|
4862
|
+
autoPublish: z10.boolean().optional().default(false).describe(
|
|
4698
4863
|
"For 'update': only true when the user explicitly asks to publish. Default false = draft."
|
|
4699
4864
|
),
|
|
4700
|
-
changeNote:
|
|
4865
|
+
changeNote: z10.string().max(2e3).optional().describe(
|
|
4701
4866
|
"For 'update': short human-readable rationale for WHY this change was made. Surfaces in activity feed."
|
|
4702
4867
|
),
|
|
4703
|
-
sourceRef:
|
|
4868
|
+
sourceRef: z10.string().max(2e3).optional().describe(
|
|
4704
4869
|
"For 'update': URI or path of the source document backing this entry. Write-once."
|
|
4705
4870
|
),
|
|
4706
|
-
sourceExcerpt:
|
|
4871
|
+
sourceExcerpt: z10.string().max(5e3).optional().describe(
|
|
4707
4872
|
"For 'update': verbatim excerpt from the source backing this entry's claims. Write-once."
|
|
4708
4873
|
),
|
|
4709
|
-
steeringOverrideReason:
|
|
4874
|
+
steeringOverrideReason: z10.string().max(2e3).optional().describe(
|
|
4710
4875
|
"For 'update'/'commit': typed override (\u226512 chars) that clears a steering coherency block."
|
|
4711
4876
|
),
|
|
4712
4877
|
coherencyAcknowledgement: coherencyAcknowledgementFlatSchema.optional().describe(
|
|
4713
4878
|
"For 'update'/'commit': explicit response to a coherency challenge (standard/strict workspace modes)."
|
|
4714
4879
|
),
|
|
4715
|
-
preview:
|
|
4880
|
+
preview: z10.boolean().optional().describe(
|
|
4716
4881
|
"For 'commit': if true, validates the accept without writing \u2014 returns what would happen."
|
|
4717
4882
|
),
|
|
4718
|
-
toCollection:
|
|
4883
|
+
toCollection: z10.string().max(200).optional().describe("For 'move': target collection slug, e.g. 'decisions', 'architecture'.")
|
|
4719
4884
|
});
|
|
4720
|
-
var entriesListVariant =
|
|
4721
|
-
action:
|
|
4722
|
-
collection:
|
|
4723
|
-
status:
|
|
4724
|
-
tag:
|
|
4725
|
-
label:
|
|
4885
|
+
var entriesListVariant = z10.object({
|
|
4886
|
+
action: z10.literal("list"),
|
|
4887
|
+
collection: z10.string().max(200).optional(),
|
|
4888
|
+
status: z10.string().max(200).optional(),
|
|
4889
|
+
tag: z10.string().max(200).optional(),
|
|
4890
|
+
label: z10.string().max(200).optional()
|
|
4726
4891
|
});
|
|
4727
|
-
var entriesGetVariant =
|
|
4728
|
-
action:
|
|
4729
|
-
entryId:
|
|
4892
|
+
var entriesGetVariant = z10.object({
|
|
4893
|
+
action: z10.literal("get"),
|
|
4894
|
+
entryId: z10.string().max(200)
|
|
4730
4895
|
});
|
|
4731
|
-
var entriesBatchVariant =
|
|
4732
|
-
action:
|
|
4733
|
-
entryIds:
|
|
4896
|
+
var entriesBatchVariant = z10.object({
|
|
4897
|
+
action: z10.literal("batch"),
|
|
4898
|
+
entryIds: z10.array(z10.string().max(200)).min(1).max(20)
|
|
4734
4899
|
});
|
|
4735
|
-
var entriesSearchVariant =
|
|
4736
|
-
action:
|
|
4737
|
-
query:
|
|
4738
|
-
collection:
|
|
4739
|
-
status:
|
|
4900
|
+
var entriesSearchVariant = z10.object({
|
|
4901
|
+
action: z10.literal("search"),
|
|
4902
|
+
query: z10.string().min(2).max(500),
|
|
4903
|
+
collection: z10.string().max(200).optional(),
|
|
4904
|
+
status: z10.string().max(200).optional()
|
|
4740
4905
|
});
|
|
4741
|
-
var entriesUpdateVariant = updateEntrySchema.extend({ action:
|
|
4742
|
-
var entriesCommitVariant = commitEntrySchema.extend({ action:
|
|
4743
|
-
var entriesHistoryVariant = getHistorySchema.extend({ action:
|
|
4744
|
-
var entriesMoveVariant =
|
|
4745
|
-
action:
|
|
4746
|
-
entryId:
|
|
4747
|
-
toCollection:
|
|
4906
|
+
var entriesUpdateVariant = updateEntrySchema.extend({ action: z10.literal("update") });
|
|
4907
|
+
var entriesCommitVariant = commitEntrySchema.extend({ action: z10.literal("commit") });
|
|
4908
|
+
var entriesHistoryVariant = getHistorySchema.extend({ action: z10.literal("history") });
|
|
4909
|
+
var entriesMoveVariant = z10.object({
|
|
4910
|
+
action: z10.literal("move"),
|
|
4911
|
+
entryId: z10.string().max(200),
|
|
4912
|
+
toCollection: z10.string().max(200)
|
|
4748
4913
|
});
|
|
4749
|
-
var entriesVerifyVariant = verifyEntrySchema.extend({ action:
|
|
4750
|
-
var entriesActionUnion =
|
|
4914
|
+
var entriesVerifyVariant = verifyEntrySchema.extend({ action: z10.literal("verify") });
|
|
4915
|
+
var entriesActionUnion = z10.discriminatedUnion("action", [
|
|
4751
4916
|
entriesListVariant,
|
|
4752
4917
|
entriesGetVariant,
|
|
4753
4918
|
entriesBatchVariant,
|
|
@@ -4769,15 +4934,15 @@ var ENTRIES_ACTION_SPECS = {
|
|
|
4769
4934
|
move: { params: ["entryId", "toCollection"], description: "Both entryId and toCollection are required." },
|
|
4770
4935
|
verify: { params: ["entryId"], description: "entryId is required." }
|
|
4771
4936
|
};
|
|
4772
|
-
var entriesGetOutputSchema =
|
|
4773
|
-
entryId:
|
|
4774
|
-
name:
|
|
4775
|
-
collection:
|
|
4776
|
-
status:
|
|
4777
|
-
capturedAt:
|
|
4778
|
-
origin:
|
|
4779
|
-
originDetail:
|
|
4780
|
-
verificationStatus:
|
|
4937
|
+
var entriesGetOutputSchema = z10.object({
|
|
4938
|
+
entryId: z10.string(),
|
|
4939
|
+
name: z10.string(),
|
|
4940
|
+
collection: z10.string(),
|
|
4941
|
+
status: z10.string(),
|
|
4942
|
+
capturedAt: z10.number().optional(),
|
|
4943
|
+
origin: z10.string().optional(),
|
|
4944
|
+
originDetail: z10.string().optional(),
|
|
4945
|
+
verificationStatus: z10.string().optional(),
|
|
4781
4946
|
// Attestation-model finding (PR #341 review): the server's honest verifier label and
|
|
4782
4947
|
// derived attestation strength/basis — connectors NEVER re-derive strength (spec §5),
|
|
4783
4948
|
// they only render what chain.getEntry ships. Mirrors packages/cli EntryFromApi.
|
|
@@ -4786,72 +4951,72 @@ var entriesGetOutputSchema = z9.object({
|
|
|
4786
4951
|
// attestation.ts's AttestationStrength SSOT (allowlisted in Check D —
|
|
4787
4952
|
// scripts/check-collection-ssot.mjs's CHECK_D_ALLOWLIST — with the full
|
|
4788
4953
|
// reasoning for why this can't just import that module). Update both together.
|
|
4789
|
-
verifiedBy:
|
|
4790
|
-
attestation:
|
|
4791
|
-
strength:
|
|
4792
|
-
basis:
|
|
4954
|
+
verifiedBy: z10.string().optional(),
|
|
4955
|
+
attestation: z10.object({
|
|
4956
|
+
strength: z10.enum(["human-direct", "delegated", "system", "unattested"]),
|
|
4957
|
+
basis: z10.string().optional()
|
|
4793
4958
|
}).optional(),
|
|
4794
|
-
sourceRef:
|
|
4795
|
-
sourceExcerpt:
|
|
4796
|
-
why:
|
|
4959
|
+
sourceRef: z10.string().optional(),
|
|
4960
|
+
sourceExcerpt: z10.string().optional(),
|
|
4961
|
+
why: z10.string().optional(),
|
|
4797
4962
|
// TEN-2191: quality of the captured WHY — 'rationale' | 'missing' | 'restated'.
|
|
4798
|
-
whyQuality:
|
|
4799
|
-
data:
|
|
4800
|
-
relations:
|
|
4801
|
-
entryId:
|
|
4802
|
-
name:
|
|
4803
|
-
type:
|
|
4804
|
-
direction:
|
|
4963
|
+
whyQuality: z10.enum(["rationale", "missing", "restated"]).optional(),
|
|
4964
|
+
data: z10.record(z10.unknown()).optional(),
|
|
4965
|
+
relations: z10.array(z10.object({
|
|
4966
|
+
entryId: z10.string().optional(),
|
|
4967
|
+
name: z10.string(),
|
|
4968
|
+
type: z10.string(),
|
|
4969
|
+
direction: z10.string()
|
|
4805
4970
|
})).optional(),
|
|
4806
|
-
labels:
|
|
4971
|
+
labels: z10.array(z10.string()).optional()
|
|
4807
4972
|
}).passthrough();
|
|
4808
|
-
var entriesListOutputSchema =
|
|
4809
|
-
entries:
|
|
4810
|
-
entryId:
|
|
4811
|
-
name:
|
|
4812
|
-
collection:
|
|
4813
|
-
status:
|
|
4973
|
+
var entriesListOutputSchema = z10.object({
|
|
4974
|
+
entries: z10.array(z10.object({
|
|
4975
|
+
entryId: z10.string(),
|
|
4976
|
+
name: z10.string(),
|
|
4977
|
+
collection: z10.string(),
|
|
4978
|
+
status: z10.string()
|
|
4814
4979
|
})),
|
|
4815
|
-
total:
|
|
4980
|
+
total: z10.number()
|
|
4816
4981
|
});
|
|
4817
|
-
var entriesSearchOutputSchema =
|
|
4818
|
-
results:
|
|
4819
|
-
entryId:
|
|
4820
|
-
name:
|
|
4821
|
-
collection:
|
|
4822
|
-
status:
|
|
4823
|
-
score:
|
|
4982
|
+
var entriesSearchOutputSchema = z10.object({
|
|
4983
|
+
results: z10.array(z10.object({
|
|
4984
|
+
entryId: z10.string(),
|
|
4985
|
+
name: z10.string(),
|
|
4986
|
+
collection: z10.string(),
|
|
4987
|
+
status: z10.string(),
|
|
4988
|
+
score: z10.number().optional()
|
|
4824
4989
|
})),
|
|
4825
|
-
total:
|
|
4826
|
-
query:
|
|
4990
|
+
total: z10.number(),
|
|
4991
|
+
query: z10.string()
|
|
4827
4992
|
});
|
|
4828
|
-
var entriesBatchOutputSchema =
|
|
4829
|
-
entries:
|
|
4830
|
-
entryId:
|
|
4831
|
-
name:
|
|
4832
|
-
collection:
|
|
4833
|
-
status:
|
|
4834
|
-
capturedAt:
|
|
4835
|
-
origin:
|
|
4836
|
-
originDetail:
|
|
4837
|
-
verificationStatus:
|
|
4993
|
+
var entriesBatchOutputSchema = z10.object({
|
|
4994
|
+
entries: z10.array(z10.object({
|
|
4995
|
+
entryId: z10.string(),
|
|
4996
|
+
name: z10.string(),
|
|
4997
|
+
collection: z10.string(),
|
|
4998
|
+
status: z10.string(),
|
|
4999
|
+
capturedAt: z10.number().optional(),
|
|
5000
|
+
origin: z10.string().optional(),
|
|
5001
|
+
originDetail: z10.string().optional(),
|
|
5002
|
+
verificationStatus: z10.string().optional(),
|
|
4838
5003
|
// Attestation-model finding (PR #341 review): mirror entriesGetOutputSchema — batch
|
|
4839
5004
|
// entries now carry the same honest verifiedBy/attestation fields. Literal set is
|
|
4840
5005
|
// the same hand-kept SSOT mirror — see entriesGetOutputSchema's attestation
|
|
4841
5006
|
// comment above for the full Check D / kernel-import reasoning.
|
|
4842
|
-
verifiedBy:
|
|
4843
|
-
attestation:
|
|
4844
|
-
strength:
|
|
4845
|
-
basis:
|
|
5007
|
+
verifiedBy: z10.string().optional(),
|
|
5008
|
+
attestation: z10.object({
|
|
5009
|
+
strength: z10.enum(["human-direct", "delegated", "system", "unattested"]),
|
|
5010
|
+
basis: z10.string().optional()
|
|
4846
5011
|
}).optional(),
|
|
4847
|
-
sourceRef:
|
|
4848
|
-
sourceExcerpt:
|
|
5012
|
+
sourceRef: z10.string().optional(),
|
|
5013
|
+
sourceExcerpt: z10.string().optional(),
|
|
4849
5014
|
// TEN-2191: mirror entriesGetOutputSchema — batch entries now carry why/whyQuality.
|
|
4850
|
-
why:
|
|
4851
|
-
whyQuality:
|
|
4852
|
-
data:
|
|
5015
|
+
why: z10.string().optional(),
|
|
5016
|
+
whyQuality: z10.enum(["rationale", "missing", "restated"]).optional(),
|
|
5017
|
+
data: z10.record(z10.unknown()).optional()
|
|
4853
5018
|
}).passthrough()),
|
|
4854
|
-
total:
|
|
5019
|
+
total: z10.number()
|
|
4855
5020
|
});
|
|
4856
5021
|
function registerEntriesTools(server) {
|
|
4857
5022
|
const entriesHandlers = {
|
|
@@ -5243,41 +5408,41 @@ ${footer}` }],
|
|
|
5243
5408
|
}
|
|
5244
5409
|
|
|
5245
5410
|
// src/tools/relations.ts
|
|
5246
|
-
import { z as
|
|
5411
|
+
import { z as z12 } from "zod/v3";
|
|
5247
5412
|
|
|
5248
5413
|
// src/tools/graph.ts
|
|
5249
|
-
import { z as
|
|
5414
|
+
import { z as z11 } from "zod/v3";
|
|
5250
5415
|
var GRAPH_ACTIONS = ["find", "suggest"];
|
|
5251
|
-
var graphSchema =
|
|
5252
|
-
action:
|
|
5416
|
+
var graphSchema = z11.object({
|
|
5417
|
+
action: z11.enum(GRAPH_ACTIONS).describe(
|
|
5253
5418
|
"'find': traverse relations from an entry (graph walk). 'suggest': discover potential connections for an entry."
|
|
5254
5419
|
),
|
|
5255
|
-
entryId:
|
|
5256
|
-
direction:
|
|
5257
|
-
limit:
|
|
5258
|
-
depth:
|
|
5420
|
+
entryId: z11.string().max(200).describe("Entry ID, e.g. '<PREFIX>-<n>'"),
|
|
5421
|
+
direction: z11.enum(["incoming", "outgoing", "both"]).default("both").optional().describe("For find: 'incoming' = what references this, 'outgoing' = what this references"),
|
|
5422
|
+
limit: z11.number().min(1).max(20).default(10).optional().describe("For suggest: max suggestions to return"),
|
|
5423
|
+
depth: z11.number().min(1).max(3).default(2).optional().describe("For suggest: graph traversal depth")
|
|
5259
5424
|
});
|
|
5260
|
-
var graphFindOutputSchema =
|
|
5261
|
-
entryId:
|
|
5262
|
-
relations:
|
|
5263
|
-
entryId:
|
|
5264
|
-
name:
|
|
5265
|
-
type:
|
|
5266
|
-
direction:
|
|
5425
|
+
var graphFindOutputSchema = z11.object({
|
|
5426
|
+
entryId: z11.string(),
|
|
5427
|
+
relations: z11.array(z11.object({
|
|
5428
|
+
entryId: z11.string().optional(),
|
|
5429
|
+
name: z11.string(),
|
|
5430
|
+
type: z11.string(),
|
|
5431
|
+
direction: z11.enum(["outgoing", "incoming"])
|
|
5267
5432
|
})),
|
|
5268
|
-
total:
|
|
5433
|
+
total: z11.number()
|
|
5269
5434
|
});
|
|
5270
|
-
var graphSuggestOutputSchema =
|
|
5271
|
-
entryId:
|
|
5272
|
-
suggestions:
|
|
5273
|
-
targetEntryId:
|
|
5274
|
-
targetName:
|
|
5275
|
-
relationType:
|
|
5276
|
-
direction:
|
|
5277
|
-
confidence:
|
|
5278
|
-
reason:
|
|
5435
|
+
var graphSuggestOutputSchema = z11.object({
|
|
5436
|
+
entryId: z11.string(),
|
|
5437
|
+
suggestions: z11.array(z11.object({
|
|
5438
|
+
targetEntryId: z11.string().optional(),
|
|
5439
|
+
targetName: z11.string(),
|
|
5440
|
+
relationType: z11.string(),
|
|
5441
|
+
direction: z11.string(),
|
|
5442
|
+
confidence: z11.number(),
|
|
5443
|
+
reason: z11.string()
|
|
5279
5444
|
})),
|
|
5280
|
-
total:
|
|
5445
|
+
total: z11.number()
|
|
5281
5446
|
});
|
|
5282
5447
|
async function handleFind(entryId, direction) {
|
|
5283
5448
|
const relations = await kernelQuery("chain.listEntryRelations", { entryId });
|
|
@@ -5468,64 +5633,64 @@ async function handleSuggest(entryId, limit, depth) {
|
|
|
5468
5633
|
|
|
5469
5634
|
// src/tools/relations.ts
|
|
5470
5635
|
var RELATIONS_ACTIONS = ["create", "batch-create", "dismiss", "delete", "find", "suggest"];
|
|
5471
|
-
var relationItemSchema =
|
|
5472
|
-
from:
|
|
5473
|
-
to:
|
|
5474
|
-
type:
|
|
5636
|
+
var relationItemSchema = z12.object({
|
|
5637
|
+
from: z12.string().max(200),
|
|
5638
|
+
to: z12.string().max(200),
|
|
5639
|
+
type: z12.string().max(200)
|
|
5475
5640
|
});
|
|
5476
|
-
var relationsSchema =
|
|
5477
|
-
action:
|
|
5641
|
+
var relationsSchema = z12.object({
|
|
5642
|
+
action: z12.enum(RELATIONS_ACTIONS).describe(
|
|
5478
5643
|
"'create': link two entries. 'batch-create': create multiple relations (validates every item before writing any). 'dismiss': record that a suggestion was not relevant. 'delete': remove a relation. 'find': traverse relations from an entry (graph walk, absorbs graph action=find). 'suggest': discover potential connections for an entry (absorbs graph action=suggest)."
|
|
5479
5644
|
),
|
|
5480
|
-
from:
|
|
5481
|
-
to:
|
|
5482
|
-
type:
|
|
5483
|
-
score:
|
|
5484
|
-
relations:
|
|
5645
|
+
from: z12.string().max(200).optional().describe("For 'create'/'dismiss'/'delete': source entry ID."),
|
|
5646
|
+
to: z12.string().max(200).optional().describe("For 'create'/'dismiss'/'delete': target entry ID."),
|
|
5647
|
+
type: z12.string().max(200).optional().describe("For 'create'/'dismiss'/'delete': relation type."),
|
|
5648
|
+
score: z12.number().optional().describe("For 'dismiss': suggestion score from action=suggest."),
|
|
5649
|
+
relations: z12.array(relationItemSchema).min(1).max(20).optional().describe("For 'batch-create': array of {from, to, type}."),
|
|
5485
5650
|
// WP-316 S3: Preview gate — dry-run mode for action=create.
|
|
5486
|
-
preview:
|
|
5487
|
-
entryId:
|
|
5488
|
-
direction:
|
|
5489
|
-
limit:
|
|
5490
|
-
depth:
|
|
5651
|
+
preview: z12.boolean().optional().describe("For 'create': if true, validates the relation without writing. Returns what would happen. Default false."),
|
|
5652
|
+
entryId: z12.string().max(200).optional().describe("For 'find'/'suggest': entry ID, e.g. '<PREFIX>-<n>'."),
|
|
5653
|
+
direction: z12.enum(["incoming", "outgoing", "both"]).optional().describe("For 'find': 'incoming' = what references this, 'outgoing' = what this references. Default 'both'."),
|
|
5654
|
+
limit: z12.number().min(1).max(20).optional().describe("For 'suggest': max suggestions to return. Default 10."),
|
|
5655
|
+
depth: z12.number().min(1).max(3).optional().describe("For 'suggest': graph traversal depth. Default 2.")
|
|
5491
5656
|
});
|
|
5492
|
-
var relationsCreateVariant =
|
|
5493
|
-
action:
|
|
5494
|
-
from:
|
|
5495
|
-
to:
|
|
5496
|
-
type:
|
|
5497
|
-
score:
|
|
5498
|
-
preview:
|
|
5657
|
+
var relationsCreateVariant = z12.object({
|
|
5658
|
+
action: z12.literal("create"),
|
|
5659
|
+
from: z12.string().max(200),
|
|
5660
|
+
to: z12.string().max(200),
|
|
5661
|
+
type: z12.string().max(200),
|
|
5662
|
+
score: z12.number().optional(),
|
|
5663
|
+
preview: z12.boolean().optional()
|
|
5499
5664
|
});
|
|
5500
|
-
var relationsBatchCreateVariant =
|
|
5501
|
-
action:
|
|
5502
|
-
relations:
|
|
5665
|
+
var relationsBatchCreateVariant = z12.object({
|
|
5666
|
+
action: z12.literal("batch-create"),
|
|
5667
|
+
relations: z12.array(relationItemSchema).min(1).max(20)
|
|
5503
5668
|
});
|
|
5504
|
-
var relationsDismissVariant =
|
|
5505
|
-
action:
|
|
5506
|
-
from:
|
|
5507
|
-
to:
|
|
5508
|
-
type:
|
|
5509
|
-
score:
|
|
5669
|
+
var relationsDismissVariant = z12.object({
|
|
5670
|
+
action: z12.literal("dismiss"),
|
|
5671
|
+
from: z12.string().max(200),
|
|
5672
|
+
to: z12.string().max(200),
|
|
5673
|
+
type: z12.string().max(200).optional(),
|
|
5674
|
+
score: z12.number().optional()
|
|
5510
5675
|
});
|
|
5511
|
-
var relationsDeleteVariant =
|
|
5512
|
-
action:
|
|
5513
|
-
from:
|
|
5514
|
-
to:
|
|
5515
|
-
type:
|
|
5676
|
+
var relationsDeleteVariant = z12.object({
|
|
5677
|
+
action: z12.literal("delete"),
|
|
5678
|
+
from: z12.string().max(200),
|
|
5679
|
+
to: z12.string().max(200),
|
|
5680
|
+
type: z12.string().max(200)
|
|
5516
5681
|
});
|
|
5517
|
-
var relationsFindVariant =
|
|
5518
|
-
action:
|
|
5519
|
-
entryId:
|
|
5520
|
-
direction:
|
|
5682
|
+
var relationsFindVariant = z12.object({
|
|
5683
|
+
action: z12.literal("find"),
|
|
5684
|
+
entryId: z12.string().max(200),
|
|
5685
|
+
direction: z12.enum(["incoming", "outgoing", "both"]).optional().default("both")
|
|
5521
5686
|
});
|
|
5522
|
-
var relationsSuggestVariant =
|
|
5523
|
-
action:
|
|
5524
|
-
entryId:
|
|
5525
|
-
limit:
|
|
5526
|
-
depth:
|
|
5687
|
+
var relationsSuggestVariant = z12.object({
|
|
5688
|
+
action: z12.literal("suggest"),
|
|
5689
|
+
entryId: z12.string().max(200),
|
|
5690
|
+
limit: z12.number().min(1).max(20).optional().default(10),
|
|
5691
|
+
depth: z12.number().min(1).max(3).optional().default(2)
|
|
5527
5692
|
});
|
|
5528
|
-
var relationsActionUnion =
|
|
5693
|
+
var relationsActionUnion = z12.discriminatedUnion("action", [
|
|
5529
5694
|
relationsCreateVariant,
|
|
5530
5695
|
relationsBatchCreateVariant,
|
|
5531
5696
|
relationsDismissVariant,
|
|
@@ -5821,19 +5986,19 @@ async function handleDelete(from, to, type) {
|
|
|
5821
5986
|
}
|
|
5822
5987
|
|
|
5823
5988
|
// src/tools/context.ts
|
|
5824
|
-
import { z as
|
|
5989
|
+
import { z as z14 } from "zod/v3";
|
|
5825
5990
|
|
|
5826
5991
|
// src/tools/documents.ts
|
|
5827
|
-
import { z as
|
|
5992
|
+
import { z as z13 } from "zod/v3";
|
|
5828
5993
|
var DOCUMENTS_ACTIONS = ["get-last-verified-brief"];
|
|
5829
|
-
var documentsSchema =
|
|
5830
|
-
action:
|
|
5994
|
+
var documentsSchema = z13.object({
|
|
5995
|
+
action: z13.enum(DOCUMENTS_ACTIONS).describe(
|
|
5831
5996
|
"'get-last-verified-brief': fetch the most recent verified brief snapshot for a (templateId, scopeKey) pair. Returns the verified summary so agents can build delta narratives ('since you last verified, X workstreams advanced')."
|
|
5832
5997
|
),
|
|
5833
|
-
templateId:
|
|
5998
|
+
templateId: z13.string().max(200).describe(
|
|
5834
5999
|
"Brief template identifier \u2014 currently 'steering-brief' is the only registered template."
|
|
5835
6000
|
),
|
|
5836
|
-
scopeKey:
|
|
6001
|
+
scopeKey: z13.string().max(200).describe(
|
|
5837
6002
|
"Canonical scope key. Use 'workspace:<workspaceId>' for the full workspace brief, or 'initiative:<INI-ID>' for an initiative-scoped brief. The same formula is applied at write time (chainwork/docKernel/scopeKey.ts), so passing the wrong shape returns exists:false."
|
|
5838
6003
|
)
|
|
5839
6004
|
});
|
|
@@ -5913,89 +6078,89 @@ function epistemicCollectionHint(collectionName) {
|
|
|
5913
6078
|
return "";
|
|
5914
6079
|
}
|
|
5915
6080
|
var CONTEXT_ACTIONS = ["gather", "build", "neighborhood", "changes", "chain", "cross-cut", "incremental", "brief", "last-verified-brief"];
|
|
5916
|
-
var contextSchema =
|
|
6081
|
+
var contextSchema = z14.object({
|
|
5917
6082
|
// provenance: neighborhood BET-142; changes/chain/cross-cut/incremental/brief BET-239 (E4, E6)
|
|
5918
|
-
action:
|
|
6083
|
+
action: z14.enum(CONTEXT_ACTIONS).describe(
|
|
5919
6084
|
"'gather': assemble knowledge context (entry graph, task auto-load, journey mode, or graph mode). 'build': structured build spec for an entry. 'neighborhood': typed graph neighborhood for an entry \u2014 blocking chain, dependencies, parent context, tensions, staleness. 'changes': entries modified and relations created since a timestamp. Requires 'since' parameter. 'chain': directed traversal along one relation type to depth 4. Requires entryId. Optional: direction, relationType, maxHops (1-4). 'cross-cut': structural aggregation \u2014 all relations of a given type grouped by source collection. Requires 'relationType' parameter. 'incremental': delta since last brief run for a skill. Requires 'skill' parameter. Returns only entries changed since the skill's last brief. 'brief': compound intelligence query. Requires 'briefType' parameter: 'steering' (changes + structure + delta + readiness), 'confidence' (changes + active bets + tensions), or 'delta' (changes + relations since timestamp). Optional 'since' for delta type. 'last-verified-brief': fetch the most recent verified brief snapshot for a (templateId, scopeKey) pair (absorbs documents action=get-last-verified-brief). Requires templateId and scopeKey."
|
|
5920
6085
|
),
|
|
5921
|
-
entryId:
|
|
5922
|
-
mapEntryId:
|
|
6086
|
+
entryId: z14.string().max(200).optional().describe("For 'build'/'neighborhood'/'chain': entry ID, e.g. '<PREFIX>-<n>'. For 'gather': optional entry ID for entry-graph mode."),
|
|
6087
|
+
mapEntryId: z14.string().max(200).optional().describe(
|
|
5923
6088
|
"For 'gather': journey map entry ID for journey-aware context. Returns context organised by journey stage. Takes precedence over entryId when both are supplied. Example: '<PREFIX>-<n>'."
|
|
5924
6089
|
),
|
|
5925
|
-
task:
|
|
5926
|
-
since:
|
|
6090
|
+
task: z14.string().max(2e3).optional().describe("For 'gather': natural-language task description for loading task-relevant governance, binding constraints, and supporting context."),
|
|
6091
|
+
since: z14.string().max(200).optional().describe(
|
|
5927
6092
|
"For 'changes': ISO 8601 timestamp \u2014 returns entries/relations modified since this time. For 'brief' briefType='delta': optional custom timestamp. Example: '2026-03-24T00:00:00Z'."
|
|
5928
6093
|
),
|
|
5929
|
-
direction:
|
|
5930
|
-
relationType:
|
|
6094
|
+
direction: z14.enum(["outgoing", "incoming"]).default("outgoing").optional().describe("For 'chain' action: traversal direction. 'outgoing' follows relations from source, 'incoming' follows relations to source. Default: outgoing."),
|
|
6095
|
+
relationType: z14.string().max(200).optional().describe(
|
|
5931
6096
|
"Relation type filter. For 'chain': optional filter to traverse only this relation type. For 'cross-cut': required \u2014 scans all relations of this type across the workspace. Examples: 'part_of', 'informs', 'governs', 'blocks', 'depends_on'."
|
|
5932
6097
|
),
|
|
5933
|
-
mode:
|
|
5934
|
-
maxHops:
|
|
5935
|
-
maxResults:
|
|
5936
|
-
strategy:
|
|
5937
|
-
skill:
|
|
6098
|
+
mode: z14.enum(["search", "graph"]).default("search").optional().describe("For gather: 'search' (default) or 'graph' (enhanced with provenance paths). Ignored when mapEntryId is provided."),
|
|
6099
|
+
maxHops: z14.number().min(1).max(4).default(2).describe("Relation traversal depth (1=direct only, 2=default, 3=wide net, 4=deep chain walk)"),
|
|
6100
|
+
maxResults: z14.number().min(1).max(25).default(10).optional().describe("Max entries to return in gather task mode (default 10)"),
|
|
6101
|
+
strategy: z14.enum(["hybrid", "keyword"]).default("keyword").optional().describe("Seed strategy for task-based gather: 'keyword' (FTS only, default) or 'hybrid' (vector + FTS). Only affects task mode."),
|
|
6102
|
+
skill: z14.string().max(200).optional().describe(
|
|
5938
6103
|
"Skill name for 'incremental' action \u2014 identifies which skill's brief history to compare against. Examples: 'preflight', 'shaping', 'review'. Required when action is 'incremental'."
|
|
5939
6104
|
),
|
|
5940
|
-
briefType:
|
|
6105
|
+
briefType: z14.enum(["steering", "confidence", "delta"]).optional().describe(
|
|
5941
6106
|
"Compound query type for 'brief' action. 'steering': 7d changes + structural aggregation (part_of, depends_on, constrains) + incremental delta + workspace readiness. 'confidence': 7d changes + active bets summary + active tensions breakdown. 'delta': changes + relations since a custom timestamp (use 'since' param). Required when action is 'brief'."
|
|
5942
6107
|
),
|
|
5943
|
-
templateId:
|
|
6108
|
+
templateId: z14.string().max(200).optional().describe(
|
|
5944
6109
|
"For 'last-verified-brief': brief template identifier \u2014 currently 'steering-brief' is the only registered template."
|
|
5945
6110
|
),
|
|
5946
|
-
scopeKey:
|
|
6111
|
+
scopeKey: z14.string().max(200).optional().describe(
|
|
5947
6112
|
"For 'last-verified-brief': canonical scope key \u2014 'workspace:<workspaceId>' or 'initiative:<INI-ID>'."
|
|
5948
6113
|
)
|
|
5949
6114
|
});
|
|
5950
|
-
var contextGatherVariant =
|
|
5951
|
-
action:
|
|
5952
|
-
entryId:
|
|
5953
|
-
mapEntryId:
|
|
5954
|
-
task:
|
|
5955
|
-
mode:
|
|
5956
|
-
maxHops:
|
|
5957
|
-
maxResults:
|
|
5958
|
-
strategy:
|
|
6115
|
+
var contextGatherVariant = z14.object({
|
|
6116
|
+
action: z14.literal("gather"),
|
|
6117
|
+
entryId: z14.string().max(200).optional(),
|
|
6118
|
+
mapEntryId: z14.string().max(200).optional(),
|
|
6119
|
+
task: z14.string().max(2e3).optional(),
|
|
6120
|
+
mode: z14.enum(["search", "graph"]).optional().default("search"),
|
|
6121
|
+
maxHops: z14.number().min(1).max(4).optional().default(2),
|
|
6122
|
+
maxResults: z14.number().min(1).max(25).optional().default(10),
|
|
6123
|
+
strategy: z14.enum(["hybrid", "keyword"]).optional().default("keyword")
|
|
5959
6124
|
});
|
|
5960
|
-
var contextBuildVariant =
|
|
5961
|
-
action:
|
|
5962
|
-
entryId:
|
|
5963
|
-
maxHops:
|
|
6125
|
+
var contextBuildVariant = z14.object({
|
|
6126
|
+
action: z14.literal("build"),
|
|
6127
|
+
entryId: z14.string().max(200),
|
|
6128
|
+
maxHops: z14.number().min(1).max(4).optional().default(2)
|
|
5964
6129
|
});
|
|
5965
|
-
var contextNeighborhoodVariant =
|
|
5966
|
-
action:
|
|
5967
|
-
entryId:
|
|
6130
|
+
var contextNeighborhoodVariant = z14.object({
|
|
6131
|
+
action: z14.literal("neighborhood"),
|
|
6132
|
+
entryId: z14.string().max(200)
|
|
5968
6133
|
});
|
|
5969
|
-
var contextChangesVariant =
|
|
5970
|
-
action:
|
|
5971
|
-
since:
|
|
6134
|
+
var contextChangesVariant = z14.object({
|
|
6135
|
+
action: z14.literal("changes"),
|
|
6136
|
+
since: z14.string().max(200)
|
|
5972
6137
|
});
|
|
5973
|
-
var contextChainVariant =
|
|
5974
|
-
action:
|
|
5975
|
-
entryId:
|
|
5976
|
-
direction:
|
|
5977
|
-
maxHops:
|
|
5978
|
-
relationType:
|
|
6138
|
+
var contextChainVariant = z14.object({
|
|
6139
|
+
action: z14.literal("chain"),
|
|
6140
|
+
entryId: z14.string().max(200),
|
|
6141
|
+
direction: z14.enum(["outgoing", "incoming"]).optional().default("outgoing"),
|
|
6142
|
+
maxHops: z14.number().min(1).max(4).optional().default(2),
|
|
6143
|
+
relationType: z14.string().max(200).optional()
|
|
5979
6144
|
});
|
|
5980
|
-
var contextCrossCutVariant =
|
|
5981
|
-
action:
|
|
5982
|
-
relationType:
|
|
6145
|
+
var contextCrossCutVariant = z14.object({
|
|
6146
|
+
action: z14.literal("cross-cut"),
|
|
6147
|
+
relationType: z14.string().max(200)
|
|
5983
6148
|
});
|
|
5984
|
-
var contextIncrementalVariant =
|
|
5985
|
-
action:
|
|
5986
|
-
skill:
|
|
6149
|
+
var contextIncrementalVariant = z14.object({
|
|
6150
|
+
action: z14.literal("incremental"),
|
|
6151
|
+
skill: z14.string().max(200)
|
|
5987
6152
|
});
|
|
5988
|
-
var contextBriefVariant =
|
|
5989
|
-
action:
|
|
5990
|
-
briefType:
|
|
5991
|
-
since:
|
|
6153
|
+
var contextBriefVariant = z14.object({
|
|
6154
|
+
action: z14.literal("brief"),
|
|
6155
|
+
briefType: z14.enum(["steering", "confidence", "delta"]),
|
|
6156
|
+
since: z14.string().max(200).optional()
|
|
5992
6157
|
});
|
|
5993
|
-
var contextLastVerifiedBriefVariant =
|
|
5994
|
-
action:
|
|
5995
|
-
templateId:
|
|
5996
|
-
scopeKey:
|
|
6158
|
+
var contextLastVerifiedBriefVariant = z14.object({
|
|
6159
|
+
action: z14.literal("last-verified-brief"),
|
|
6160
|
+
templateId: z14.string().max(200),
|
|
6161
|
+
scopeKey: z14.string().max(200)
|
|
5997
6162
|
});
|
|
5998
|
-
var contextActionUnion =
|
|
6163
|
+
var contextActionUnion = z14.discriminatedUnion("action", [
|
|
5999
6164
|
contextGatherVariant,
|
|
6000
6165
|
contextBuildVariant,
|
|
6001
6166
|
contextNeighborhoodVariant,
|
|
@@ -7036,20 +7201,20 @@ function formatTimeAgo(ms) {
|
|
|
7036
7201
|
}
|
|
7037
7202
|
|
|
7038
7203
|
// src/tools/collections.ts
|
|
7039
|
-
import { z as
|
|
7204
|
+
import { z as z16 } from "zod/v3";
|
|
7040
7205
|
|
|
7041
7206
|
// src/tools/labels.ts
|
|
7042
|
-
import { z as
|
|
7043
|
-
var labelsSchema =
|
|
7044
|
-
action:
|
|
7045
|
-
slug:
|
|
7046
|
-
name:
|
|
7047
|
-
color:
|
|
7048
|
-
description:
|
|
7049
|
-
parentSlug:
|
|
7050
|
-
isGroup:
|
|
7051
|
-
order:
|
|
7052
|
-
entryId:
|
|
7207
|
+
import { z as z15 } from "zod/v3";
|
|
7208
|
+
var labelsSchema = z15.object({
|
|
7209
|
+
action: z15.enum(["list", "create", "update", "delete", "apply", "remove"]).describe("Action: list all labels, create/update/delete a label, or apply/remove a label on an entry"),
|
|
7210
|
+
slug: z15.string().max(200).optional().describe("Label slug (required for create/update/delete/apply/remove)"),
|
|
7211
|
+
name: z15.string().max(500).optional().describe("Display name (required for create)"),
|
|
7212
|
+
color: z15.string().max(50).optional().describe("Hex color, e.g. '#ef4444'"),
|
|
7213
|
+
description: z15.string().max(2e3).optional().describe("What this label means"),
|
|
7214
|
+
parentSlug: z15.string().max(200).optional().describe("Parent group slug for label hierarchy"),
|
|
7215
|
+
isGroup: z15.boolean().optional().describe("True if this is a group container, not a taggable label"),
|
|
7216
|
+
order: z15.number().optional().describe("Sort order within its group"),
|
|
7217
|
+
entryId: z15.string().max(200).optional().describe("Entry ID for apply/remove actions")
|
|
7053
7218
|
});
|
|
7054
7219
|
async function handleLabelsList() {
|
|
7055
7220
|
const labels = await kernelQuery("chain.listLabels");
|
|
@@ -7154,128 +7319,128 @@ var COLLECTIONS_ACTIONS = [
|
|
|
7154
7319
|
"label-apply",
|
|
7155
7320
|
"label-remove"
|
|
7156
7321
|
];
|
|
7157
|
-
var qualityCriterionSchema =
|
|
7158
|
-
field:
|
|
7322
|
+
var qualityCriterionSchema = z16.object({
|
|
7323
|
+
field: z16.string().max(200).describe("Entry data field key this criterion applies to, e.g. 'description', 'owner'"),
|
|
7159
7324
|
// WP-480 S1: `max_length` — must mirror the Convex rule union, or the tool rejects a
|
|
7160
7325
|
// valid criterion before the request ever reaches the server.
|
|
7161
|
-
rule:
|
|
7162
|
-
value:
|
|
7326
|
+
rule: z16.enum(["required", "min_length", "max_length", "pattern"]).describe("'required': field must be non-empty (blocks accept). 'min_length': minimum string length (warns). 'max_length': maximum string length (warns). 'pattern': regex match (warns)."),
|
|
7327
|
+
value: z16.string().max(500).optional().describe("For min_length/max_length: the length bound as a string integer. For pattern: the regex string. Unused for 'required'.")
|
|
7163
7328
|
});
|
|
7164
|
-
var fieldSchema =
|
|
7165
|
-
key:
|
|
7166
|
-
label:
|
|
7167
|
-
type:
|
|
7168
|
-
required:
|
|
7169
|
-
options:
|
|
7170
|
-
searchable:
|
|
7171
|
-
displayHint:
|
|
7172
|
-
zone:
|
|
7173
|
-
colorMap:
|
|
7329
|
+
var fieldSchema = z16.object({
|
|
7330
|
+
key: z16.string().max(200).describe("Field key, e.g. 'description', 'severity', 'status'"),
|
|
7331
|
+
label: z16.string().max(200).describe("Display label, e.g. 'Description', 'Severity'"),
|
|
7332
|
+
type: z16.string().max(50).describe("Field type: 'string', 'select', 'array', 'number', 'boolean'"),
|
|
7333
|
+
required: z16.boolean().optional().describe("Whether this field is required"),
|
|
7334
|
+
options: z16.array(z16.string().max(200)).max(200).optional().describe("Options for 'select' type fields"),
|
|
7335
|
+
searchable: z16.boolean().optional().describe("Whether this field is included in full-text search"),
|
|
7336
|
+
displayHint: z16.enum(["hero", "badge", "meta", "section", "hidden", "inline-meta"]).optional().describe("V2 rendering hint: how the field should be displayed in Cortex"),
|
|
7337
|
+
zone: z16.enum(["header", "body", "meta"]).optional().describe("V2 layout zone: where the field appears in the entry view"),
|
|
7338
|
+
colorMap: z16.record(z16.string().max(50)).optional().describe("V2 value-to-semantic-color mapping, e.g. { critical: 'danger', low: 'success' }"),
|
|
7174
7339
|
// ENT-61
|
|
7175
|
-
accentSource:
|
|
7340
|
+
accentSource: z16.boolean().optional().describe("When true, this field's colorMap value drives the card-level accent styling"),
|
|
7176
7341
|
// ENT-61
|
|
7177
|
-
iconMap:
|
|
7178
|
-
helpText:
|
|
7179
|
-
optionDescriptions:
|
|
7342
|
+
iconMap: z16.record(z16.string(), z16.string().max(50)).optional().describe("Maps field values to icons (emoji/symbol), prepended to badge text"),
|
|
7343
|
+
helpText: z16.string().max(2e3).optional().describe("Help text shown in editors and describe output"),
|
|
7344
|
+
optionDescriptions: z16.record(z16.string().max(500)).optional().describe("Per-option guidance for select fields"),
|
|
7180
7345
|
// BET-136
|
|
7181
|
-
semanticRole:
|
|
7346
|
+
semanticRole: z16.enum(["problem", "appetite", "elements", "architecture", "done_when", "risks", "exclusions"]).optional().describe("Semantic role for schema-driven consumers \u2014 enables field-key-independent validation and rendering"),
|
|
7182
7347
|
// BET-196
|
|
7183
|
-
maxLength:
|
|
7348
|
+
maxLength: z16.number().optional().describe("Maximum character length for field values. Three-tier resolution: explicit > displayHint > type fallback."),
|
|
7184
7349
|
// BET-196
|
|
7185
|
-
minLength:
|
|
7350
|
+
minLength: z16.number().optional().describe("Minimum character length for field values. Only explicit \u2014 no defaults.")
|
|
7186
7351
|
});
|
|
7187
|
-
var collectionsSchema =
|
|
7188
|
-
action:
|
|
7352
|
+
var collectionsSchema = z16.object({
|
|
7353
|
+
action: z16.enum(COLLECTIONS_ACTIONS).describe(
|
|
7189
7354
|
"'list': browse all collections. 'create': create a new collection. 'update': update an existing collection. 'describe': full documentation for one collection \u2014 fields, option guides, usage guidance, examples. 'audit': health report for all collections \u2014 missing classification, icon, displayHint coverage, and field schema gaps. 'export': full system_collection_definitions export with classification metadata (thinkingLayer, classificationPriority, classificationCheck, classificationSignals, governanceRole, governanceFunction, timelineRole, canBeElementOf, descriptionFieldKey). Admin only. 'label-list'/'label-create'/'label-update'/'label-delete'/'label-apply'/'label-remove': manage workspace labels (absorbs the `labels` tool)."
|
|
7190
7355
|
),
|
|
7191
|
-
slug:
|
|
7192
|
-
name:
|
|
7193
|
-
description:
|
|
7194
|
-
purpose:
|
|
7195
|
-
icon:
|
|
7196
|
-
navGroup:
|
|
7197
|
-
fields:
|
|
7356
|
+
slug: z16.string().max(200).optional().describe("URL-safe identifier for create/update, e.g. 'glossary', 'tech-debt'. For label-*: label slug."),
|
|
7357
|
+
name: z16.string().max(500).optional().describe("Display name for create, or new name for update. For label-create: label display name."),
|
|
7358
|
+
description: z16.string().max(2e4).optional().describe("What this collection is for. For label-create/label-update: what the label means."),
|
|
7359
|
+
purpose: z16.string().max(2e3).optional().describe("Why this collection exists \u2014 strategic reason"),
|
|
7360
|
+
icon: z16.string().max(50).optional().describe("Emoji icon for the collection"),
|
|
7361
|
+
navGroup: z16.enum(["daily", "strategic", "governance", "reference", "collections"]).optional().describe("Sidebar placement: 'daily', 'strategic', 'governance', 'reference', 'collections'"),
|
|
7362
|
+
fields: z16.array(fieldSchema).max(200).optional().describe("Field definitions for create, or replacement schema for update (replaces all fields)"),
|
|
7198
7363
|
// ENT-62
|
|
7199
|
-
defaultCanonicalKey:
|
|
7364
|
+
defaultCanonicalKey: z16.string().max(200).optional().describe("The canonical_key entries in this collection default to (e.g. 'decision', 'insight'). Consumers read from collection doc; code map is fallback."),
|
|
7200
7365
|
// ENT-67
|
|
7201
|
-
defaultWorkflowStatus:
|
|
7366
|
+
defaultWorkflowStatus: z16.string().max(200).optional().describe("Default workflowStatus for new entries. Must be in validWorkflowStatuses when set (e.g. 'hypothesis' for insights)."),
|
|
7202
7367
|
// ENT-65
|
|
7203
|
-
validWorkflowStatuses:
|
|
7368
|
+
validWorkflowStatuses: z16.array(z16.string().max(200)).max(50).optional().describe("The allowed workflowStatus values for entries in this collection. New entries are validated against this list. Empty array means no constraint."),
|
|
7204
7369
|
// ENT-65, FEAT-200
|
|
7205
|
-
classificationCheck:
|
|
7370
|
+
classificationCheck: z16.string().max(500).optional().describe("LLM decision-tree check for this collection (3\u2013500 chars). Guides the classifier in routing entries here."),
|
|
7206
7371
|
// ENT-65, FEAT-200
|
|
7207
|
-
classificationPriority:
|
|
7372
|
+
classificationPriority: z16.number().optional().describe("Classifier priority (1\u20139, lower = higher priority). Used with classificationCheck to order the decision tree."),
|
|
7208
7373
|
// FEAT-301 Slice 2: quality gate criteria and usage guidance.
|
|
7209
7374
|
// FEAT-257
|
|
7210
|
-
qualityCriteria:
|
|
7211
|
-
usageGuidance:
|
|
7375
|
+
qualityCriteria: z16.array(qualityCriterionSchema).max(50).optional().describe("Per-collection accept gate rules. 'required' rule hard-blocks accepts on empty fields; 'min_length'/'pattern' rules warn. Pass an empty array to clear all criteria."),
|
|
7376
|
+
usageGuidance: z16.string().max(2e4).optional().describe("Plain-text guidance shown to agents and users: when to use this collection, when not to, and what makes a good entry."),
|
|
7212
7377
|
// For label-*
|
|
7213
|
-
color:
|
|
7214
|
-
parentSlug:
|
|
7215
|
-
isGroup:
|
|
7216
|
-
order:
|
|
7217
|
-
entryId:
|
|
7378
|
+
color: z16.string().max(50).optional().describe("For label-create/label-update: hex color, e.g. '#ef4444'."),
|
|
7379
|
+
parentSlug: z16.string().max(200).optional().describe("For label-create: parent group slug for label hierarchy."),
|
|
7380
|
+
isGroup: z16.boolean().optional().describe("For label-create/label-update: true if this is a group container, not a taggable label."),
|
|
7381
|
+
order: z16.number().optional().describe("For label-create/label-update: sort order within its group."),
|
|
7382
|
+
entryId: z16.string().max(200).optional().describe("For label-apply/label-remove: entry ID.")
|
|
7218
7383
|
});
|
|
7219
|
-
var collectionsListVariant =
|
|
7220
|
-
var collectionsDescribeVariant =
|
|
7221
|
-
var collectionsCreateVariant =
|
|
7222
|
-
action:
|
|
7223
|
-
slug:
|
|
7224
|
-
name:
|
|
7225
|
-
description:
|
|
7226
|
-
purpose:
|
|
7227
|
-
icon:
|
|
7228
|
-
navGroup:
|
|
7229
|
-
fields:
|
|
7230
|
-
defaultCanonicalKey:
|
|
7231
|
-
defaultWorkflowStatus:
|
|
7232
|
-
validWorkflowStatuses:
|
|
7233
|
-
classificationCheck:
|
|
7234
|
-
classificationPriority:
|
|
7384
|
+
var collectionsListVariant = z16.object({ action: z16.literal("list") });
|
|
7385
|
+
var collectionsDescribeVariant = z16.object({ action: z16.literal("describe"), slug: z16.string().max(200) });
|
|
7386
|
+
var collectionsCreateVariant = z16.object({
|
|
7387
|
+
action: z16.literal("create"),
|
|
7388
|
+
slug: z16.string().max(200),
|
|
7389
|
+
name: z16.string().max(500),
|
|
7390
|
+
description: z16.string().max(2e4).optional(),
|
|
7391
|
+
purpose: z16.string().max(2e3).optional(),
|
|
7392
|
+
icon: z16.string().max(50).optional(),
|
|
7393
|
+
navGroup: z16.enum(["daily", "strategic", "governance", "reference", "collections"]).optional(),
|
|
7394
|
+
fields: z16.array(fieldSchema).min(1),
|
|
7395
|
+
defaultCanonicalKey: z16.string().max(200).optional(),
|
|
7396
|
+
defaultWorkflowStatus: z16.string().max(200).optional(),
|
|
7397
|
+
validWorkflowStatuses: z16.array(z16.string().max(200)).optional(),
|
|
7398
|
+
classificationCheck: z16.string().max(500).optional(),
|
|
7399
|
+
classificationPriority: z16.number().optional()
|
|
7235
7400
|
});
|
|
7236
|
-
var collectionsUpdateVariant =
|
|
7237
|
-
action:
|
|
7238
|
-
slug:
|
|
7239
|
-
name:
|
|
7240
|
-
description:
|
|
7241
|
-
purpose:
|
|
7242
|
-
icon:
|
|
7243
|
-
navGroup:
|
|
7244
|
-
fields:
|
|
7245
|
-
defaultCanonicalKey:
|
|
7246
|
-
defaultWorkflowStatus:
|
|
7247
|
-
validWorkflowStatuses:
|
|
7248
|
-
classificationCheck:
|
|
7249
|
-
classificationPriority:
|
|
7250
|
-
qualityCriteria:
|
|
7251
|
-
usageGuidance:
|
|
7401
|
+
var collectionsUpdateVariant = z16.object({
|
|
7402
|
+
action: z16.literal("update"),
|
|
7403
|
+
slug: z16.string().max(200),
|
|
7404
|
+
name: z16.string().max(500).optional(),
|
|
7405
|
+
description: z16.string().max(2e4).optional(),
|
|
7406
|
+
purpose: z16.string().max(2e3).optional(),
|
|
7407
|
+
icon: z16.string().max(50).optional(),
|
|
7408
|
+
navGroup: z16.enum(["daily", "strategic", "governance", "reference", "collections"]).optional(),
|
|
7409
|
+
fields: z16.array(fieldSchema).optional(),
|
|
7410
|
+
defaultCanonicalKey: z16.string().max(200).optional(),
|
|
7411
|
+
defaultWorkflowStatus: z16.string().max(200).optional(),
|
|
7412
|
+
validWorkflowStatuses: z16.array(z16.string().max(200)).optional(),
|
|
7413
|
+
classificationCheck: z16.string().max(500).optional(),
|
|
7414
|
+
classificationPriority: z16.number().optional(),
|
|
7415
|
+
qualityCriteria: z16.array(qualityCriterionSchema).optional(),
|
|
7416
|
+
usageGuidance: z16.string().max(2e4).optional()
|
|
7252
7417
|
});
|
|
7253
|
-
var collectionsAuditVariant =
|
|
7254
|
-
var collectionsExportVariant =
|
|
7255
|
-
var collectionsLabelListVariant =
|
|
7256
|
-
var collectionsLabelCreateVariant =
|
|
7257
|
-
action:
|
|
7258
|
-
slug:
|
|
7259
|
-
name:
|
|
7260
|
-
color:
|
|
7261
|
-
description:
|
|
7262
|
-
parentSlug:
|
|
7263
|
-
isGroup:
|
|
7264
|
-
order:
|
|
7418
|
+
var collectionsAuditVariant = z16.object({ action: z16.literal("audit") });
|
|
7419
|
+
var collectionsExportVariant = z16.object({ action: z16.literal("export") });
|
|
7420
|
+
var collectionsLabelListVariant = z16.object({ action: z16.literal("label-list") });
|
|
7421
|
+
var collectionsLabelCreateVariant = z16.object({
|
|
7422
|
+
action: z16.literal("label-create"),
|
|
7423
|
+
slug: z16.string().max(200),
|
|
7424
|
+
name: z16.string().max(500),
|
|
7425
|
+
color: z16.string().max(50).optional(),
|
|
7426
|
+
description: z16.string().max(2e3).optional(),
|
|
7427
|
+
parentSlug: z16.string().max(200).optional(),
|
|
7428
|
+
isGroup: z16.boolean().optional(),
|
|
7429
|
+
order: z16.number().optional()
|
|
7265
7430
|
});
|
|
7266
|
-
var collectionsLabelUpdateVariant =
|
|
7267
|
-
action:
|
|
7268
|
-
slug:
|
|
7269
|
-
name:
|
|
7270
|
-
color:
|
|
7271
|
-
description:
|
|
7272
|
-
isGroup:
|
|
7273
|
-
order:
|
|
7431
|
+
var collectionsLabelUpdateVariant = z16.object({
|
|
7432
|
+
action: z16.literal("label-update"),
|
|
7433
|
+
slug: z16.string().max(200),
|
|
7434
|
+
name: z16.string().max(500).optional(),
|
|
7435
|
+
color: z16.string().max(50).optional(),
|
|
7436
|
+
description: z16.string().max(2e3).optional(),
|
|
7437
|
+
isGroup: z16.boolean().optional(),
|
|
7438
|
+
order: z16.number().optional()
|
|
7274
7439
|
});
|
|
7275
|
-
var collectionsLabelDeleteVariant =
|
|
7276
|
-
var collectionsLabelApplyVariant =
|
|
7277
|
-
var collectionsLabelRemoveVariant =
|
|
7278
|
-
var collectionsActionUnion =
|
|
7440
|
+
var collectionsLabelDeleteVariant = z16.object({ action: z16.literal("label-delete"), slug: z16.string().max(200) });
|
|
7441
|
+
var collectionsLabelApplyVariant = z16.object({ action: z16.literal("label-apply"), slug: z16.string().max(200), entryId: z16.string().max(200) });
|
|
7442
|
+
var collectionsLabelRemoveVariant = z16.object({ action: z16.literal("label-remove"), slug: z16.string().max(200), entryId: z16.string().max(200) });
|
|
7443
|
+
var collectionsActionUnion = z16.discriminatedUnion("action", [
|
|
7279
7444
|
collectionsListVariant,
|
|
7280
7445
|
collectionsDescribeVariant,
|
|
7281
7446
|
collectionsCreateVariant,
|
|
@@ -7660,7 +7825,7 @@ async function handleExport() {
|
|
|
7660
7825
|
}
|
|
7661
7826
|
|
|
7662
7827
|
// src/tools/orient.ts
|
|
7663
|
-
import { z as
|
|
7828
|
+
import { z as z20 } from "zod/v3";
|
|
7664
7829
|
|
|
7665
7830
|
// src/tools/planned-work.ts
|
|
7666
7831
|
function buildPlannedWork(allEntries) {
|
|
@@ -8661,12 +8826,12 @@ function replaceVocabTokens(body, workspaceCtx, collectionCtxMap) {
|
|
|
8661
8826
|
}
|
|
8662
8827
|
|
|
8663
8828
|
// src/tools/start_pb.ts
|
|
8664
|
-
import { z as
|
|
8829
|
+
import { z as z18 } from "zod/v3";
|
|
8665
8830
|
|
|
8666
8831
|
// src/tools/skills.ts
|
|
8667
|
-
import { z as
|
|
8668
|
-
var skillsSchema =
|
|
8669
|
-
entryId:
|
|
8832
|
+
import { z as z17 } from "zod/v3";
|
|
8833
|
+
var skillsSchema = z17.object({
|
|
8834
|
+
entryId: z17.string().min(1).describe(
|
|
8670
8835
|
"Workspace-scoped skill entry id (e.g. 'SKILL-pb-setup'). The tool refuses non-skill entries (canonicalKey !== 'skill') with INVALID_KIND."
|
|
8671
8836
|
)
|
|
8672
8837
|
});
|
|
@@ -8679,8 +8844,8 @@ async function loadSkillBody(entryId) {
|
|
|
8679
8844
|
}
|
|
8680
8845
|
|
|
8681
8846
|
// src/tools/start_pb.ts
|
|
8682
|
-
var startPbSchema =
|
|
8683
|
-
task:
|
|
8847
|
+
var startPbSchema = z18.object({
|
|
8848
|
+
task: z18.string().max(2e3).optional().describe(
|
|
8684
8849
|
"What you're about to work on (e.g. 'implementing auth middleware'). Grounded/connected workspaces: filters governance to show relevant principles, standards, and business rules. Blank/seeded workspaces: ignored (setup flow takes over)."
|
|
8685
8850
|
)
|
|
8686
8851
|
// TEN-2431: no `scope` param — start_pb's governance matches orient's scope-BLIND RENDERED
|
|
@@ -9039,15 +9204,15 @@ ${FEEDBACK_HINT}` }],
|
|
|
9039
9204
|
}
|
|
9040
9205
|
|
|
9041
9206
|
// src/tools/record_activation.ts
|
|
9042
|
-
import { z as
|
|
9043
|
-
var recordActivationSchema =
|
|
9044
|
-
confirmedEntryCount:
|
|
9207
|
+
import { z as z19 } from "zod/v3";
|
|
9208
|
+
var recordActivationSchema = z19.object({
|
|
9209
|
+
confirmedEntryCount: z19.number().int().min(0).describe(
|
|
9045
9210
|
"Confirmed-entry count from the Phase 4 capture loop. The mutation enforces >=10."
|
|
9046
9211
|
),
|
|
9047
|
-
entriesAcrossCollections:
|
|
9212
|
+
entriesAcrossCollections: z19.number().int().min(0).describe(
|
|
9048
9213
|
"Number of distinct collections those entries span. The mutation enforces >=2 (diversity soft-gate)."
|
|
9049
9214
|
),
|
|
9050
|
-
retrievalDemoConfirmed:
|
|
9215
|
+
retrievalDemoConfirmed: z19.boolean().describe(
|
|
9051
9216
|
"True if the retrieval round-trip ran successfully in Phase 4. The mutation rejects false."
|
|
9052
9217
|
)
|
|
9053
9218
|
});
|
|
@@ -9120,65 +9285,65 @@ async function markOrientedWithSnapshotFallback(agentSessionId, coherenceSnapsho
|
|
|
9120
9285
|
}
|
|
9121
9286
|
}
|
|
9122
9287
|
var ORIENT_ACTIONS = ["start", "task", "record-activation"];
|
|
9123
|
-
var orientSchema =
|
|
9124
|
-
action:
|
|
9288
|
+
var orientSchema = z20.object({
|
|
9289
|
+
action: z20.enum(ORIENT_ACTIONS).optional().default("task").describe(
|
|
9125
9290
|
"'start': universal session opener (absorbs start_pb) \u2014 stage-aware setup skill or standup briefing. 'task': task-grounded context loader \u2014 the original orient behavior. 'record-activation': chat-only activation receipt writer (absorbs record_activation)."
|
|
9126
9291
|
),
|
|
9127
|
-
mode:
|
|
9128
|
-
tier:
|
|
9292
|
+
mode: z20.enum(["full", "brief"]).optional().default("full").describe("For 'task': full = full context (default). brief = compact summary for mid-session re-orientation. Prefer using the `tier` param for depth control."),
|
|
9293
|
+
tier: z20.enum(["summary", "standard", "full"]).optional().describe(
|
|
9129
9294
|
"For 'task': payload depth. Defaults to summary (~10 KB) when task is provided; standard (~256 KB) when task is absent. Pass summary, standard, or full to override."
|
|
9130
9295
|
),
|
|
9131
|
-
task:
|
|
9296
|
+
task: z20.string().max(2e3).optional().describe(
|
|
9132
9297
|
"For 'task': natural-language task description for task-scoped context. For 'start': what you're about to work on. When provided to 'task', orient returns scored, relevant entries for the task."
|
|
9133
9298
|
),
|
|
9134
|
-
scope:
|
|
9299
|
+
scope: z20.string().max(200).optional().describe("For 'task': optional domain scope to filter governance to entries relevant for this domain. Forwarded to Convex for workspace-specific validation."),
|
|
9135
9300
|
// WP-486 Slice 1 (FEAT-1371, TEN-2724): the startup-signal envelope `resolveStartupDomain` already
|
|
9136
9301
|
// consumes (`startupResolver.ts:344-379`) but this tool never sent. Nested to match the server's
|
|
9137
9302
|
// `StartupResolutionSignals` shape exactly — every field optional, sanitized server-side.
|
|
9138
|
-
startupSignals:
|
|
9139
|
-
changedPaths:
|
|
9140
|
-
reviewedArtifactRefs:
|
|
9141
|
-
branchName:
|
|
9142
|
-
worktreeName:
|
|
9303
|
+
startupSignals: z20.object({
|
|
9304
|
+
changedPaths: z20.array(z20.string()).max(25).optional().describe("Paths changed in the current working tree, if known (e.g. from a prior git status/diff tool call)."),
|
|
9305
|
+
reviewedArtifactRefs: z20.array(z20.string()).max(25).optional().describe("Chain entry IDs the caller has already reviewed this session, if tracked."),
|
|
9306
|
+
branchName: z20.string().max(120).optional().describe("Current git branch name, if known."),
|
|
9307
|
+
worktreeName: z20.string().max(120).optional().describe("Current worktree/directory name, if known.")
|
|
9143
9308
|
}).optional().describe("For 'task': best-effort startup signals for domain resolution \u2014 changedPaths/reviewedArtifactRefs/branchName/worktreeName. All optional; omit fields you don't know."),
|
|
9144
|
-
invocationPath:
|
|
9145
|
-
confirmedEntryCount:
|
|
9309
|
+
invocationPath: z20.enum(["session-start", "session-close", "manual-orient", "handshake", "unknown"]).optional().describe("For 'task': how this orient was invoked. Defaults to 'manual-orient' (the direct `orient task=...` call shape) when omitted."),
|
|
9310
|
+
confirmedEntryCount: z20.number().int().min(0).optional().describe(
|
|
9146
9311
|
"For 'record-activation': confirmed-entry count from the Phase 4 capture loop. The mutation enforces >=10."
|
|
9147
9312
|
),
|
|
9148
|
-
entriesAcrossCollections:
|
|
9313
|
+
entriesAcrossCollections: z20.number().int().min(0).optional().describe(
|
|
9149
9314
|
"For 'record-activation': number of distinct collections those entries span. The mutation enforces >=2 (diversity soft-gate)."
|
|
9150
9315
|
),
|
|
9151
|
-
retrievalDemoConfirmed:
|
|
9316
|
+
retrievalDemoConfirmed: z20.boolean().optional().describe(
|
|
9152
9317
|
"For 'record-activation': true if the retrieval round-trip ran successfully in Phase 4. The mutation rejects false."
|
|
9153
9318
|
)
|
|
9154
9319
|
});
|
|
9155
|
-
var orientStartVariant =
|
|
9156
|
-
action:
|
|
9157
|
-
task:
|
|
9320
|
+
var orientStartVariant = z20.object({
|
|
9321
|
+
action: z20.literal("start"),
|
|
9322
|
+
task: z20.string().max(2e3).optional()
|
|
9158
9323
|
});
|
|
9159
|
-
var orientTaskVariant =
|
|
9160
|
-
action:
|
|
9161
|
-
mode:
|
|
9162
|
-
tier:
|
|
9163
|
-
task:
|
|
9164
|
-
scope:
|
|
9324
|
+
var orientTaskVariant = z20.object({
|
|
9325
|
+
action: z20.literal("task"),
|
|
9326
|
+
mode: z20.enum(["full", "brief"]).optional().default("full"),
|
|
9327
|
+
tier: z20.enum(["summary", "standard", "full"]).optional(),
|
|
9328
|
+
task: z20.string().max(2e3).optional(),
|
|
9329
|
+
scope: z20.string().max(200).optional(),
|
|
9165
9330
|
// WP-486 Slice 1 (FEAT-1371) — mirrors orientSchema's top-level declaration above; see its
|
|
9166
9331
|
// doc comment for the shape rationale.
|
|
9167
|
-
startupSignals:
|
|
9168
|
-
changedPaths:
|
|
9169
|
-
reviewedArtifactRefs:
|
|
9170
|
-
branchName:
|
|
9171
|
-
worktreeName:
|
|
9332
|
+
startupSignals: z20.object({
|
|
9333
|
+
changedPaths: z20.array(z20.string()).max(25).optional(),
|
|
9334
|
+
reviewedArtifactRefs: z20.array(z20.string()).max(25).optional(),
|
|
9335
|
+
branchName: z20.string().max(120).optional(),
|
|
9336
|
+
worktreeName: z20.string().max(120).optional()
|
|
9172
9337
|
}).optional(),
|
|
9173
|
-
invocationPath:
|
|
9338
|
+
invocationPath: z20.enum(["session-start", "session-close", "manual-orient", "handshake", "unknown"]).optional()
|
|
9174
9339
|
});
|
|
9175
|
-
var orientRecordActivationVariant =
|
|
9176
|
-
action:
|
|
9177
|
-
confirmedEntryCount:
|
|
9178
|
-
entriesAcrossCollections:
|
|
9179
|
-
retrievalDemoConfirmed:
|
|
9340
|
+
var orientRecordActivationVariant = z20.object({
|
|
9341
|
+
action: z20.literal("record-activation"),
|
|
9342
|
+
confirmedEntryCount: z20.number().int().min(0),
|
|
9343
|
+
entriesAcrossCollections: z20.number().int().min(0),
|
|
9344
|
+
retrievalDemoConfirmed: z20.boolean()
|
|
9180
9345
|
});
|
|
9181
|
-
var orientActionUnion =
|
|
9346
|
+
var orientActionUnion = z20.discriminatedUnion("action", [
|
|
9182
9347
|
orientStartVariant,
|
|
9183
9348
|
orientTaskVariant,
|
|
9184
9349
|
orientRecordActivationVariant
|
|
@@ -10030,7 +10195,7 @@ async function _handleOrient({ mode = "full", tier, task, scope, startupSignals,
|
|
|
10030
10195
|
}
|
|
10031
10196
|
|
|
10032
10197
|
// src/tools/workflows.ts
|
|
10033
|
-
import { z as
|
|
10198
|
+
import { z as z21 } from "zod/v3";
|
|
10034
10199
|
|
|
10035
10200
|
// src/workflows/descriptor.ts
|
|
10036
10201
|
function cloneWorkflowQuestion(question) {
|
|
@@ -10870,75 +11035,75 @@ function workflowRunOutputToText(output) {
|
|
|
10870
11035
|
|
|
10871
11036
|
// src/tools/workflows.ts
|
|
10872
11037
|
var WORKFLOWS_ACTIONS = ["list", "start", "checkpoint", "get-run", "load-skill"];
|
|
10873
|
-
var jsonValueSchema =
|
|
10874
|
-
() =>
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
11038
|
+
var jsonValueSchema = z21.lazy(
|
|
11039
|
+
() => z21.union([
|
|
11040
|
+
z21.string(),
|
|
11041
|
+
z21.number(),
|
|
11042
|
+
z21.boolean(),
|
|
11043
|
+
z21.null(),
|
|
11044
|
+
z21.array(jsonValueSchema),
|
|
11045
|
+
z21.record(jsonValueSchema)
|
|
10881
11046
|
])
|
|
10882
11047
|
);
|
|
10883
|
-
var workflowRunOutputInputSchema =
|
|
10884
|
-
|
|
10885
|
-
format:
|
|
10886
|
-
value:
|
|
11048
|
+
var workflowRunOutputInputSchema = z21.union([
|
|
11049
|
+
z21.object({
|
|
11050
|
+
format: z21.literal("freetext"),
|
|
11051
|
+
value: z21.string()
|
|
10887
11052
|
}),
|
|
10888
|
-
|
|
10889
|
-
format:
|
|
10890
|
-
value:
|
|
11053
|
+
z21.object({
|
|
11054
|
+
format: z21.literal("list"),
|
|
11055
|
+
value: z21.array(z21.string())
|
|
10891
11056
|
}),
|
|
10892
|
-
|
|
10893
|
-
format:
|
|
10894
|
-
value:
|
|
11057
|
+
z21.object({
|
|
11058
|
+
format: z21.literal("choice"),
|
|
11059
|
+
value: z21.union([z21.string(), z21.array(z21.string())])
|
|
10895
11060
|
}),
|
|
10896
|
-
|
|
10897
|
-
format:
|
|
11061
|
+
z21.object({
|
|
11062
|
+
format: z21.literal("structured"),
|
|
10898
11063
|
value: jsonValueSchema
|
|
10899
11064
|
})
|
|
10900
11065
|
]);
|
|
10901
|
-
var workflowsSchema =
|
|
10902
|
-
action:
|
|
11066
|
+
var workflowsSchema = z21.object({
|
|
11067
|
+
action: z21.enum(WORKFLOWS_ACTIONS).describe(
|
|
10903
11068
|
"'list': browse available workflows. 'start': start or resume a workflow \u2014 returns first (or current) round and next-step checkpoint call. 'checkpoint': record round output or final summary. 'get-run': inspect a persisted workflow run. 'load-skill': load the markdown body of a SKILL-* entry from the workspace (absorbs the `skills` tool). Requires entryId."
|
|
10904
11069
|
),
|
|
10905
|
-
workflowId:
|
|
10906
|
-
runId:
|
|
10907
|
-
roundId:
|
|
10908
|
-
output:
|
|
10909
|
-
isFinal:
|
|
10910
|
-
restart:
|
|
10911
|
-
summaryName:
|
|
10912
|
-
summaryDescription:
|
|
10913
|
-
summaryEntryId:
|
|
10914
|
-
entryId:
|
|
11070
|
+
workflowId: z21.string().max(200).optional().describe("Workflow ID for start, checkpoint, or get-run, e.g. 'retro', 'implementation-review'"),
|
|
11071
|
+
runId: z21.string().max(200).optional().describe("Workflow run ID: for get-run, which run to load; for checkpoint, target this run (avoids session drift \u2014 pass runId from get-run)."),
|
|
11072
|
+
roundId: z21.string().max(200).optional().describe("Round ID for checkpoint, e.g. 'what-went-well'"),
|
|
11073
|
+
output: z21.union([z21.string(), workflowRunOutputInputSchema]).optional().describe("The round's output \u2014 either legacy synthesized text or a typed workflow run payload."),
|
|
11074
|
+
isFinal: z21.boolean().optional().describe("If true, finalize an existing durable workflow run from its terminal round and create the summary chain entry."),
|
|
11075
|
+
restart: z21.boolean().optional().describe("If true, start a new durable run from the workflow's first round in the current session."),
|
|
11076
|
+
summaryName: z21.string().max(500).optional().describe("Optional name for final chain entry. If omitted, the workflow summary template is used."),
|
|
11077
|
+
summaryDescription: z21.string().max(2e4).optional().describe("Optional override for the final chain entry description. Defaults to the final round output text."),
|
|
11078
|
+
summaryEntryId: z21.string().max(200).optional().describe("Link an existing entry as the run's summary instead of creating one. Used by facilitated workflows (e.g. shape) where the primary record is created by the specialized tool."),
|
|
11079
|
+
entryId: z21.string().max(200).optional().describe("For 'load-skill': workspace-scoped skill entry id (e.g. 'SKILL-pb-setup'). Refuses non-skill entries (canonicalKey !== 'skill') with INVALID_KIND."),
|
|
10915
11080
|
// WP-513: team+role to create the finalize summary AS OWNER of (rung 2 only).
|
|
10916
|
-
ownerTeamEntryId:
|
|
10917
|
-
ownerRoleEntryId:
|
|
11081
|
+
ownerTeamEntryId: z21.string().max(200).optional().describe("For 'checkpoint' (isFinal): owning team (rung-2)."),
|
|
11082
|
+
ownerRoleEntryId: z21.string().max(200).optional().describe("For 'checkpoint' (isFinal): owning role (rung-2).")
|
|
10918
11083
|
});
|
|
10919
|
-
var workflowsListVariant =
|
|
10920
|
-
var workflowsGetRunVariant =
|
|
10921
|
-
action:
|
|
10922
|
-
runId:
|
|
10923
|
-
workflowId:
|
|
11084
|
+
var workflowsListVariant = z21.object({ action: z21.literal("list") });
|
|
11085
|
+
var workflowsGetRunVariant = z21.object({
|
|
11086
|
+
action: z21.literal("get-run"),
|
|
11087
|
+
runId: z21.string().max(200).optional(),
|
|
11088
|
+
workflowId: z21.string().max(200).optional()
|
|
10924
11089
|
});
|
|
10925
|
-
var workflowsStartVariant =
|
|
10926
|
-
var workflowsCheckpointVariant =
|
|
10927
|
-
action:
|
|
10928
|
-
workflowId:
|
|
10929
|
-
roundId:
|
|
10930
|
-
output:
|
|
10931
|
-
isFinal:
|
|
10932
|
-
restart:
|
|
10933
|
-
summaryName:
|
|
10934
|
-
summaryDescription:
|
|
10935
|
-
summaryEntryId:
|
|
10936
|
-
runId:
|
|
10937
|
-
ownerTeamEntryId:
|
|
10938
|
-
ownerRoleEntryId:
|
|
11090
|
+
var workflowsStartVariant = z21.object({ action: z21.literal("start"), workflowId: z21.string().max(200) });
|
|
11091
|
+
var workflowsCheckpointVariant = z21.object({
|
|
11092
|
+
action: z21.literal("checkpoint"),
|
|
11093
|
+
workflowId: z21.string().max(200),
|
|
11094
|
+
roundId: z21.string().max(200),
|
|
11095
|
+
output: z21.union([z21.string(), workflowRunOutputInputSchema]),
|
|
11096
|
+
isFinal: z21.boolean().optional(),
|
|
11097
|
+
restart: z21.boolean().optional(),
|
|
11098
|
+
summaryName: z21.string().max(500).optional(),
|
|
11099
|
+
summaryDescription: z21.string().max(2e4).optional(),
|
|
11100
|
+
summaryEntryId: z21.string().max(200).optional(),
|
|
11101
|
+
runId: z21.string().max(200).optional(),
|
|
11102
|
+
ownerTeamEntryId: z21.string().max(200).optional(),
|
|
11103
|
+
ownerRoleEntryId: z21.string().max(200).optional()
|
|
10939
11104
|
});
|
|
10940
|
-
var workflowsLoadSkillVariant =
|
|
10941
|
-
var workflowsActionUnion =
|
|
11105
|
+
var workflowsLoadSkillVariant = z21.object({ action: z21.literal("load-skill"), entryId: z21.string().max(200).min(1) });
|
|
11106
|
+
var workflowsActionUnion = z21.discriminatedUnion("action", [
|
|
10942
11107
|
workflowsListVariant,
|
|
10943
11108
|
workflowsGetRunVariant,
|
|
10944
11109
|
workflowsStartVariant,
|
|
@@ -11678,10 +11843,10 @@ function parseListOutput(output) {
|
|
|
11678
11843
|
}
|
|
11679
11844
|
|
|
11680
11845
|
// src/tools/quality.ts
|
|
11681
|
-
import { z as
|
|
11846
|
+
import { z as z23 } from "zod/v3";
|
|
11682
11847
|
|
|
11683
11848
|
// src/tools/audit.ts
|
|
11684
|
-
import { z as
|
|
11849
|
+
import { z as z22 } from "zod/v3";
|
|
11685
11850
|
var VOCAB_TTL_MS = 5 * 60 * 1e3;
|
|
11686
11851
|
var MAX_VOCAB_KEYS = 100;
|
|
11687
11852
|
var vocabCache = /* @__PURE__ */ new Map();
|
|
@@ -11711,12 +11876,12 @@ function evictVocabIfFull() {
|
|
|
11711
11876
|
}
|
|
11712
11877
|
}
|
|
11713
11878
|
var AUDIT_ACTIONS = ["run"];
|
|
11714
|
-
var auditSchema =
|
|
11715
|
-
action:
|
|
11879
|
+
var auditSchema = z22.object({
|
|
11880
|
+
action: z22.enum(AUDIT_ACTIONS).describe(
|
|
11716
11881
|
"'run': run the hygiene audit for a bet entry."
|
|
11717
11882
|
),
|
|
11718
|
-
entryId:
|
|
11719
|
-
phase:
|
|
11883
|
+
entryId: z22.string().describe("Bet entry ID to audit, e.g. '<PREFIX>-<n>'"),
|
|
11884
|
+
phase: z22.enum(["shaping", "handoff"]).default("shaping").optional().describe(
|
|
11720
11885
|
"'shaping': check shaping-phase fields only. 'handoff': check all required fields including buildContract/buildSequence/exclusions/risks. Default: shaping."
|
|
11721
11886
|
)
|
|
11722
11887
|
});
|
|
@@ -11909,44 +12074,44 @@ async function handleSpineCheck(story, refresh = false) {
|
|
|
11909
12074
|
|
|
11910
12075
|
// src/tools/quality.ts
|
|
11911
12076
|
var QUALITY_ACTIONS = ["check", "re-evaluate", "verify-chain", "audit", "spine-check"];
|
|
11912
|
-
var qualitySchema =
|
|
11913
|
-
action:
|
|
12077
|
+
var qualitySchema = z23.object({
|
|
12078
|
+
action: z23.enum(QUALITY_ACTIONS).describe(
|
|
11914
12079
|
"'check': read the entry's server quality verdict (tier + criteria). 're-evaluate': trigger fresh evaluation. 'verify-chain': verify entries against the codebase (codeMapping drift, cross-references) \u2014 absorbs `verify`. 'audit': hygiene audit for a bet entry \u2014 absorbs `audit`. 'spine-check': structural completeness of the purpose+vision+strategy spine \u2014 story:true also runs the on-demand one-story judgment."
|
|
11915
12080
|
),
|
|
11916
|
-
entryId:
|
|
11917
|
-
context:
|
|
11918
|
-
collection:
|
|
11919
|
-
mode:
|
|
11920
|
-
phase:
|
|
12081
|
+
entryId: z23.string().max(200).optional().describe("For 'check'/'re-evaluate'/'audit': entry ID, e.g. 'TEN-graph-db', '<PREFIX>-<n>'."),
|
|
12082
|
+
context: z23.enum(["capture", "commit", "review"]).default("review").optional().describe("For re-evaluate: evaluation context"),
|
|
12083
|
+
collection: z23.string().max(200).optional().describe("For 'verify-chain': collection slug to verify (default: glossary)."),
|
|
12084
|
+
mode: z23.enum(["report", "fix"]).optional().describe("For 'verify-chain': 'report' = read-only trust report (default). 'fix' = also update drifted codeMapping statuses."),
|
|
12085
|
+
phase: z23.enum(["shaping", "handoff"]).optional().describe(
|
|
11921
12086
|
"For 'audit': 'shaping' checks shaping-phase fields only (default). 'handoff' checks all required fields including buildContract/buildSequence/exclusions/risks."
|
|
11922
12087
|
),
|
|
11923
|
-
story:
|
|
11924
|
-
refresh:
|
|
12088
|
+
story: z23.boolean().optional().describe("For 'spine-check': also run the on-demand one-story LLM judgment (never scheduled; result labelled [unvalidated])."),
|
|
12089
|
+
refresh: z23.boolean().optional().describe(
|
|
11925
12090
|
"For 'spine-check': force a new run even if a fresh verdict already exists. Default false \u2014 a plain call NEVER re-triggers work just to read the last result; it auto-schedules only when no run is already in flight AND the stored verdict is absent/stale/missing the requested story pass."
|
|
11926
12091
|
)
|
|
11927
12092
|
});
|
|
11928
|
-
var qualityCheckVariant =
|
|
11929
|
-
var qualityReEvaluateVariant =
|
|
11930
|
-
action:
|
|
11931
|
-
entryId:
|
|
11932
|
-
context:
|
|
12093
|
+
var qualityCheckVariant = z23.object({ action: z23.literal("check"), entryId: z23.string().max(200) });
|
|
12094
|
+
var qualityReEvaluateVariant = z23.object({
|
|
12095
|
+
action: z23.literal("re-evaluate"),
|
|
12096
|
+
entryId: z23.string().max(200),
|
|
12097
|
+
context: z23.enum(["capture", "commit", "review"]).optional().default("review")
|
|
11933
12098
|
});
|
|
11934
|
-
var qualityVerifyChainVariant =
|
|
11935
|
-
action:
|
|
11936
|
-
collection:
|
|
11937
|
-
mode:
|
|
12099
|
+
var qualityVerifyChainVariant = z23.object({
|
|
12100
|
+
action: z23.literal("verify-chain"),
|
|
12101
|
+
collection: z23.string().max(200).optional().default("glossary"),
|
|
12102
|
+
mode: z23.enum(["report", "fix"]).optional().default("report")
|
|
11938
12103
|
});
|
|
11939
|
-
var qualityAuditVariant =
|
|
11940
|
-
action:
|
|
11941
|
-
entryId:
|
|
11942
|
-
phase:
|
|
12104
|
+
var qualityAuditVariant = z23.object({
|
|
12105
|
+
action: z23.literal("audit"),
|
|
12106
|
+
entryId: z23.string().max(200),
|
|
12107
|
+
phase: z23.enum(["shaping", "handoff"]).optional().default("shaping")
|
|
11943
12108
|
});
|
|
11944
|
-
var qualitySpineCheckVariant =
|
|
11945
|
-
action:
|
|
11946
|
-
story:
|
|
11947
|
-
refresh:
|
|
12109
|
+
var qualitySpineCheckVariant = z23.object({
|
|
12110
|
+
action: z23.literal("spine-check"),
|
|
12111
|
+
story: z23.boolean().optional().default(false),
|
|
12112
|
+
refresh: z23.boolean().optional().default(false)
|
|
11948
12113
|
});
|
|
11949
|
-
var qualityActionUnion =
|
|
12114
|
+
var qualityActionUnion = z23.discriminatedUnion("action", [
|
|
11950
12115
|
qualityCheckVariant,
|
|
11951
12116
|
qualityReEvaluateVariant,
|
|
11952
12117
|
qualityVerifyChainVariant,
|
|
@@ -11960,34 +12125,34 @@ var QUALITY_ACTION_SPECS = {
|
|
|
11960
12125
|
audit: { params: ["entryId", "phase"], description: "entryId is required." },
|
|
11961
12126
|
"spine-check": { params: ["story", "refresh"], description: "All params optional; story and refresh default to false \u2014 a plain call never re-triggers work, it just reads back the latest verdict (auto-refreshing only when stale/absent)." }
|
|
11962
12127
|
};
|
|
11963
|
-
var qualityCheckOutputSchema =
|
|
11964
|
-
entryId:
|
|
12128
|
+
var qualityCheckOutputSchema = z23.object({
|
|
12129
|
+
entryId: z23.string(),
|
|
11965
12130
|
/** WP-480 S1: false = the ID does not resolve to an entry (typo/deleted) — distinct from "no verdict yet". */
|
|
11966
|
-
entryFound:
|
|
11967
|
-
hasVerdict:
|
|
12131
|
+
entryFound: z23.boolean().optional(),
|
|
12132
|
+
hasVerdict: z23.boolean(),
|
|
11968
12133
|
/** WP-480 S1: the verdict was judged against content the entry no longer has — re-evaluate for a current one. */
|
|
11969
|
-
stale:
|
|
11970
|
-
tier:
|
|
11971
|
-
passed:
|
|
11972
|
-
criteria:
|
|
11973
|
-
id:
|
|
11974
|
-
passed:
|
|
11975
|
-
hint:
|
|
12134
|
+
stale: z23.boolean().optional(),
|
|
12135
|
+
tier: z23.string().optional(),
|
|
12136
|
+
passed: z23.boolean().optional(),
|
|
12137
|
+
criteria: z23.array(z23.object({
|
|
12138
|
+
id: z23.string(),
|
|
12139
|
+
passed: z23.boolean(),
|
|
12140
|
+
hint: z23.string().optional()
|
|
11976
12141
|
}))
|
|
11977
12142
|
});
|
|
11978
|
-
var qualityReevaluateOutputSchema =
|
|
11979
|
-
entryId:
|
|
11980
|
-
context:
|
|
11981
|
-
score:
|
|
11982
|
-
maxScore:
|
|
11983
|
-
improved:
|
|
12143
|
+
var qualityReevaluateOutputSchema = z23.object({
|
|
12144
|
+
entryId: z23.string(),
|
|
12145
|
+
context: z23.string(),
|
|
12146
|
+
score: z23.number(),
|
|
12147
|
+
maxScore: z23.number(),
|
|
12148
|
+
improved: z23.boolean()
|
|
11984
12149
|
});
|
|
11985
|
-
var qualitySpineCheckOutputSchema =
|
|
11986
|
-
hasVerdict:
|
|
11987
|
-
noSpineEntries:
|
|
11988
|
-
structuralPassed:
|
|
11989
|
-
storyPassed:
|
|
11990
|
-
stale:
|
|
12150
|
+
var qualitySpineCheckOutputSchema = z23.object({
|
|
12151
|
+
hasVerdict: z23.boolean(),
|
|
12152
|
+
noSpineEntries: z23.boolean().optional(),
|
|
12153
|
+
structuralPassed: z23.boolean().optional(),
|
|
12154
|
+
storyPassed: z23.boolean().nullable().optional(),
|
|
12155
|
+
stale: z23.boolean().optional()
|
|
11991
12156
|
});
|
|
11992
12157
|
function registerQualityTools(server) {
|
|
11993
12158
|
const qualityHandlers = {
|
|
@@ -12169,10 +12334,10 @@ async function handleReEvaluate(entryId, context) {
|
|
|
12169
12334
|
}
|
|
12170
12335
|
|
|
12171
12336
|
// src/tools/session.ts
|
|
12172
|
-
import { z as
|
|
12337
|
+
import { z as z26 } from "zod/v3";
|
|
12173
12338
|
|
|
12174
12339
|
// src/tools/wrapup.ts
|
|
12175
|
-
import { z as
|
|
12340
|
+
import { z as z24 } from "zod/v3";
|
|
12176
12341
|
|
|
12177
12342
|
// src/lib/compose-wrapup-view.ts
|
|
12178
12343
|
function toComposed(e) {
|
|
@@ -12625,8 +12790,8 @@ async function runWrapupCommitAll(data, cachedSuggestions) {
|
|
|
12625
12790
|
overflowUnscanned
|
|
12626
12791
|
};
|
|
12627
12792
|
}
|
|
12628
|
-
var wrapupSchema =
|
|
12629
|
-
action:
|
|
12793
|
+
var wrapupSchema = z24.object({
|
|
12794
|
+
action: z24.enum(["review", "commit-all"]).optional().describe(
|
|
12630
12795
|
"Action to perform. 'review' (default) shows the wrapup summary. 'commit-all' accepts all uncommitted drafts and creates suggested links."
|
|
12631
12796
|
)
|
|
12632
12797
|
});
|
|
@@ -12727,26 +12892,26 @@ ${text}` : text;
|
|
|
12727
12892
|
}
|
|
12728
12893
|
|
|
12729
12894
|
// src/tools/facilitate.ts
|
|
12730
|
-
import { z as
|
|
12895
|
+
import { z as z25 } from "zod/v3";
|
|
12731
12896
|
var FACILITATE_ACTIONS = ["resume", "commit-constellation"];
|
|
12732
|
-
var coherencyAcknowledgementSchema =
|
|
12733
|
-
response:
|
|
12734
|
-
entryId:
|
|
12735
|
-
reason:
|
|
12736
|
-
subjectEntryId:
|
|
12897
|
+
var coherencyAcknowledgementSchema = z25.object({
|
|
12898
|
+
response: z25.string().max(200).describe("Acknowledgement response per offender: 'linked' | 'accepted-fix' | 'diverged'."),
|
|
12899
|
+
entryId: z25.string().max(200).optional().describe("Entry the acknowledgement links to (e.g. the strategic spine entry)."),
|
|
12900
|
+
reason: z25.string().max(2e3).optional().describe("Free-text justification, required for a 'diverged' response."),
|
|
12901
|
+
subjectEntryId: z25.string().max(200).optional().describe("The refused entry this acknowledgement answers.")
|
|
12737
12902
|
});
|
|
12738
|
-
var facilitateSchema =
|
|
12739
|
-
action:
|
|
12903
|
+
var facilitateSchema = z25.object({
|
|
12904
|
+
action: z25.enum(FACILITATE_ACTIONS).describe(
|
|
12740
12905
|
"'resume': load session state from an existing bet entry. 'commit-constellation': atomically accept a bet and all its linked draft entries in one call. Requires betEntryId."
|
|
12741
12906
|
),
|
|
12742
|
-
betEntryId:
|
|
12743
|
-
operationId:
|
|
12907
|
+
betEntryId: z25.string().max(200).optional().describe("Bet entry ID. Required for both actions."),
|
|
12908
|
+
operationId: z25.string().max(200).optional().describe("Optional idempotency key for commit-constellation retries."),
|
|
12744
12909
|
// WP-465 slice ⑤: coherency retry controls for a COHERENCY_REFUSED constellation hold.
|
|
12745
12910
|
// Forwarded verbatim to agentKnowledge.facilitateEnvelope (validation lives at the gate).
|
|
12746
|
-
coherencyAcknowledgements:
|
|
12911
|
+
coherencyAcknowledgements: z25.array(coherencyAcknowledgementSchema).max(20).optional().describe(
|
|
12747
12912
|
"Per-offender acknowledgements to retry a constellation held under standard/strict coherency mode. Each: {subjectEntryId, response: 'linked' | 'accepted-fix' | 'diverged', entryId?, reason?}."
|
|
12748
12913
|
),
|
|
12749
|
-
steeringOverrideReason:
|
|
12914
|
+
steeringOverrideReason: z25.string().max(2e3).optional().describe(
|
|
12750
12915
|
"Typed override reason (>= 12 chars) to push a constellation past a coherency hold instead of acknowledging."
|
|
12751
12916
|
)
|
|
12752
12917
|
});
|
|
@@ -13017,33 +13182,33 @@ var SESSION_ACTIONS = [
|
|
|
13017
13182
|
"resume",
|
|
13018
13183
|
"commit-constellation"
|
|
13019
13184
|
];
|
|
13020
|
-
var coherencyAcknowledgementFlatSchema2 =
|
|
13021
|
-
response:
|
|
13022
|
-
entryId:
|
|
13023
|
-
reason:
|
|
13024
|
-
subjectEntryId:
|
|
13185
|
+
var coherencyAcknowledgementFlatSchema2 = z26.object({
|
|
13186
|
+
response: z26.string().max(200).describe("Acknowledgement response per offender: 'linked' | 'accepted-fix' | 'diverged'."),
|
|
13187
|
+
entryId: z26.string().max(200).optional().describe("Entry the acknowledgement links to."),
|
|
13188
|
+
reason: z26.string().max(2e3).optional().describe("Free-text justification, required for a 'diverged' response."),
|
|
13189
|
+
subjectEntryId: z26.string().max(200).optional().describe("The refused entry this acknowledgement answers.")
|
|
13025
13190
|
});
|
|
13026
|
-
var sessionSchema =
|
|
13027
|
-
action:
|
|
13191
|
+
var sessionSchema = z26.object({
|
|
13192
|
+
action: z26.enum(SESSION_ACTIONS).describe(
|
|
13028
13193
|
"'start': begin a tracked session. 'close': end the session and record activity. 'status': check current session state. 'wrapup-review': review uncommitted drafts before closing (absorbs session-wrapup action=review). 'wrapup-commit': accept all uncommitted drafts (absorbs session-wrapup action=commit-all). 'resume': load session state from an existing bet entry (absorbs facilitate action=resume). 'commit-constellation': atomically accept a bet and its linked drafts (absorbs facilitate action=commit-constellation)."
|
|
13029
13194
|
),
|
|
13030
|
-
betEntryId:
|
|
13031
|
-
operationId:
|
|
13032
|
-
coherencyAcknowledgements:
|
|
13195
|
+
betEntryId: z26.string().max(200).optional().describe("For 'resume'/'commit-constellation': bet entry ID. Required for both."),
|
|
13196
|
+
operationId: z26.string().max(200).optional().describe("For 'commit-constellation': optional idempotency key for retries."),
|
|
13197
|
+
coherencyAcknowledgements: z26.array(coherencyAcknowledgementFlatSchema2).max(20).optional().describe(
|
|
13033
13198
|
"For 'commit-constellation': per-offender acknowledgements to retry a constellation held under standard/strict coherency mode."
|
|
13034
13199
|
),
|
|
13035
|
-
steeringOverrideReason:
|
|
13200
|
+
steeringOverrideReason: z26.string().max(2e3).optional().describe(
|
|
13036
13201
|
"For 'commit-constellation': typed override reason (>= 12 chars) to push past a coherency hold instead of acknowledging."
|
|
13037
13202
|
)
|
|
13038
13203
|
});
|
|
13039
|
-
var sessionStartVariant =
|
|
13040
|
-
var sessionCloseVariant =
|
|
13041
|
-
var sessionStatusVariant =
|
|
13042
|
-
var sessionWrapupReviewVariant =
|
|
13043
|
-
var sessionWrapupCommitVariant =
|
|
13044
|
-
var sessionResumeVariant = facilitateSchema.omit({ action: true }).extend({ action:
|
|
13045
|
-
var sessionCommitConstellationVariant = facilitateSchema.omit({ action: true }).extend({ action:
|
|
13046
|
-
var sessionActionUnion =
|
|
13204
|
+
var sessionStartVariant = z26.object({ action: z26.literal("start") });
|
|
13205
|
+
var sessionCloseVariant = z26.object({ action: z26.literal("close") });
|
|
13206
|
+
var sessionStatusVariant = z26.object({ action: z26.literal("status") });
|
|
13207
|
+
var sessionWrapupReviewVariant = z26.object({ action: z26.literal("wrapup-review") });
|
|
13208
|
+
var sessionWrapupCommitVariant = z26.object({ action: z26.literal("wrapup-commit") });
|
|
13209
|
+
var sessionResumeVariant = facilitateSchema.omit({ action: true }).extend({ action: z26.literal("resume") });
|
|
13210
|
+
var sessionCommitConstellationVariant = facilitateSchema.omit({ action: true }).extend({ action: z26.literal("commit-constellation") });
|
|
13211
|
+
var sessionActionUnion = z26.discriminatedUnion("action", [
|
|
13047
13212
|
sessionStartVariant,
|
|
13048
13213
|
sessionCloseVariant,
|
|
13049
13214
|
sessionStatusVariant,
|
|
@@ -13288,7 +13453,7 @@ async function handleStatus() {
|
|
|
13288
13453
|
}
|
|
13289
13454
|
|
|
13290
13455
|
// src/tools/gitchain.ts
|
|
13291
|
-
import { z as
|
|
13456
|
+
import { z as z27 } from "zod/v3";
|
|
13292
13457
|
|
|
13293
13458
|
// src/lib/versionDisplay.ts
|
|
13294
13459
|
function toVersionDisplay(version) {
|
|
@@ -13297,51 +13462,51 @@ function toVersionDisplay(version) {
|
|
|
13297
13462
|
}
|
|
13298
13463
|
|
|
13299
13464
|
// src/tools/gitchain.ts
|
|
13300
|
-
var chainSchema =
|
|
13301
|
-
action:
|
|
13302
|
-
chainEntryId:
|
|
13303
|
-
title:
|
|
13304
|
-
chainTypeId:
|
|
13305
|
-
description:
|
|
13306
|
-
linkId:
|
|
13307
|
-
content:
|
|
13308
|
-
status:
|
|
13309
|
-
author:
|
|
13465
|
+
var chainSchema = z27.object({
|
|
13466
|
+
action: z27.enum(["create", "get", "list", "edit"]).describe("Action: create a process, get process details, list all processes, or edit a process link"),
|
|
13467
|
+
chainEntryId: z27.string().max(200).optional().describe("Chain entry ID (required for get/edit)"),
|
|
13468
|
+
title: z27.string().max(500).optional().describe("Process title (required for create)"),
|
|
13469
|
+
chainTypeId: z27.string().max(200).optional().default("strategy-coherence").describe("Process template slug for create: 'strategy-coherence', 'idm-proposal', or any custom template slug"),
|
|
13470
|
+
description: z27.string().max(2e4).optional().describe("Description (for create)"),
|
|
13471
|
+
linkId: z27.string().max(200).optional().describe("Link to edit (for edit action): problem, insight, choice, action, outcome"),
|
|
13472
|
+
content: z27.string().max(5e4).optional().describe("New content for the link (for edit action)"),
|
|
13473
|
+
status: z27.string().max(200).optional().describe("Filter by status for list: 'draft' or 'active'"),
|
|
13474
|
+
author: z27.string().max(200).optional().describe("Who is performing the action. Defaults to 'mcp'."),
|
|
13310
13475
|
// WP-513 review round 3 (P1): team+role to create AS OWNER of (rung 2 only) — entry ID or entryId (e.g. "TEAM-1").
|
|
13311
|
-
ownerTeamEntryId:
|
|
13312
|
-
ownerRoleEntryId:
|
|
13476
|
+
ownerTeamEntryId: z27.string().max(200).optional().describe("For 'create': owning team (rung-2 workspaces)."),
|
|
13477
|
+
ownerRoleEntryId: z27.string().max(200).optional().describe("For 'create': owning role (rung-2 workspaces).")
|
|
13313
13478
|
});
|
|
13314
|
-
var chainVersionSchema =
|
|
13315
|
-
action:
|
|
13316
|
-
chainEntryId:
|
|
13317
|
-
commitMessage:
|
|
13318
|
-
versionA:
|
|
13319
|
-
versionB:
|
|
13320
|
-
toVersion:
|
|
13321
|
-
author:
|
|
13479
|
+
var chainVersionSchema = z27.object({
|
|
13480
|
+
action: z27.enum(["commit", "list", "diff", "revert", "history"]).describe("Action: commit a snapshot, list commits, diff two versions, revert to a version, or view history"),
|
|
13481
|
+
chainEntryId: z27.string().max(200).describe("The chain's entry ID"),
|
|
13482
|
+
commitMessage: z27.string().max(2e3).optional().describe("Commit message (required for commit). Convention: type(link): description"),
|
|
13483
|
+
versionA: z27.number().optional().describe("Earlier version for diff"),
|
|
13484
|
+
versionB: z27.number().optional().describe("Later version for diff"),
|
|
13485
|
+
toVersion: z27.number().optional().describe("Version number to revert to"),
|
|
13486
|
+
author: z27.string().max(200).optional().describe("Who is performing the action. Defaults to 'mcp'.")
|
|
13322
13487
|
});
|
|
13323
|
-
var chainBranchSchema =
|
|
13324
|
-
action:
|
|
13325
|
-
chainEntryId:
|
|
13326
|
-
branchName:
|
|
13327
|
-
strategy:
|
|
13328
|
-
author:
|
|
13488
|
+
var chainBranchSchema = z27.object({
|
|
13489
|
+
action: z27.enum(["create", "list", "merge", "conflicts"]).describe("Action: create a branch, list branches, merge a branch, or check for conflicts"),
|
|
13490
|
+
chainEntryId: z27.string().max(200).describe("The chain's entry ID"),
|
|
13491
|
+
branchName: z27.string().max(200).optional().describe("Branch name (required for merge/conflicts, optional for create)"),
|
|
13492
|
+
strategy: z27.enum(["merge_commit", "squash"]).optional().describe("Merge strategy: 'merge_commit' (default) or 'squash'"),
|
|
13493
|
+
author: z27.string().max(200).optional().describe("Who is performing the action. Defaults to 'mcp'.")
|
|
13329
13494
|
});
|
|
13330
|
-
var chainReviewSchema =
|
|
13331
|
-
action:
|
|
13495
|
+
var chainReviewSchema = z27.object({
|
|
13496
|
+
action: z27.enum(["gate", "comment", "resolve-comment", "list-comments"]).describe("Action: run coherence gate, add a comment, resolve a comment, or list comments"),
|
|
13332
13497
|
// Finding #12: optional at the base (mirrors chainSchema's chainEntryId pattern at
|
|
13333
13498
|
// line ~690) — resolve-comment resolves purely by commentId (handleChainReview never
|
|
13334
13499
|
// reads chainEntryId in that branch) and the compound-tool's advertised schema
|
|
13335
13500
|
// (chainReviewCompoundSchema below) already documents it as optional for that action.
|
|
13336
13501
|
// Per-action variants that DO need it (gate/comment/list-comments) re-require it below,
|
|
13337
13502
|
// same pattern as chainGetVariant/chainEditVariant re-requiring over chainSchema's base.
|
|
13338
|
-
chainEntryId:
|
|
13339
|
-
commitMessage:
|
|
13340
|
-
versionNumber:
|
|
13341
|
-
linkId:
|
|
13342
|
-
body:
|
|
13343
|
-
commentId:
|
|
13344
|
-
author:
|
|
13503
|
+
chainEntryId: z27.string().max(200).optional().describe("The chain's entry ID. Required for every action except 'resolve-comment'."),
|
|
13504
|
+
commitMessage: z27.string().max(2e3).optional().describe("Commit message to lint (for gate action)"),
|
|
13505
|
+
versionNumber: z27.number().optional().describe("Version to comment on or list comments for"),
|
|
13506
|
+
linkId: z27.string().max(200).optional().describe("Link this comment targets (optional for comment)"),
|
|
13507
|
+
body: z27.string().max(2e4).optional().describe("Comment text (required for comment action)"),
|
|
13508
|
+
commentId: z27.string().max(200).optional().describe("Comment ID (required for resolve-comment)"),
|
|
13509
|
+
author: z27.string().max(200).optional().describe("Who is performing the action. Defaults to 'mcp'.")
|
|
13345
13510
|
});
|
|
13346
13511
|
function linkSummary(links) {
|
|
13347
13512
|
return Object.entries(links).map(([id, content]) => {
|
|
@@ -13846,57 +14011,57 @@ var CHAIN_REVIEW_ACTIONS = [
|
|
|
13846
14011
|
"branch.merge",
|
|
13847
14012
|
"branch.conflicts"
|
|
13848
14013
|
];
|
|
13849
|
-
var chainCompoundSchema =
|
|
13850
|
-
action:
|
|
14014
|
+
var chainCompoundSchema = z27.object({
|
|
14015
|
+
action: z27.enum(CHAIN_ACTIONS).describe(
|
|
13851
14016
|
"Unnamespaced: 'create'/'get'/'list'/'edit' \u2014 process CRUD (the original `chain` tool). 'version.*' (commit/list/diff/revert/history) \u2014 versioning, absorbs `chain-version`. Branching and review live on the sibling `chain-review` tool."
|
|
13852
14017
|
),
|
|
13853
|
-
chainEntryId:
|
|
13854
|
-
title:
|
|
13855
|
-
chainTypeId:
|
|
13856
|
-
description:
|
|
13857
|
-
linkId:
|
|
13858
|
-
content:
|
|
13859
|
-
status:
|
|
13860
|
-
author:
|
|
13861
|
-
commitMessage:
|
|
13862
|
-
versionA:
|
|
13863
|
-
versionB:
|
|
13864
|
-
toVersion:
|
|
14018
|
+
chainEntryId: z27.string().max(200).optional().describe("Chain entry ID. Required for get/edit and all version.* actions."),
|
|
14019
|
+
title: z27.string().max(500).optional().describe("For 'create': process title (required)."),
|
|
14020
|
+
chainTypeId: z27.string().max(200).optional().default("strategy-coherence").describe("For 'create'/'list': process template slug."),
|
|
14021
|
+
description: z27.string().max(2e4).optional().describe("For 'create': description."),
|
|
14022
|
+
linkId: z27.string().max(200).optional().describe("For 'edit': link to edit (required)."),
|
|
14023
|
+
content: z27.string().max(5e4).optional().describe("For 'edit': new content for the link (required)."),
|
|
14024
|
+
status: z27.string().max(200).optional().describe("For 'list': filter by status."),
|
|
14025
|
+
author: z27.string().max(200).optional().describe("Who is performing the action. Defaults to 'mcp'."),
|
|
14026
|
+
commitMessage: z27.string().max(2e3).optional().describe("For 'version.commit': commit message (required)."),
|
|
14027
|
+
versionA: z27.number().optional().describe("For 'version.diff': earlier version (required)."),
|
|
14028
|
+
versionB: z27.number().optional().describe("For 'version.diff': later version (required)."),
|
|
14029
|
+
toVersion: z27.number().optional().describe("For 'version.revert': version number to revert to (required)."),
|
|
13865
14030
|
// WP-513 review round 3 (P1): team+role to create AS OWNER of (rung 2 only).
|
|
13866
|
-
ownerTeamEntryId:
|
|
13867
|
-
ownerRoleEntryId:
|
|
14031
|
+
ownerTeamEntryId: z27.string().max(200).optional().describe("For 'create': owning team (rung-2 workspaces)."),
|
|
14032
|
+
ownerRoleEntryId: z27.string().max(200).optional().describe("For 'create': owning role (rung-2 workspaces).")
|
|
13868
14033
|
});
|
|
13869
|
-
var chainReviewCompoundSchema =
|
|
13870
|
-
action:
|
|
14034
|
+
var chainReviewCompoundSchema = z27.object({
|
|
14035
|
+
action: z27.enum(CHAIN_REVIEW_ACTIONS).describe(
|
|
13871
14036
|
"'gate'/'comment'/'resolve-comment'/'list-comments' \u2014 quality gate + comments (the original `chain-review` tool, unchanged call shape). 'branch.*' (create/list/merge/conflicts) \u2014 branching, absorbs `chain-branch`. Process CRUD and versioning live on the sibling `chain` tool."
|
|
13872
14037
|
),
|
|
13873
|
-
chainEntryId:
|
|
13874
|
-
commitMessage:
|
|
13875
|
-
versionNumber:
|
|
13876
|
-
linkId:
|
|
13877
|
-
body:
|
|
13878
|
-
commentId:
|
|
13879
|
-
branchName:
|
|
13880
|
-
strategy:
|
|
13881
|
-
author:
|
|
14038
|
+
chainEntryId: z27.string().max(200).optional().describe("Chain entry ID. Required for every action except 'resolve-comment'."),
|
|
14039
|
+
commitMessage: z27.string().max(2e3).optional().describe("For 'gate': commit message to lint."),
|
|
14040
|
+
versionNumber: z27.number().optional().describe("For 'comment'/'list-comments': version to comment on or list comments for."),
|
|
14041
|
+
linkId: z27.string().max(200).optional().describe("For 'comment': optional link this comment targets."),
|
|
14042
|
+
body: z27.string().max(2e4).optional().describe("For 'comment': comment text (required)."),
|
|
14043
|
+
commentId: z27.string().max(200).optional().describe("For 'resolve-comment': comment ID (required)."),
|
|
14044
|
+
branchName: z27.string().max(200).optional().describe("For 'branch.merge'/'branch.conflicts': required. For 'branch.create': optional."),
|
|
14045
|
+
strategy: z27.enum(["merge_commit", "squash"]).optional().describe("For 'branch.merge': merge strategy. Default 'merge_commit'."),
|
|
14046
|
+
author: z27.string().max(200).optional().describe("Who is performing the action. Defaults to 'mcp'.")
|
|
13882
14047
|
});
|
|
13883
|
-
var chainCreateVariant = chainSchema.omit({ action: true }).extend({ action:
|
|
13884
|
-
var chainGetVariant =
|
|
13885
|
-
var chainListVariant =
|
|
13886
|
-
var chainEditVariant =
|
|
13887
|
-
action:
|
|
13888
|
-
chainEntryId:
|
|
13889
|
-
linkId:
|
|
13890
|
-
content:
|
|
13891
|
-
author:
|
|
14048
|
+
var chainCreateVariant = chainSchema.omit({ action: true }).extend({ action: z27.literal("create") });
|
|
14049
|
+
var chainGetVariant = z27.object({ action: z27.literal("get"), chainEntryId: z27.string().max(200) });
|
|
14050
|
+
var chainListVariant = z27.object({ action: z27.literal("list"), chainTypeId: z27.string().max(200).optional(), status: z27.string().max(200).optional() });
|
|
14051
|
+
var chainEditVariant = z27.object({
|
|
14052
|
+
action: z27.literal("edit"),
|
|
14053
|
+
chainEntryId: z27.string().max(200),
|
|
14054
|
+
linkId: z27.string().max(200),
|
|
14055
|
+
content: z27.string().max(5e4),
|
|
14056
|
+
author: z27.string().max(200).optional()
|
|
13892
14057
|
});
|
|
13893
14058
|
var versionBase = chainVersionSchema.omit({ action: true });
|
|
13894
|
-
var chainVersionCommitVariant = versionBase.extend({ action:
|
|
13895
|
-
var chainVersionListVariant = versionBase.extend({ action:
|
|
13896
|
-
var chainVersionDiffVariant = versionBase.extend({ action:
|
|
13897
|
-
var chainVersionRevertVariant = versionBase.extend({ action:
|
|
13898
|
-
var chainVersionHistoryVariant = versionBase.extend({ action:
|
|
13899
|
-
var chainActionUnion =
|
|
14059
|
+
var chainVersionCommitVariant = versionBase.extend({ action: z27.literal("version.commit"), commitMessage: z27.string().max(2e3) });
|
|
14060
|
+
var chainVersionListVariant = versionBase.extend({ action: z27.literal("version.list") });
|
|
14061
|
+
var chainVersionDiffVariant = versionBase.extend({ action: z27.literal("version.diff"), versionA: z27.number(), versionB: z27.number() });
|
|
14062
|
+
var chainVersionRevertVariant = versionBase.extend({ action: z27.literal("version.revert"), toVersion: z27.number() });
|
|
14063
|
+
var chainVersionHistoryVariant = versionBase.extend({ action: z27.literal("version.history") });
|
|
14064
|
+
var chainActionUnion = z27.discriminatedUnion("action", [
|
|
13900
14065
|
chainCreateVariant,
|
|
13901
14066
|
chainGetVariant,
|
|
13902
14067
|
chainListVariant,
|
|
@@ -13908,16 +14073,16 @@ var chainActionUnion = z26.discriminatedUnion("action", [
|
|
|
13908
14073
|
chainVersionHistoryVariant
|
|
13909
14074
|
]);
|
|
13910
14075
|
var reviewBase = chainReviewSchema.omit({ action: true });
|
|
13911
|
-
var chainReviewGateVariant = reviewBase.extend({ action:
|
|
13912
|
-
var chainReviewCommentVariant = reviewBase.extend({ action:
|
|
13913
|
-
var chainReviewResolveCommentVariant = reviewBase.extend({ action:
|
|
13914
|
-
var chainReviewListCommentsVariant = reviewBase.extend({ action:
|
|
14076
|
+
var chainReviewGateVariant = reviewBase.extend({ action: z27.literal("gate"), chainEntryId: z27.string().max(200) });
|
|
14077
|
+
var chainReviewCommentVariant = reviewBase.extend({ action: z27.literal("comment"), chainEntryId: z27.string().max(200), versionNumber: z27.number(), body: z27.string().max(2e4) });
|
|
14078
|
+
var chainReviewResolveCommentVariant = reviewBase.extend({ action: z27.literal("resolve-comment"), commentId: z27.string().max(200) });
|
|
14079
|
+
var chainReviewListCommentsVariant = reviewBase.extend({ action: z27.literal("list-comments"), chainEntryId: z27.string().max(200) });
|
|
13915
14080
|
var branchBase = chainBranchSchema.omit({ action: true });
|
|
13916
|
-
var chainBranchCreateVariant = branchBase.extend({ action:
|
|
13917
|
-
var chainBranchListVariant = branchBase.extend({ action:
|
|
13918
|
-
var chainBranchMergeVariant = branchBase.extend({ action:
|
|
13919
|
-
var chainBranchConflictsVariant = branchBase.extend({ action:
|
|
13920
|
-
var chainReviewActionUnion =
|
|
14081
|
+
var chainBranchCreateVariant = branchBase.extend({ action: z27.literal("branch.create") });
|
|
14082
|
+
var chainBranchListVariant = branchBase.extend({ action: z27.literal("branch.list") });
|
|
14083
|
+
var chainBranchMergeVariant = branchBase.extend({ action: z27.literal("branch.merge"), branchName: z27.string().max(200) });
|
|
14084
|
+
var chainBranchConflictsVariant = branchBase.extend({ action: z27.literal("branch.conflicts"), branchName: z27.string().max(200) });
|
|
14085
|
+
var chainReviewActionUnion = z27.discriminatedUnion("action", [
|
|
13921
14086
|
chainReviewGateVariant,
|
|
13922
14087
|
chainReviewCommentVariant,
|
|
13923
14088
|
chainReviewResolveCommentVariant,
|
|
@@ -14009,44 +14174,44 @@ function registerGitChainTools(server) {
|
|
|
14009
14174
|
}
|
|
14010
14175
|
|
|
14011
14176
|
// src/tools/maps.ts
|
|
14012
|
-
import { z as
|
|
14013
|
-
var createAudienceMapSetSchema =
|
|
14014
|
-
audienceEntryId:
|
|
14177
|
+
import { z as z28 } from "zod/v3";
|
|
14178
|
+
var createAudienceMapSetSchema = z28.object({
|
|
14179
|
+
audienceEntryId: z28.string().max(200).describe("Entry ID of the audience (e.g. STR-fb7hje)"),
|
|
14015
14180
|
// WP-513: team+role to create AS OWNER of (rung 2); ID or entryId (e.g. "TEAM-1"); no-op pre-rung-2.
|
|
14016
|
-
ownerTeamEntryId:
|
|
14017
|
-
ownerRoleEntryId:
|
|
14181
|
+
ownerTeamEntryId: z28.string().max(200).optional().describe("Team entry ID/ref to own the created maps (required once the workspace is on rung 2)"),
|
|
14182
|
+
ownerRoleEntryId: z28.string().max(200).optional().describe("Role entry ID/ref to own the created maps (required once the workspace is on rung 2)")
|
|
14018
14183
|
});
|
|
14019
|
-
var mapSchema =
|
|
14020
|
-
action:
|
|
14021
|
-
mapEntryId:
|
|
14022
|
-
title:
|
|
14023
|
-
templateId:
|
|
14024
|
-
description:
|
|
14025
|
-
slotIds:
|
|
14026
|
-
status:
|
|
14184
|
+
var mapSchema = z28.object({
|
|
14185
|
+
action: z28.enum(["create", "get", "list"]).describe("Action: create a map, get map details, or list all maps"),
|
|
14186
|
+
mapEntryId: z28.string().max(200).optional().describe("Map entry ID (for get)"),
|
|
14187
|
+
title: z28.string().max(500).optional().describe("Map title (for create)"),
|
|
14188
|
+
templateId: z28.string().max(200).optional().default("lean-canvas").describe("Template slug for create: 'lean-canvas' or any composed template"),
|
|
14189
|
+
description: z28.string().max(2e4).optional().describe("Description (for create)"),
|
|
14190
|
+
slotIds: z28.array(z28.string().max(200)).max(200).optional().describe("Slot IDs to initialize (for create; auto-populated from template if omitted)"),
|
|
14191
|
+
status: z28.string().max(200).optional().describe("Filter by status for list"),
|
|
14027
14192
|
// WP-513: team+role to create AS OWNER of (rung 2, action "create" only); no-op pre-rung-2.
|
|
14028
|
-
ownerTeamEntryId:
|
|
14029
|
-
ownerRoleEntryId:
|
|
14193
|
+
ownerTeamEntryId: z28.string().max(200).optional().describe("Team entry ID/ref to own the created map (required once the workspace is on rung 2)"),
|
|
14194
|
+
ownerRoleEntryId: z28.string().max(200).optional().describe("Role entry ID/ref to own the created map (required once the workspace is on rung 2)")
|
|
14030
14195
|
});
|
|
14031
|
-
var mapSlotSchema =
|
|
14032
|
-
action:
|
|
14033
|
-
mapEntryId:
|
|
14034
|
-
slotId:
|
|
14035
|
-
ingredientEntryId:
|
|
14036
|
-
newIngredientEntryId:
|
|
14037
|
-
label:
|
|
14038
|
-
author:
|
|
14196
|
+
var mapSlotSchema = z28.object({
|
|
14197
|
+
action: z28.enum(["add", "remove", "replace", "list"]).describe("Action: add/remove/replace an ingredient in a slot, or list slot contents"),
|
|
14198
|
+
mapEntryId: z28.string().max(200).describe("Map entry ID"),
|
|
14199
|
+
slotId: z28.string().max(200).optional().describe("Slot ID (e.g. 'problem', 'customer-segments')"),
|
|
14200
|
+
ingredientEntryId: z28.string().max(200).optional().describe("Ingredient entry ID to add/remove"),
|
|
14201
|
+
newIngredientEntryId: z28.string().max(200).optional().describe("New ingredient entry ID (for replace)"),
|
|
14202
|
+
label: z28.string().max(500).optional().describe("Display label override"),
|
|
14203
|
+
author: z28.string().max(200).optional().describe("Who is performing the action")
|
|
14039
14204
|
});
|
|
14040
|
-
var mapVersionSchema =
|
|
14041
|
-
action:
|
|
14042
|
-
mapEntryId:
|
|
14043
|
-
commitMessage:
|
|
14044
|
-
author:
|
|
14205
|
+
var mapVersionSchema = z28.object({
|
|
14206
|
+
action: z28.enum(["commit", "list", "history"]).describe("Action: commit the map, list commits, or view commit history"),
|
|
14207
|
+
mapEntryId: z28.string().max(200).describe("Map entry ID"),
|
|
14208
|
+
commitMessage: z28.string().max(2e3).optional().describe("Commit message (for commit action)"),
|
|
14209
|
+
author: z28.string().max(200).optional().describe("Who is committing")
|
|
14045
14210
|
});
|
|
14046
|
-
var mapSuggestSchema =
|
|
14047
|
-
mapEntryId:
|
|
14048
|
-
slotId:
|
|
14049
|
-
query:
|
|
14211
|
+
var mapSuggestSchema = z28.object({
|
|
14212
|
+
mapEntryId: z28.string().max(200).describe("Map entry ID to suggest ingredients for"),
|
|
14213
|
+
slotId: z28.string().max(200).optional().describe("Specific slot to find ingredients for (or all empty slots)"),
|
|
14214
|
+
query: z28.string().max(500).optional().describe("Optional search query to narrow ingredient suggestions")
|
|
14050
14215
|
});
|
|
14051
14216
|
function slotSummary(slots) {
|
|
14052
14217
|
return Object.entries(slots).map(([id, refs]) => {
|
|
@@ -14426,43 +14591,43 @@ var MAP_ACTIONS = [
|
|
|
14426
14591
|
"suggest",
|
|
14427
14592
|
"create-audience-set"
|
|
14428
14593
|
];
|
|
14429
|
-
var mapCompoundSchema =
|
|
14430
|
-
action:
|
|
14594
|
+
var mapCompoundSchema = z28.object({
|
|
14595
|
+
action: z28.enum(MAP_ACTIONS).describe(
|
|
14431
14596
|
"Unnamespaced: 'create'/'get'/'list' \u2014 map CRUD (the original `map` tool). 'slot.*' (add/remove/replace/list) \u2014 ingredient slot management, absorbs `map-slot`. 'version.*' (commit/list/history) \u2014 versioning, absorbs `map-version`. 'suggest' \u2014 find ingredients to fill empty slots, absorbs `map-suggest`. 'create-audience-set' \u2014 create all three audience intelligence maps at once, absorbs `create-audience-map-set`."
|
|
14432
14597
|
),
|
|
14433
|
-
mapEntryId:
|
|
14434
|
-
title:
|
|
14435
|
-
templateId:
|
|
14436
|
-
description:
|
|
14437
|
-
slotIds:
|
|
14438
|
-
status:
|
|
14439
|
-
slotId:
|
|
14440
|
-
ingredientEntryId:
|
|
14441
|
-
newIngredientEntryId:
|
|
14442
|
-
label:
|
|
14443
|
-
author:
|
|
14444
|
-
commitMessage:
|
|
14445
|
-
query:
|
|
14446
|
-
audienceEntryId:
|
|
14598
|
+
mapEntryId: z28.string().max(200).optional().describe("Map entry ID. Required for get and all slot.*/version.*/suggest actions."),
|
|
14599
|
+
title: z28.string().max(500).optional().describe("For 'create': map title (required)."),
|
|
14600
|
+
templateId: z28.string().max(200).optional().default("lean-canvas").describe("For 'create': template slug."),
|
|
14601
|
+
description: z28.string().max(2e4).optional().describe("For 'create': description."),
|
|
14602
|
+
slotIds: z28.array(z28.string().max(200)).max(200).optional().describe("For 'create': slot IDs to initialize."),
|
|
14603
|
+
status: z28.string().max(200).optional().describe("For 'list': filter by status."),
|
|
14604
|
+
slotId: z28.string().max(200).optional().describe("For 'slot.add'/'slot.remove'/'slot.replace': slot ID (required). For 'suggest': specific slot (optional)."),
|
|
14605
|
+
ingredientEntryId: z28.string().max(200).optional().describe("For 'slot.add'/'slot.remove'/'slot.replace': ingredient entry ID to add/remove (required)."),
|
|
14606
|
+
newIngredientEntryId: z28.string().max(200).optional().describe("For 'slot.replace': new ingredient entry ID (required)."),
|
|
14607
|
+
label: z28.string().max(500).optional().describe("For 'slot.add'/'slot.replace': display label override."),
|
|
14608
|
+
author: z28.string().max(200).optional().describe("Who is performing the action."),
|
|
14609
|
+
commitMessage: z28.string().max(2e3).optional().describe("For 'version.commit': commit message."),
|
|
14610
|
+
query: z28.string().max(500).optional().describe("For 'suggest': search query to narrow ingredient suggestions."),
|
|
14611
|
+
audienceEntryId: z28.string().max(200).optional().describe("For 'create-audience-set': audience entry ID (required)."),
|
|
14447
14612
|
// WP-513 review round 3 (P1): without these here, zod strips them before mapActionUnion ever sees them.
|
|
14448
|
-
ownerTeamEntryId:
|
|
14449
|
-
ownerRoleEntryId:
|
|
14613
|
+
ownerTeamEntryId: z28.string().max(200).optional().describe("For 'create'/'create-audience-set': owning team (rung-2 workspaces)."),
|
|
14614
|
+
ownerRoleEntryId: z28.string().max(200).optional().describe("For 'create'/'create-audience-set': owning role (rung-2 workspaces).")
|
|
14450
14615
|
});
|
|
14451
|
-
var mapCreateVariant = mapSchema.omit({ action: true }).extend({ action:
|
|
14452
|
-
var mapGetVariant =
|
|
14453
|
-
var mapListVariant =
|
|
14616
|
+
var mapCreateVariant = mapSchema.omit({ action: true }).extend({ action: z28.literal("create") });
|
|
14617
|
+
var mapGetVariant = z28.object({ action: z28.literal("get"), mapEntryId: z28.string().max(200) });
|
|
14618
|
+
var mapListVariant = z28.object({ action: z28.literal("list"), templateId: z28.string().max(200).optional(), status: z28.string().max(200).optional() });
|
|
14454
14619
|
var slotBase = mapSlotSchema.omit({ action: true });
|
|
14455
|
-
var mapSlotAddVariant = slotBase.extend({ action:
|
|
14456
|
-
var mapSlotRemoveVariant = slotBase.extend({ action:
|
|
14457
|
-
var mapSlotReplaceVariant = slotBase.extend({ action:
|
|
14458
|
-
var mapSlotListVariant = slotBase.extend({ action:
|
|
14620
|
+
var mapSlotAddVariant = slotBase.extend({ action: z28.literal("slot.add"), slotId: z28.string().max(200), ingredientEntryId: z28.string().max(200) });
|
|
14621
|
+
var mapSlotRemoveVariant = slotBase.extend({ action: z28.literal("slot.remove"), slotId: z28.string().max(200), ingredientEntryId: z28.string().max(200) });
|
|
14622
|
+
var mapSlotReplaceVariant = slotBase.extend({ action: z28.literal("slot.replace"), slotId: z28.string().max(200), ingredientEntryId: z28.string().max(200), newIngredientEntryId: z28.string().max(200) });
|
|
14623
|
+
var mapSlotListVariant = slotBase.extend({ action: z28.literal("slot.list") });
|
|
14459
14624
|
var versionBase2 = mapVersionSchema.omit({ action: true });
|
|
14460
|
-
var mapVersionCommitVariant = versionBase2.extend({ action:
|
|
14461
|
-
var mapVersionListVariant = versionBase2.extend({ action:
|
|
14462
|
-
var mapVersionHistoryVariant = versionBase2.extend({ action:
|
|
14463
|
-
var mapSuggestVariant = mapSuggestSchema.extend({ action:
|
|
14464
|
-
var mapCreateAudienceSetVariant = createAudienceMapSetSchema.extend({ action:
|
|
14465
|
-
var mapActionUnion =
|
|
14625
|
+
var mapVersionCommitVariant = versionBase2.extend({ action: z28.literal("version.commit") });
|
|
14626
|
+
var mapVersionListVariant = versionBase2.extend({ action: z28.literal("version.list") });
|
|
14627
|
+
var mapVersionHistoryVariant = versionBase2.extend({ action: z28.literal("version.history") });
|
|
14628
|
+
var mapSuggestVariant = mapSuggestSchema.extend({ action: z28.literal("suggest") });
|
|
14629
|
+
var mapCreateAudienceSetVariant = createAudienceMapSetSchema.extend({ action: z28.literal("create-audience-set") });
|
|
14630
|
+
var mapActionUnion = z28.discriminatedUnion("action", [
|
|
14466
14631
|
mapCreateVariant,
|
|
14467
14632
|
mapGetVariant,
|
|
14468
14633
|
mapListVariant,
|
|
@@ -14526,10 +14691,37 @@ function registerMapTools(server) {
|
|
|
14526
14691
|
}
|
|
14527
14692
|
|
|
14528
14693
|
// src/tools/workspace.ts
|
|
14529
|
-
import { z as
|
|
14694
|
+
import { z as z31 } from "zod/v3";
|
|
14695
|
+
|
|
14696
|
+
// src/tools/health.ts
|
|
14697
|
+
import { z as z29 } from "zod/v3";
|
|
14698
|
+
|
|
14699
|
+
// src/lib/auditView.ts
|
|
14700
|
+
async function buildTenantAuditView(limit) {
|
|
14701
|
+
const scope = cacheScope();
|
|
14702
|
+
let workspace;
|
|
14703
|
+
try {
|
|
14704
|
+
workspace = await getWorkspaceId();
|
|
14705
|
+
} catch {
|
|
14706
|
+
workspace = scope;
|
|
14707
|
+
}
|
|
14708
|
+
const ownScopes = [workspace, scope];
|
|
14709
|
+
const log = getAuditLog(ownScopes);
|
|
14710
|
+
const recent = log.slice(-limit);
|
|
14711
|
+
const gatewaySeam = getMergedGatewaySeamCounters(ownScopes);
|
|
14712
|
+
const logLines = [
|
|
14713
|
+
`# Audit Log (last ${recent.length} of ${log.length} total)
|
|
14714
|
+
`,
|
|
14715
|
+
...recent.map((entry) => {
|
|
14716
|
+
const toolPart = entry.toolContext ? ` [${entry.toolContext.tool}${entry.toolContext.action ? ` action=${entry.toolContext.action}` : ""}]` : "";
|
|
14717
|
+
const errPart = entry.error ? ` \u2014 ${entry.error}` : "";
|
|
14718
|
+
return `${entry.status === "ok" ? "\u2713" : "\u2717"} \`${entry.fn}\`${toolPart} ${entry.durationMs}ms ${entry.status}${errPart}`;
|
|
14719
|
+
})
|
|
14720
|
+
];
|
|
14721
|
+
return { workspace, log, recent, gatewaySeam, logLines, seamSummaryText: formatGatewaySeamSummary(gatewaySeam) };
|
|
14722
|
+
}
|
|
14530
14723
|
|
|
14531
14724
|
// src/tools/health.ts
|
|
14532
|
-
import { z as z28 } from "zod/v3";
|
|
14533
14725
|
var CALL_CATEGORIES = {
|
|
14534
14726
|
"chain.getEntry": "read",
|
|
14535
14727
|
"chain.batchGetEntries": "read",
|
|
@@ -14838,27 +15030,19 @@ async function handleWorkspaceStatus() {
|
|
|
14838
15030
|
};
|
|
14839
15031
|
}
|
|
14840
15032
|
async function handleAudit2(limit) {
|
|
14841
|
-
const log =
|
|
14842
|
-
|
|
14843
|
-
if (recent.length === 0) {
|
|
14844
|
-
return successResult("No calls recorded yet this session.", "No calls recorded yet this session.", { totalCalls: 0, calls: [] });
|
|
14845
|
-
}
|
|
15033
|
+
const { log, recent, gatewaySeam, logLines, seamSummaryText } = await buildTenantAuditView(limit);
|
|
15034
|
+
if (recent.length === 0) return successResult(`No calls recorded yet this session.${seamSummaryText}`, "No calls recorded yet this session.", { totalCalls: 0, calls: [], gatewaySeam });
|
|
14846
15035
|
const summary = buildSessionSummary(log);
|
|
14847
|
-
const logLines = [`# Audit Log (last ${recent.length} of ${log.length} total)
|
|
14848
|
-
`];
|
|
14849
|
-
for (const entry of recent) {
|
|
14850
|
-
const icon = entry.status === "ok" ? "\u2713" : "\u2717";
|
|
14851
|
-
const errPart = entry.error ? ` \u2014 ${entry.error}` : "";
|
|
14852
|
-
const toolPart = entry.toolContext ? ` [${entry.toolContext.tool}${entry.toolContext.action ? ` action=${entry.toolContext.action}` : ""}]` : "";
|
|
14853
|
-
logLines.push(`${icon} \`${entry.fn}\`${toolPart} ${entry.durationMs}ms ${entry.status}${errPart}`);
|
|
14854
|
-
}
|
|
14855
15036
|
const auditData = {
|
|
14856
15037
|
totalCalls: log.length,
|
|
15038
|
+
gatewaySeam,
|
|
14857
15039
|
calls: recent.map((entry) => ({
|
|
14858
15040
|
tool: entry.fn,
|
|
14859
15041
|
...entry.toolContext?.action && { action: entry.toolContext.action },
|
|
14860
15042
|
timestamp: entry.ts,
|
|
14861
|
-
...entry.durationMs != null && { durationMs: entry.durationMs }
|
|
15043
|
+
...entry.durationMs != null && { durationMs: entry.durationMs },
|
|
15044
|
+
...entry.budgetMs != null && { budgetMs: entry.budgetMs },
|
|
15045
|
+
...entry.timedOut ? { timedOut: true } : {}
|
|
14862
15046
|
}))
|
|
14863
15047
|
};
|
|
14864
15048
|
return {
|
|
@@ -14866,7 +15050,7 @@ async function handleAudit2(limit) {
|
|
|
14866
15050
|
|
|
14867
15051
|
---
|
|
14868
15052
|
|
|
14869
|
-
${logLines.join("\n")}` }],
|
|
15053
|
+
${logLines.join("\n")}${seamSummaryText}` }],
|
|
14870
15054
|
structuredContent: success(
|
|
14871
15055
|
`Audit: ${log.length} total calls, showing last ${recent.length}.`,
|
|
14872
15056
|
auditData
|
|
@@ -14874,65 +15058,65 @@ ${logLines.join("\n")}` }],
|
|
|
14874
15058
|
};
|
|
14875
15059
|
}
|
|
14876
15060
|
var HEALTH_ACTIONS = ["check", "whoami", "status", "audit", "self-test"];
|
|
14877
|
-
var healthSchema =
|
|
14878
|
-
action:
|
|
15061
|
+
var healthSchema = z29.object({
|
|
15062
|
+
action: z29.enum(HEALTH_ACTIONS).describe(
|
|
14879
15063
|
"'check': connectivity and workspace stats. 'whoami': session identity. 'status': workspace readiness. 'audit': session audit log. 'self-test': validate all tool schemas."
|
|
14880
15064
|
),
|
|
14881
|
-
limit:
|
|
15065
|
+
limit: z29.number().min(1).max(50).default(20).optional().describe("For audit: how many recent calls to show (max 50)")
|
|
14882
15066
|
});
|
|
14883
|
-
var healthCheckOutputSchema =
|
|
14884
|
-
healthy:
|
|
14885
|
-
collections:
|
|
14886
|
-
entries:
|
|
14887
|
-
latencyMs:
|
|
14888
|
-
workspace:
|
|
15067
|
+
var healthCheckOutputSchema = z29.object({
|
|
15068
|
+
healthy: z29.boolean(),
|
|
15069
|
+
collections: z29.number(),
|
|
15070
|
+
entries: z29.number(),
|
|
15071
|
+
latencyMs: z29.number(),
|
|
15072
|
+
workspace: z29.string()
|
|
14889
15073
|
});
|
|
14890
|
-
var organisationHealthSchema =
|
|
14891
|
-
reviewed:
|
|
14892
|
-
agreements:
|
|
14893
|
-
disagreements:
|
|
14894
|
-
abstentions:
|
|
14895
|
-
agreementRate:
|
|
14896
|
-
flags:
|
|
14897
|
-
collection:
|
|
14898
|
-
count:
|
|
14899
|
-
suggestedCollection:
|
|
15074
|
+
var organisationHealthSchema = z29.object({
|
|
15075
|
+
reviewed: z29.number(),
|
|
15076
|
+
agreements: z29.number(),
|
|
15077
|
+
disagreements: z29.number(),
|
|
15078
|
+
abstentions: z29.number(),
|
|
15079
|
+
agreementRate: z29.number(),
|
|
15080
|
+
flags: z29.array(z29.object({
|
|
15081
|
+
collection: z29.string(),
|
|
15082
|
+
count: z29.number(),
|
|
15083
|
+
suggestedCollection: z29.string()
|
|
14900
15084
|
}))
|
|
14901
15085
|
});
|
|
14902
|
-
var healthStatusOutputSchema =
|
|
14903
|
-
stage:
|
|
14904
|
-
scoringVersion:
|
|
14905
|
-
readinessScore:
|
|
14906
|
-
activeEntries:
|
|
14907
|
-
totalRelations:
|
|
14908
|
-
orphanedEntries:
|
|
14909
|
-
gaps:
|
|
15086
|
+
var healthStatusOutputSchema = z29.object({
|
|
15087
|
+
stage: z29.enum(["blank", "seeded", "grounded", "connected"]).optional().default("seeded"),
|
|
15088
|
+
scoringVersion: z29.enum(["v1", "v2"]).optional().default("v1"),
|
|
15089
|
+
readinessScore: z29.number(),
|
|
15090
|
+
activeEntries: z29.number(),
|
|
15091
|
+
totalRelations: z29.number(),
|
|
15092
|
+
orphanedEntries: z29.number(),
|
|
15093
|
+
gaps: z29.array(z29.object({ id: z29.string(), label: z29.string(), guidance: z29.string() })),
|
|
14910
15094
|
organisationHealth: organisationHealthSchema.optional()
|
|
14911
15095
|
});
|
|
14912
|
-
var healthAuditOutputSchema =
|
|
14913
|
-
totalCalls:
|
|
14914
|
-
calls:
|
|
14915
|
-
tool:
|
|
14916
|
-
action:
|
|
14917
|
-
timestamp:
|
|
14918
|
-
durationMs:
|
|
15096
|
+
var healthAuditOutputSchema = z29.object({
|
|
15097
|
+
totalCalls: z29.number(),
|
|
15098
|
+
calls: z29.array(z29.object({
|
|
15099
|
+
tool: z29.string(),
|
|
15100
|
+
action: z29.string().optional(),
|
|
15101
|
+
timestamp: z29.string(),
|
|
15102
|
+
durationMs: z29.number().optional()
|
|
14919
15103
|
}))
|
|
14920
15104
|
});
|
|
14921
|
-
var healthWhoamiOutputSchema =
|
|
14922
|
-
workspaceId:
|
|
14923
|
-
workspaceName:
|
|
14924
|
-
scope:
|
|
14925
|
-
sessionId:
|
|
14926
|
-
oriented:
|
|
15105
|
+
var healthWhoamiOutputSchema = z29.object({
|
|
15106
|
+
workspaceId: z29.string(),
|
|
15107
|
+
workspaceName: z29.string(),
|
|
15108
|
+
scope: z29.string(),
|
|
15109
|
+
sessionId: z29.union([z29.string(), z29.null()]),
|
|
15110
|
+
oriented: z29.boolean()
|
|
14927
15111
|
});
|
|
14928
|
-
var selfTestOutputSchema =
|
|
14929
|
-
passed:
|
|
14930
|
-
failed:
|
|
14931
|
-
total:
|
|
14932
|
-
results:
|
|
14933
|
-
tool:
|
|
14934
|
-
valid:
|
|
14935
|
-
error:
|
|
15112
|
+
var selfTestOutputSchema = z29.object({
|
|
15113
|
+
passed: z29.number(),
|
|
15114
|
+
failed: z29.number(),
|
|
15115
|
+
total: z29.number(),
|
|
15116
|
+
results: z29.array(z29.object({
|
|
15117
|
+
tool: z29.string(),
|
|
15118
|
+
valid: z29.boolean(),
|
|
15119
|
+
error: z29.string().optional()
|
|
14936
15120
|
}))
|
|
14937
15121
|
});
|
|
14938
15122
|
function handleSelfTest(server) {
|
|
@@ -14983,9 +15167,9 @@ function handleSelfTest(server) {
|
|
|
14983
15167
|
}
|
|
14984
15168
|
|
|
14985
15169
|
// src/tools/usage.ts
|
|
14986
|
-
import { z as
|
|
14987
|
-
var usageSummarySchema =
|
|
14988
|
-
periodDays:
|
|
15170
|
+
import { z as z30 } from "zod/v3";
|
|
15171
|
+
var usageSummarySchema = z30.object({
|
|
15172
|
+
periodDays: z30.number().min(1).max(90).optional().describe("Number of days to look back (default 30, max 90)")
|
|
14989
15173
|
});
|
|
14990
15174
|
async function handleUsageSummary(periodDays) {
|
|
14991
15175
|
const ws = await getWorkspaceContext();
|
|
@@ -15157,35 +15341,35 @@ var WORKSPACE_ACTIONS = [
|
|
|
15157
15341
|
"proposals-respond",
|
|
15158
15342
|
"proposals-count"
|
|
15159
15343
|
];
|
|
15160
|
-
var workspaceSchema =
|
|
15161
|
-
action:
|
|
15344
|
+
var workspaceSchema = z31.object({
|
|
15345
|
+
action: z31.enum(WORKSPACE_ACTIONS).describe(
|
|
15162
15346
|
"'check': connectivity and workspace stats (absorbs health action=check). 'whoami': session identity (absorbs health action=whoami). 'status': workspace readiness (absorbs health action=status). 'audit': session audit log (absorbs health action=audit). 'self-test': validate all tool schemas (absorbs health action=self-test). 'usage': LLM usage and cost summary (absorbs get-usage-summary). 'proposals-list': list open consent proposals (absorbs governance-proposals action=list). 'proposals-respond': approve/reject a consent proposal (absorbs governance-proposals action=respond). 'proposals-count': count open consent proposals (absorbs governance-proposals action=count)."
|
|
15163
15347
|
),
|
|
15164
|
-
limit:
|
|
15165
|
-
periodDays:
|
|
15166
|
-
status:
|
|
15167
|
-
proposalId:
|
|
15168
|
-
verdict:
|
|
15169
|
-
reason:
|
|
15348
|
+
limit: z31.number().min(1).max(50).optional().describe("For 'audit': how many recent calls to show (max 50, default 20)."),
|
|
15349
|
+
periodDays: z31.number().min(1).max(90).optional().describe("For 'usage': number of days to look back (default 30, max 90)."),
|
|
15350
|
+
status: z31.enum(["open", "approved", "objected", "expired"]).optional().describe("For 'proposals-list': filter by status (default: open)."),
|
|
15351
|
+
proposalId: z31.string().max(200).optional().describe("For 'proposals-respond': proposal ID."),
|
|
15352
|
+
verdict: z31.enum(["approve", "reject"]).optional().describe("For 'proposals-respond': approve or reject."),
|
|
15353
|
+
reason: z31.string().max(2e3).optional().describe("For 'proposals-respond': reason for the verdict (required when rejecting).")
|
|
15170
15354
|
});
|
|
15171
|
-
var workspaceCheckVariant =
|
|
15172
|
-
var workspaceWhoamiVariant =
|
|
15173
|
-
var workspaceStatusVariant =
|
|
15174
|
-
var workspaceAuditVariant =
|
|
15175
|
-
var workspaceSelfTestVariant =
|
|
15176
|
-
var workspaceUsageVariant =
|
|
15177
|
-
var workspaceProposalsListVariant =
|
|
15178
|
-
action:
|
|
15179
|
-
status:
|
|
15355
|
+
var workspaceCheckVariant = z31.object({ action: z31.literal("check") });
|
|
15356
|
+
var workspaceWhoamiVariant = z31.object({ action: z31.literal("whoami") });
|
|
15357
|
+
var workspaceStatusVariant = z31.object({ action: z31.literal("status") });
|
|
15358
|
+
var workspaceAuditVariant = z31.object({ action: z31.literal("audit"), limit: z31.number().min(1).max(50).optional().default(20) });
|
|
15359
|
+
var workspaceSelfTestVariant = z31.object({ action: z31.literal("self-test") });
|
|
15360
|
+
var workspaceUsageVariant = z31.object({ action: z31.literal("usage"), periodDays: z31.number().min(1).max(90).optional() });
|
|
15361
|
+
var workspaceProposalsListVariant = z31.object({
|
|
15362
|
+
action: z31.literal("proposals-list"),
|
|
15363
|
+
status: z31.enum(["open", "approved", "objected", "expired"]).optional()
|
|
15180
15364
|
});
|
|
15181
|
-
var workspaceProposalsRespondVariant =
|
|
15182
|
-
action:
|
|
15183
|
-
proposalId:
|
|
15184
|
-
verdict:
|
|
15185
|
-
reason:
|
|
15365
|
+
var workspaceProposalsRespondVariant = z31.object({
|
|
15366
|
+
action: z31.literal("proposals-respond"),
|
|
15367
|
+
proposalId: z31.string().max(200),
|
|
15368
|
+
verdict: z31.enum(["approve", "reject"]),
|
|
15369
|
+
reason: z31.string().max(2e3).optional()
|
|
15186
15370
|
});
|
|
15187
|
-
var workspaceProposalsCountVariant =
|
|
15188
|
-
var workspaceActionUnion =
|
|
15371
|
+
var workspaceProposalsCountVariant = z31.object({ action: z31.literal("proposals-count") });
|
|
15372
|
+
var workspaceActionUnion = z31.discriminatedUnion("action", [
|
|
15189
15373
|
workspaceCheckVariant,
|
|
15190
15374
|
workspaceWhoamiVariant,
|
|
15191
15375
|
workspaceStatusVariant,
|
|
@@ -15241,7 +15425,7 @@ function registerWorkspaceTools(server) {
|
|
|
15241
15425
|
}
|
|
15242
15426
|
|
|
15243
15427
|
// src/tools/feedback.ts
|
|
15244
|
-
import { z as
|
|
15428
|
+
import { z as z32 } from "zod/v3";
|
|
15245
15429
|
|
|
15246
15430
|
// src/lib/productFeedbackConstants.ts
|
|
15247
15431
|
var PRODUCT_FEEDBACK_CATEGORIES = ["bug", "friction", "idea", "praise", "other"];
|
|
@@ -15252,9 +15436,9 @@ var VENDOR_SETTABLE_STATUSES = PRODUCT_FEEDBACK_STATUSES.filter(
|
|
|
15252
15436
|
|
|
15253
15437
|
// src/tools/feedback.ts
|
|
15254
15438
|
var actions = ["submit", "list", "queue", "note", "group", "status"];
|
|
15255
|
-
var category =
|
|
15256
|
-
var status =
|
|
15257
|
-
var vendorStatus =
|
|
15439
|
+
var category = z32.enum(PRODUCT_FEEDBACK_CATEGORIES);
|
|
15440
|
+
var status = z32.enum(PRODUCT_FEEDBACK_STATUSES);
|
|
15441
|
+
var vendorStatus = z32.enum(VENDOR_SETTABLE_STATUSES);
|
|
15258
15442
|
var GATEWAY_MAX_STRING_BYTES = 10240;
|
|
15259
15443
|
var utf8Bytes = (value) => new TextEncoder().encode(value).length;
|
|
15260
15444
|
var fitsGatewayBytes = (value) => utf8Bytes(value) <= GATEWAY_MAX_STRING_BYTES;
|
|
@@ -15263,32 +15447,32 @@ var byteLimitMessage = (field) => ({
|
|
|
15263
15447
|
});
|
|
15264
15448
|
var MESSAGE_DISPLAY_LIMIT = 1e3;
|
|
15265
15449
|
var FULL_MESSAGE_MAX_LIMIT = 5;
|
|
15266
|
-
var feedbackSchema =
|
|
15267
|
-
action:
|
|
15268
|
-
message:
|
|
15450
|
+
var feedbackSchema = z32.object({
|
|
15451
|
+
action: z32.enum(actions).describe("submit requires message; list returns your own workspace's feedback (all statuses); queue is the vendor triage queue (system admins only) and accepts filters; note requires feedbackId+note; group requires feedbackIds+groupId (null clears); status requires feedbackId+status."),
|
|
15452
|
+
message: z32.string().max(1e4).optional().describe("Required for submit: the product feedback text (max 10,000 chars and 10,240 UTF-8 bytes)."),
|
|
15269
15453
|
category: category.optional().describe("Submit/queue category; submit defaults to other."),
|
|
15270
|
-
command:
|
|
15271
|
-
route:
|
|
15272
|
-
client:
|
|
15273
|
-
feedbackId:
|
|
15274
|
-
feedbackIds:
|
|
15275
|
-
note:
|
|
15454
|
+
command: z32.string().max(1e3).optional().describe("Optional submit command context; argument values are scrubbed server-side."),
|
|
15455
|
+
route: z32.string().max(500).optional().describe("Optional submit route context."),
|
|
15456
|
+
client: z32.string().max(100).optional().describe("Optional submit client label."),
|
|
15457
|
+
feedbackId: z32.string().max(200).optional().describe("Required for note/status: target feedback ID."),
|
|
15458
|
+
feedbackIds: z32.array(z32.string().max(200)).max(100).optional().describe("Required for group: 1\u2013100 target feedback IDs."),
|
|
15459
|
+
note: z32.string().max(4e3).optional().describe("Required for note: replacement triage note (max 10,240 UTF-8 bytes)."),
|
|
15276
15460
|
status: status.optional().describe("list/queue filter (any status, including 'screening'); the status action's required target value excludes 'screening' (system-only)."),
|
|
15277
|
-
groupId:
|
|
15278
|
-
workspaceId:
|
|
15279
|
-
since:
|
|
15280
|
-
before:
|
|
15281
|
-
limit:
|
|
15282
|
-
cursor:
|
|
15283
|
-
full:
|
|
15461
|
+
groupId: z32.string().min(1).max(200).nullable().optional().describe("Group filter, or required group destination; null explicitly clears grouping."),
|
|
15462
|
+
workspaceId: z32.string().max(200).optional().describe("Queue-only filter (vendor cross-workspace triage); omitted means all workspaces. Has no effect on list \u2014 your own workspace is always injected server-side."),
|
|
15463
|
+
since: z32.number().optional().describe("Queue-only lower createdAt window bound (inclusive) in epoch milliseconds."),
|
|
15464
|
+
before: z32.number().optional().describe("Queue-only upper createdAt window bound (exclusive) in epoch milliseconds. A time-window FILTER, not the pager \u2014 use cursor to page."),
|
|
15465
|
+
limit: z32.number().int().min(1).max(100).optional().describe("list/queue row limit, default 50, maximum 100."),
|
|
15466
|
+
cursor: z32.string().max(2e3).optional().describe("Opaque pagination cursor from a previous list/queue response (continueCursor); omit for the first page."),
|
|
15467
|
+
full: z32.boolean().optional().describe(`list/queue only: return untruncated messages; allowed only when limit <= ${FULL_MESSAGE_MAX_LIMIT}.`)
|
|
15284
15468
|
});
|
|
15285
|
-
var union =
|
|
15286
|
-
|
|
15287
|
-
|
|
15288
|
-
|
|
15289
|
-
|
|
15290
|
-
|
|
15291
|
-
|
|
15469
|
+
var union = z32.discriminatedUnion("action", [
|
|
15470
|
+
z32.object({ action: z32.literal("submit"), message: z32.string().min(1).max(1e4).refine(fitsGatewayBytes, byteLimitMessage("message")), category: category.optional(), command: z32.string().max(1e3).optional(), route: z32.string().max(500).optional(), client: z32.string().max(100).optional() }),
|
|
15471
|
+
z32.object({ action: z32.literal("list"), status: status.optional(), limit: z32.number().int().min(1).max(100).optional(), cursor: z32.string().max(2e3).optional(), full: z32.boolean().optional() }),
|
|
15472
|
+
z32.object({ action: z32.literal("queue"), status: status.optional(), category: category.optional(), groupId: z32.string().min(1).max(200).optional(), workspaceId: z32.string().max(200).optional(), since: z32.number().optional(), before: z32.number().optional(), limit: z32.number().int().min(1).max(100).optional(), cursor: z32.string().max(2e3).optional(), full: z32.boolean().optional() }),
|
|
15473
|
+
z32.object({ action: z32.literal("note"), feedbackId: z32.string().min(1).max(200), note: z32.string().max(4e3).refine(fitsGatewayBytes, byteLimitMessage("note")) }),
|
|
15474
|
+
z32.object({ action: z32.literal("group"), feedbackIds: z32.array(z32.string().min(1).max(200)).min(1).max(100), groupId: z32.string().min(1).max(200).nullable() }),
|
|
15475
|
+
z32.object({ action: z32.literal("status"), feedbackId: z32.string().min(1).max(200), status: vendorStatus })
|
|
15292
15476
|
]);
|
|
15293
15477
|
var specs = {
|
|
15294
15478
|
submit: { params: ["message", "category", "command", "route", "client"], description: "message is required; category defaults to other." },
|
|
@@ -15415,34 +15599,34 @@ function registerFeedbackTool(server) {
|
|
|
15415
15599
|
}
|
|
15416
15600
|
|
|
15417
15601
|
// src/tools/shape.ts
|
|
15418
|
-
import { z as
|
|
15602
|
+
import { z as z33 } from "zod/v3";
|
|
15419
15603
|
var SHAPE_ACTIONS = ["list", "show", "agree", "dismiss"];
|
|
15420
15604
|
var LIST_DISPOSITIONS = ["pending", "agreed", "dismissed", "expired"];
|
|
15421
15605
|
var LIST_OUTCOMES = ["not_candidate", "atomic", "compound", "unavailable"];
|
|
15422
|
-
var shapeSchema =
|
|
15423
|
-
action:
|
|
15606
|
+
var shapeSchema = z33.object({
|
|
15607
|
+
action: z33.enum(SHAPE_ACTIONS).describe(
|
|
15424
15608
|
"'list': list shape advisories for this workspace, latest per subject. 'show': show one shape advisory by id. 'agree': agree with a compound advisory's split verdict. 'dismiss': dismiss a compound advisory's split verdict."
|
|
15425
15609
|
),
|
|
15426
|
-
disposition:
|
|
15610
|
+
disposition: z33.enum(LIST_DISPOSITIONS).optional().describe(
|
|
15427
15611
|
"For 'list': filter by disposition. Omitting both disposition and outcome defaults to the actionable set (disposition:pending, outcome:compound)."
|
|
15428
15612
|
),
|
|
15429
|
-
outcome:
|
|
15613
|
+
outcome: z33.enum(LIST_OUTCOMES).optional().describe(
|
|
15430
15614
|
"For 'list': filter by outcome. Omitting both disposition and outcome defaults to the actionable set (disposition:pending, outcome:compound)."
|
|
15431
15615
|
),
|
|
15432
|
-
limit:
|
|
15433
|
-
rowId:
|
|
15434
|
-
reason:
|
|
15616
|
+
limit: z33.number().min(1).max(200).optional().describe("For 'list': max rows (default 50, max 200)."),
|
|
15617
|
+
rowId: z33.string().max(200).optional().describe("For 'show'/'agree'/'dismiss': the advisory row id."),
|
|
15618
|
+
reason: z33.string().max(1e3).optional().describe("For 'agree'/'dismiss': optional reason (capped at 1000 chars).")
|
|
15435
15619
|
});
|
|
15436
|
-
var shapeListVariant =
|
|
15437
|
-
action:
|
|
15438
|
-
disposition:
|
|
15439
|
-
outcome:
|
|
15440
|
-
limit:
|
|
15620
|
+
var shapeListVariant = z33.object({
|
|
15621
|
+
action: z33.literal("list"),
|
|
15622
|
+
disposition: z33.enum(LIST_DISPOSITIONS).optional(),
|
|
15623
|
+
outcome: z33.enum(LIST_OUTCOMES).optional(),
|
|
15624
|
+
limit: z33.number().min(1).max(200).optional()
|
|
15441
15625
|
});
|
|
15442
|
-
var shapeShowVariant =
|
|
15443
|
-
var shapeAgreeVariant =
|
|
15444
|
-
var shapeDismissVariant =
|
|
15445
|
-
var shapeActionUnion =
|
|
15626
|
+
var shapeShowVariant = z33.object({ action: z33.literal("show"), rowId: z33.string().max(200) });
|
|
15627
|
+
var shapeAgreeVariant = z33.object({ action: z33.literal("agree"), rowId: z33.string().max(200), reason: z33.string().max(1e3).optional() });
|
|
15628
|
+
var shapeDismissVariant = z33.object({ action: z33.literal("dismiss"), rowId: z33.string().max(200), reason: z33.string().max(1e3).optional() });
|
|
15629
|
+
var shapeActionUnion = z33.discriminatedUnion("action", [
|
|
15446
15630
|
shapeListVariant,
|
|
15447
15631
|
shapeShowVariant,
|
|
15448
15632
|
shapeAgreeVariant,
|
|
@@ -16109,12 +16293,12 @@ ${entry.labels.map((l) => `- ${l.name ?? l.slug}`).join("\n")}`);
|
|
|
16109
16293
|
}
|
|
16110
16294
|
|
|
16111
16295
|
// src/prompts/index.ts
|
|
16112
|
-
import { z as
|
|
16296
|
+
import { z as z34 } from "zod/v3";
|
|
16113
16297
|
function registerPrompts(server) {
|
|
16114
16298
|
server.prompt(
|
|
16115
16299
|
"review-against-rules",
|
|
16116
16300
|
"Review code or a design decision against all business rules for a given domain. Fetches the rules and asks you to do a structured compliance review.",
|
|
16117
|
-
{ domain:
|
|
16301
|
+
{ domain: z34.string().describe("Business rule domain (e.g. 'Identity & Access', 'Governance & Decision-Making')") },
|
|
16118
16302
|
async ({ domain }) => {
|
|
16119
16303
|
const entries = await kernelQuery("chain.listEntries", { collectionSlug: "business-rules" });
|
|
16120
16304
|
const rules = entries.filter((e) => e.data?.domain === domain);
|
|
@@ -16167,7 +16351,7 @@ Provide a structured review with a compliance status for each rule (COMPLIANT /
|
|
|
16167
16351
|
server.prompt(
|
|
16168
16352
|
"name-check",
|
|
16169
16353
|
"Check variable names, field names, or API names against the glossary for terminology alignment. Flags drift from canonical terms.",
|
|
16170
|
-
{ names:
|
|
16354
|
+
{ names: z34.string().describe("Comma-separated list of names to check (e.g. 'vendor_id, compliance_level, formulator_type')") },
|
|
16171
16355
|
async ({ names }) => {
|
|
16172
16356
|
const terms = await kernelQuery("chain.listEntries", { collectionSlug: "glossary" });
|
|
16173
16357
|
const glossaryContext = terms.map(
|
|
@@ -16203,7 +16387,7 @@ Format as a table: Name | Status | Canonical Form | Action Needed`
|
|
|
16203
16387
|
server.prompt(
|
|
16204
16388
|
"draft-decision-record",
|
|
16205
16389
|
"Draft a structured decision record from a description of what was decided. Includes context from recent decisions and relevant rules.",
|
|
16206
|
-
{ context:
|
|
16390
|
+
{ context: z34.string().describe("Description of the decision (e.g. 'We decided to use MRSL v3.1 as the conformance baseline because...')") },
|
|
16207
16391
|
async ({ context }) => {
|
|
16208
16392
|
const recentDecisions = await kernelQuery("chain.listEntries", { collectionSlug: "decisions" });
|
|
16209
16393
|
const sorted = [...recentDecisions].sort((a, b) => (b.data?.date ?? "") > (a.data?.date ?? "") ? 1 : -1).slice(0, 5);
|
|
@@ -16241,8 +16425,8 @@ After drafting, I can log it using the capture tool with collection "decisions".
|
|
|
16241
16425
|
"draft-rule-from-context",
|
|
16242
16426
|
"Draft a new business rule from an observation or discovery made while coding. Fetches existing rules for the domain to ensure consistency.",
|
|
16243
16427
|
{
|
|
16244
|
-
observation:
|
|
16245
|
-
domain:
|
|
16428
|
+
observation: z34.string().describe("What you observed or discovered (e.g. 'Suppliers can have multiple org types in Gateway')"),
|
|
16429
|
+
domain: z34.string().describe("Which domain this rule belongs to (e.g. 'Governance & Decision-Making')")
|
|
16246
16430
|
},
|
|
16247
16431
|
async ({ observation, domain }) => {
|
|
16248
16432
|
const allRules = await kernelQuery("chain.listEntries", { collectionSlug: "business-rules" });
|
|
@@ -16518,4 +16702,4 @@ export {
|
|
|
16518
16702
|
createProductBrainServer,
|
|
16519
16703
|
initFeatureFlags
|
|
16520
16704
|
};
|
|
16521
|
-
//# sourceMappingURL=chunk-
|
|
16705
|
+
//# sourceMappingURL=chunk-PEAWB3EE.js.map
|