@fenglimg/fabric-shared 2.0.0-rc.28 → 2.0.0-rc.29
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-DXQVLDEB.js → chunk-225L7D4T.js} +35 -13
- package/dist/{chunk-G32HVF7H.js → chunk-Y2YBFL2G.js} +38 -14
- package/dist/i18n/index.js +1 -1
- package/dist/index.d.ts +158 -86
- package/dist/index.js +53 -16
- package/dist/node/mcp-payload-guard.d.ts +3 -1
- package/dist/node/mcp-payload-guard.js +6 -2
- package/dist/schemas/api-contracts.d.ts +132 -77
- package/dist/schemas/api-contracts.js +1 -1
- package/dist/types/index.d.ts +3 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
BOOTSTRAP_CANONICAL,
|
|
3
|
-
BOOTSTRAP_MARKER_BEGIN,
|
|
4
|
-
BOOTSTRAP_MARKER_END,
|
|
5
|
-
BOOTSTRAP_REGEX,
|
|
6
|
-
LEGACY_KB_MARKER_BEGIN,
|
|
7
|
-
LEGACY_KB_MARKER_END,
|
|
8
|
-
LEGACY_KB_REGEX
|
|
9
|
-
} from "./chunk-4OQXR6JW.js";
|
|
1
|
+
import "./chunk-LXNCAKJZ.js";
|
|
10
2
|
import {
|
|
11
3
|
PROTECTED_TOKENS,
|
|
12
4
|
createTranslator,
|
|
@@ -16,7 +8,7 @@ import {
|
|
|
16
8
|
normalizeLocale,
|
|
17
9
|
resolveFabricLocale,
|
|
18
10
|
zhCNMessages
|
|
19
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-225L7D4T.js";
|
|
20
12
|
import {
|
|
21
13
|
FabExtractKnowledgeInputSchema,
|
|
22
14
|
FabExtractKnowledgeInputShape,
|
|
@@ -58,8 +50,16 @@ import {
|
|
|
58
50
|
planContextInputSchema,
|
|
59
51
|
planContextOutputSchema,
|
|
60
52
|
structuredWarningSchema
|
|
61
|
-
} from "./chunk-
|
|
62
|
-
import
|
|
53
|
+
} from "./chunk-Y2YBFL2G.js";
|
|
54
|
+
import {
|
|
55
|
+
BOOTSTRAP_CANONICAL,
|
|
56
|
+
BOOTSTRAP_MARKER_BEGIN,
|
|
57
|
+
BOOTSTRAP_MARKER_END,
|
|
58
|
+
BOOTSTRAP_REGEX,
|
|
59
|
+
LEGACY_KB_MARKER_BEGIN,
|
|
60
|
+
LEGACY_KB_MARKER_END,
|
|
61
|
+
LEGACY_KB_REGEX
|
|
62
|
+
} from "./chunk-4OQXR6JW.js";
|
|
63
63
|
|
|
64
64
|
// src/schemas/agents-meta.ts
|
|
65
65
|
import { z } from "zod";
|
|
@@ -79,7 +79,7 @@ var ruleDescriptionSchema = z.object({
|
|
|
79
79
|
entities: z.array(z.string()).optional(),
|
|
80
80
|
// v2.0 knowledge entry fields (TASK-002 schemas). All optional for backward compat.
|
|
81
81
|
id: z.string().optional(),
|
|
82
|
-
knowledge_type: z.enum(["
|
|
82
|
+
knowledge_type: z.enum(["models", "decisions", "guidelines", "pitfalls", "processes"]).optional(),
|
|
83
83
|
maturity: z.enum(["draft", "verified", "proven"]).optional(),
|
|
84
84
|
knowledge_layer: z.enum(["personal", "team"]).optional(),
|
|
85
85
|
layer_reason: z.string().optional(),
|
|
@@ -319,6 +319,7 @@ var mcpPayloadLimitsSchema = z5.object({
|
|
|
319
319
|
warnBytes: z5.number().int().positive().optional(),
|
|
320
320
|
hardBytes: z5.number().int().positive().optional()
|
|
321
321
|
}).optional();
|
|
322
|
+
var selectionTokenTtlMsSchema = z5.number().int().min(3e4).max(36e5);
|
|
322
323
|
var fabricLanguageSchema = z5.enum([
|
|
323
324
|
"match-existing",
|
|
324
325
|
"zh-CN",
|
|
@@ -484,7 +485,23 @@ var fabricConfigSchema = z5.object({
|
|
|
484
485
|
//
|
|
485
486
|
// Default `[]` keeps the field optional on existing configs — fresh
|
|
486
487
|
// installs land with no opt-outs.
|
|
487
|
-
onboard_slots_opted_out: z5.array(z5.string()).optional().default([])
|
|
488
|
+
onboard_slots_opted_out: z5.array(z5.string()).optional().default([]),
|
|
489
|
+
// v2.0.0-rc.29 TASK-008 (BUG-F3): selection-token TTL override. The
|
|
490
|
+
// `fab_plan_context` MCP tool hands clients a `selection_token` whose default
|
|
491
|
+
// 5-minute lifetime (`SELECTION_TOKEN_TTL_MS` at
|
|
492
|
+
// packages/server/src/services/plan-context.ts:91) was hard-coded and could
|
|
493
|
+
// not be tuned for slow review cycles. Operators on long-running sessions
|
|
494
|
+
// (manual paste-and-review flows, debugger pauses, etc.) reported tokens
|
|
495
|
+
// expiring mid-review. Override here; absence means "use the library default
|
|
496
|
+
// of 5*60*1000 ms." Range 30s..1h keeps the value useful — below 30s the
|
|
497
|
+
// token expires before MCP round-trips finish; above 1h it stops being a
|
|
498
|
+
// meaningful liveness signal for the plan-context cache.
|
|
499
|
+
//
|
|
500
|
+
// The single-field schema is exported separately (`selectionTokenTtlMsSchema`)
|
|
501
|
+
// so the server-side per-field reader can validate without re-running the
|
|
502
|
+
// whole fabricConfigSchema on every plan_context call — that lets a corrupt
|
|
503
|
+
// unrelated field stay isolated from the hot read path.
|
|
504
|
+
selection_token_ttl_ms: selectionTokenTtlMsSchema.optional()
|
|
488
505
|
});
|
|
489
506
|
|
|
490
507
|
// src/schemas/fabric-config-introspect.ts
|
|
@@ -875,6 +892,13 @@ var reapplyCompletedEventSchema = z10.object({
|
|
|
875
892
|
preserved_meta: z10.boolean(),
|
|
876
893
|
rules_count: z10.number().int().nonnegative()
|
|
877
894
|
});
|
|
895
|
+
var installDiffAppliedEventSchema = z10.object({
|
|
896
|
+
...eventLedgerEnvelopeSchema,
|
|
897
|
+
event_type: z10.literal("install_diff_applied"),
|
|
898
|
+
applied: z10.array(z10.string()),
|
|
899
|
+
canonical: z10.array(z10.string()),
|
|
900
|
+
drifted: z10.array(z10.string())
|
|
901
|
+
});
|
|
878
902
|
var eventLedgerTruncatedEventSchema = z10.object({
|
|
879
903
|
...eventLedgerEnvelopeSchema,
|
|
880
904
|
event_type: z10.literal("event_ledger_truncated"),
|
|
@@ -919,7 +943,17 @@ var metaReconciledEventSchema = z10.object({
|
|
|
919
943
|
// `fab_review` write-actions can flush newly-promoted entries into
|
|
920
944
|
// `agents.meta.json.nodes[id]` synchronously — without this the new entry
|
|
921
945
|
// remains description-less until the next plan_context auto-heal.
|
|
922
|
-
|
|
946
|
+
// v2.0.0-rc.29 TASK-005 (BUG-G1): `auto-heal-after-drift` added so
|
|
947
|
+
// `ensureKnowledgeFresh` hot-path can chain a paired reconcile (closing the
|
|
948
|
+
// drift→heal gap) when the caller opts in via `autoHealOnDrift: true`.
|
|
949
|
+
trigger: z10.enum([
|
|
950
|
+
"doctor",
|
|
951
|
+
"manual",
|
|
952
|
+
"auto-heal-description",
|
|
953
|
+
"auto-heal-after-drift",
|
|
954
|
+
"post-approve",
|
|
955
|
+
"post-modify"
|
|
956
|
+
]),
|
|
923
957
|
source: z10.literal("reconcileKnowledge"),
|
|
924
958
|
// v2.0.0-rc.22 TASK-014 (Scope E): set when reconcileKnowledge forced a
|
|
925
959
|
// writeKnowledgeMeta on revision drift alone (no per-file content drift).
|
|
@@ -1145,7 +1179,7 @@ var knowledgeEnrichedEventSchema = z10.object({
|
|
|
1145
1179
|
event_type: z10.literal("knowledge_enriched"),
|
|
1146
1180
|
path: z10.string(),
|
|
1147
1181
|
added_fields: z10.array(z10.enum(["intent_clues", "tech_stack", "impact", "must_read_if"])),
|
|
1148
|
-
mode: z10.enum(["auto", "interactive"]),
|
|
1182
|
+
mode: z10.enum(["auto", "preview", "readonly", "interactive"]),
|
|
1149
1183
|
timestamp: z10.string().datetime()
|
|
1150
1184
|
});
|
|
1151
1185
|
var sessionArchiveAttemptedEventSchema = z10.object({
|
|
@@ -1164,6 +1198,7 @@ var eventLedgerEventSchema = z10.discriminatedUnion("event_type", [
|
|
|
1164
1198
|
knowledgeDriftDetectedEventSchema,
|
|
1165
1199
|
mcpEventLedgerEventSchema,
|
|
1166
1200
|
reapplyCompletedEventSchema,
|
|
1201
|
+
installDiffAppliedEventSchema,
|
|
1167
1202
|
eventLedgerTruncatedEventSchema,
|
|
1168
1203
|
mcpConfigMigratedEventSchema,
|
|
1169
1204
|
// v2.0.0-rc.19 TASK-004: bootstrap_marker_migrated — one-time fabric:knowledge-base
|
|
@@ -1426,6 +1461,7 @@ export {
|
|
|
1426
1461
|
initContextSchema,
|
|
1427
1462
|
initContextSourceEvidenceSchema,
|
|
1428
1463
|
initScanCompletedEventSchema,
|
|
1464
|
+
installDiffAppliedEventSchema,
|
|
1429
1465
|
isKnowledgeStableId,
|
|
1430
1466
|
knowledgeArchiveAttemptedEventSchema,
|
|
1431
1467
|
knowledgeArchivedEventSchema,
|
|
@@ -1480,6 +1516,7 @@ export {
|
|
|
1480
1516
|
resolveFabricLocale,
|
|
1481
1517
|
ruleDescriptionIndexItemSchema,
|
|
1482
1518
|
ruleDescriptionSchema,
|
|
1519
|
+
selectionTokenTtlMsSchema,
|
|
1483
1520
|
serveLockClearedEventSchema,
|
|
1484
1521
|
sessionArchiveAttemptedEventSchema,
|
|
1485
1522
|
structuredWarningSchema,
|
|
@@ -11,6 +11,8 @@ interface PayloadGuardResult {
|
|
|
11
11
|
threshold: number;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
+
declare const PAYLOAD_LIMIT_DEFAULT_WARN_BYTES = 16384;
|
|
15
|
+
declare const PAYLOAD_LIMIT_DEFAULT_HARD_BYTES = 65536;
|
|
14
16
|
declare function enforcePayloadLimit(serializedPayload: string, opts?: PayloadGuardOptions): PayloadGuardResult;
|
|
15
17
|
|
|
16
|
-
export { type PayloadGuardOptions, type PayloadGuardResult, enforcePayloadLimit };
|
|
18
|
+
export { PAYLOAD_LIMIT_DEFAULT_HARD_BYTES, PAYLOAD_LIMIT_DEFAULT_WARN_BYTES, type PayloadGuardOptions, type PayloadGuardResult, enforcePayloadLimit };
|
|
@@ -7,8 +7,10 @@ var McpPayloadTooLargeError = class extends MCPError {
|
|
|
7
7
|
code = "MCP_PAYLOAD_TOO_LARGE";
|
|
8
8
|
httpStatus = 413;
|
|
9
9
|
};
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var PAYLOAD_LIMIT_DEFAULT_WARN_BYTES = 16384;
|
|
11
|
+
var PAYLOAD_LIMIT_DEFAULT_HARD_BYTES = 65536;
|
|
12
|
+
var DEFAULT_WARN = PAYLOAD_LIMIT_DEFAULT_WARN_BYTES;
|
|
13
|
+
var DEFAULT_HARD = PAYLOAD_LIMIT_DEFAULT_HARD_BYTES;
|
|
12
14
|
function enforcePayloadLimit(serializedPayload, opts) {
|
|
13
15
|
const warnAt = opts?.warnBytes ?? DEFAULT_WARN;
|
|
14
16
|
const hardAt = opts?.hardBytes ?? DEFAULT_HARD;
|
|
@@ -36,5 +38,7 @@ function enforcePayloadLimit(serializedPayload, opts) {
|
|
|
36
38
|
return { bytes };
|
|
37
39
|
}
|
|
38
40
|
export {
|
|
41
|
+
PAYLOAD_LIMIT_DEFAULT_HARD_BYTES,
|
|
42
|
+
PAYLOAD_LIMIT_DEFAULT_WARN_BYTES,
|
|
39
43
|
enforcePayloadLimit
|
|
40
44
|
};
|