@lucern/events 1.0.11 → 1.0.12

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.
@@ -1431,6 +1431,59 @@ var REMOVE_LENS_FROM_TOPIC = {
1431
1431
  tier: "workhorse"
1432
1432
  };
1433
1433
 
1434
+ // ../contracts/src/tool-contracts.context-orientation.ts
1435
+ var LUCERN_ORIENT = {
1436
+ name: "lucern_orient",
1437
+ description: "Load the Lucern reasoning grammar before operating. Like `git help` plus a repository CONTRIBUTING guide for reasoning state - teaches the git-shaped model of topics, campaigns, lanes, worktrees, beliefs, questions, evidence, receipts, gates, and merges.",
1438
+ parameters: {
1439
+ audience: {
1440
+ type: "string",
1441
+ description: "Audience for the primer: agent, human, operator, or developer.",
1442
+ enum: ["agent", "human", "operator", "developer"]
1443
+ },
1444
+ depth: {
1445
+ type: "string",
1446
+ description: "Orientation depth: quick, standard, or deep.",
1447
+ enum: ["quick", "standard", "deep"]
1448
+ },
1449
+ situation: {
1450
+ type: "string",
1451
+ description: "Optional task or query context used to tailor suggested next calls."
1452
+ },
1453
+ includeExamples: {
1454
+ type: "boolean",
1455
+ description: "Whether to include concrete tool-call examples."
1456
+ },
1457
+ includeToolMap: {
1458
+ type: "boolean",
1459
+ description: "Whether to include situation-to-tool routing guidance."
1460
+ },
1461
+ includeFuture: {
1462
+ type: "boolean",
1463
+ description: "Whether to include future exemplar, gauntlet, and training-data capabilities."
1464
+ }
1465
+ },
1466
+ required: [],
1467
+ response: {
1468
+ description: "Canonical operator primer for Lucern's git-shaped reasoning substrate.",
1469
+ fields: {
1470
+ schemaVersion: "string - lucern_orientation.v1",
1471
+ canonicalMentalModel: "object - concise model of Lucern as git-shaped reasoning state",
1472
+ workflow: "array - recommended branch -> investigate -> prove gate -> merge workflow",
1473
+ grammarMap: "array - primitive-to-git-analogy map for topics, campaigns, worktrees, beliefs, questions, evidence, edges, contradictions, and gates",
1474
+ firstMoves: "array - recommended first tools for a cold-start agent",
1475
+ receiptRules: "array - how to interpret candidateCounts, broadening, coverageWarning, and noDefaultGlobalScan",
1476
+ safetyRules: "array - mutation and completion rules that preserve reasoning lineage",
1477
+ toolMap: "array | undefined - situation-to-tool routing map when requested",
1478
+ examples: "array | undefined - concrete tool-call examples when requested",
1479
+ suggestedNextCalls: "array - safe next tool calls for the current situation"
1480
+ }
1481
+ },
1482
+ ownerModule: "reasoning-kernel",
1483
+ ontologyPrimitive: "graph",
1484
+ tier: "showcase"
1485
+ };
1486
+
1434
1487
  // ../contracts/src/tool-contracts.ontology.ts
1435
1488
  var MANAGE_WRITE_POLICY = {
1436
1489
  name: "manage_write_policy",
@@ -3940,10 +3993,34 @@ var COMPILE_CONTEXT = {
3940
3993
  type: "string",
3941
3994
  description: "Optional source kind used as a resolver signal, such as cli, worktree, commit, or docs."
3942
3995
  },
3996
+ campaign: {
3997
+ type: "number",
3998
+ description: "Optional campaign dimension seed. When supplied without topicId, the compiler fans out across all carrier topics for that campaign instead of resolving a single topic."
3999
+ },
4000
+ lane: {
4001
+ type: "string",
4002
+ description: "Optional lane dimension seed. When supplied without topicId, the compiler reads all matching worktrees and their carrier topics."
4003
+ },
4004
+ status: {
4005
+ type: "string",
4006
+ description: "Optional state/status dimension seed for worktrees and graph rows."
4007
+ },
4008
+ principalId: {
4009
+ type: "string",
4010
+ description: "Optional principal seed for work authored, touched, or owned by a human, agent, group, or service principal."
4011
+ },
4012
+ workspaceId: {
4013
+ type: "string",
4014
+ description: "Optional workspace seed used by hosted MCP and SDK clients when compiling tenant-scoped context."
4015
+ },
3943
4016
  budget: {
3944
4017
  type: "number",
3945
4018
  description: "Token budget for prompt injection planning"
3946
4019
  },
4020
+ tokenBudget: {
4021
+ type: "number",
4022
+ description: "Compatibility alias for budget. External MCP clients may send tokenBudget when requesting prompt injection planning."
4023
+ },
3947
4024
  ranking: {
3948
4025
  type: "string",
3949
4026
  description: "Ranking profile for context ordering",
@@ -4634,6 +4711,7 @@ var MCP_TOOL_CONTRACTS = {
4634
4711
  update_worktree_metadata: UPDATE_WORKTREE_METADATA,
4635
4712
  identity_whoami: IDENTITY_WHOAMI,
4636
4713
  resolve_interactive_principal: RESOLVE_INTERACTIVE_PRINCIPAL,
4714
+ lucern_orient: LUCERN_ORIENT,
4637
4715
  compile_context: COMPILE_CONTEXT,
4638
4716
  record_scope_learning: RECORD_SCOPE_LEARNING,
4639
4717
  pipeline_snapshot: PIPELINE_SNAPSHOT,
@@ -10349,6 +10427,20 @@ GRAPH_INTELLIGENCE_QUERIES.map((query) => {
10349
10427
  var WEBHOOK_MAX_ATTEMPTS = 5;
10350
10428
  var WEBHOOK_RETRY_DELAYS_MS = [1e3, 5e3, 3e4, 3e5];
10351
10429
 
10430
+ // ../contracts/src/ids.contract.ts
10431
+ var PREFIXED_ID_PATTERN = /^([a-z][a-z0-9]*)_(.+)$/;
10432
+ function decodePrefixedId(id) {
10433
+ const normalized = id.trim();
10434
+ const match = PREFIXED_ID_PATTERN.exec(normalized);
10435
+ if (!match) {
10436
+ throw new Error(`Invalid prefixed ID: ${id}`);
10437
+ }
10438
+ return {
10439
+ prefix: match[1],
10440
+ value: match[2]
10441
+ };
10442
+ }
10443
+
10352
10444
  // ../contracts/src/schema-helpers/spine/tables/epistemicNodes.ts
10353
10445
  var NODE_TYPES = [
10354
10446
  "decision",
@@ -11511,15 +11603,57 @@ function isRecord(value) {
11511
11603
  function recordValue(value) {
11512
11604
  return isRecord(value) ? value : {};
11513
11605
  }
11606
+ function normalizeTopicIdForKernel(topicId) {
11607
+ const normalized = topicId?.trim();
11608
+ if (!normalized) {
11609
+ return void 0;
11610
+ }
11611
+ try {
11612
+ const decoded = decodePrefixedId(normalized);
11613
+ return decoded.prefix === "top" ? decoded.value : normalized;
11614
+ } catch {
11615
+ return normalized;
11616
+ }
11617
+ }
11618
+ function normalizeWorktreeId(value) {
11619
+ const normalized = value?.trim();
11620
+ if (!normalized) {
11621
+ return void 0;
11622
+ }
11623
+ if (normalized.startsWith("wt_")) {
11624
+ return normalized.slice("wt_".length);
11625
+ }
11626
+ return normalized;
11627
+ }
11628
+ function targetKind(targetId) {
11629
+ const normalized = targetId?.trim();
11630
+ if (!normalized) {
11631
+ return "unknown";
11632
+ }
11633
+ if (normalized.startsWith("wt_") || /^tn[a-z0-9]+$/i.test(normalized)) {
11634
+ return "worktree";
11635
+ }
11636
+ if (normalized.startsWith("que_")) {
11637
+ return "question";
11638
+ }
11639
+ if (normalized.startsWith("bel_")) {
11640
+ return "belief";
11641
+ }
11642
+ return "unknown";
11643
+ }
11514
11644
  var createEvidenceProjection = defineProjection({
11515
11645
  contractName: "create_evidence",
11516
11646
  inputSchema: createEvidenceInputSchema,
11517
11647
  project: (input) => {
11518
11648
  const text = input.text ?? input.canonicalText;
11519
11649
  const weight = typeof input.weight === "number" ? input.weight : void 0;
11650
+ const target = input.targetId ?? input.targetNodeId;
11651
+ const kind = targetKind(target);
11652
+ const linkedWorktreeId = kind === "worktree" ? normalizeWorktreeId(target) : void 0;
11653
+ const linkedBeliefNodeId = input.linkedBeliefNodeId ?? (kind === "belief" || kind === "unknown" ? input.targetNodeId ?? input.targetId : void 0);
11520
11654
  return compactRecord({
11521
11655
  projectId: input.projectId,
11522
- topicId: input.topicId,
11656
+ topicId: normalizeTopicIdForKernel(input.topicId),
11523
11657
  text,
11524
11658
  title: input.title ?? text,
11525
11659
  content: input.content ?? text,
@@ -11538,11 +11672,13 @@ var createEvidenceProjection = defineProjection({
11538
11672
  source: input.source,
11539
11673
  targetId: input.targetId,
11540
11674
  targetNodeId: input.targetNodeId,
11675
+ targetKind: kind === "unknown" ? void 0 : kind,
11676
+ linkedWorktreeId,
11541
11677
  weight,
11542
11678
  reasoning: input.reasoning,
11543
11679
  rationale: input.rationale
11544
11680
  }),
11545
- linkedBeliefNodeId: input.linkedBeliefNodeId ?? input.targetNodeId ?? input.targetId,
11681
+ linkedBeliefNodeId,
11546
11682
  evidenceRelation: input.evidenceRelation ?? (weight === void 0 ? void 0 : weight < 0 ? "contradicts" : "supports"),
11547
11683
  confidence: input.confidence ?? (weight === void 0 ? void 0 : Math.min(1, Math.max(0, Math.abs(weight)))),
11548
11684
  rationale: input.rationale,
@@ -11845,6 +11981,7 @@ function entries(names, surfaceClass, surfaceIntent, surfaces, rationale) {
11845
11981
  );
11846
11982
  }
11847
11983
  var MCP_CORE_OPERATION_NAMES = [
11984
+ "lucern_orient",
11848
11985
  "compile_context",
11849
11986
  "identity_whoami",
11850
11987
  "resolve_interactive_principal",
@@ -12473,6 +12610,14 @@ var observationContextArgs = z.object({
12473
12610
  limit: z.number().optional().describe("Maximum observations to return."),
12474
12611
  status: z.string().optional().describe("Observation status filter.")
12475
12612
  });
12613
+ var lucernOrientArgs = z.object({
12614
+ audience: z.enum(["agent", "human", "operator", "developer"]).optional().describe("Audience for the orientation primer."),
12615
+ depth: z.enum(["quick", "standard", "deep"]).optional().describe("How much orientation detail to include."),
12616
+ situation: z.string().optional().describe("Optional task or query context for suggested next calls."),
12617
+ includeExamples: z.boolean().optional().describe("Include concrete tool-call examples."),
12618
+ includeToolMap: z.boolean().optional().describe("Include situation-to-tool routing guidance."),
12619
+ includeFuture: z.boolean().optional().describe("Include future training and pedagogy capabilities.")
12620
+ });
12476
12621
  function isRecord2(value) {
12477
12622
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
12478
12623
  }
@@ -12500,6 +12645,20 @@ var observationInput = (input, context) => withUserId(
12500
12645
  context
12501
12646
  );
12502
12647
  var contextContracts = [
12648
+ surfaceContract({
12649
+ name: "lucern_orient",
12650
+ kind: "query",
12651
+ domain: "context",
12652
+ surfaceClass: "platform_public",
12653
+ path: "/context/orient",
12654
+ sdkNamespace: "context",
12655
+ sdkMethod: "lucernOrient",
12656
+ summary: "Return the canonical Lucern operator orientation primer.",
12657
+ gateway: {
12658
+ handler: "context.lucernOrient"
12659
+ },
12660
+ args: lucernOrientArgs
12661
+ }),
12503
12662
  surfaceContract({
12504
12663
  name: "compile_context",
12505
12664
  kind: "query",
@@ -12919,7 +13078,7 @@ var createEvidenceArgs = z.object({
12919
13078
  text: z.string().describe("Canonical evidence text."),
12920
13079
  source: z.string().optional().describe("Source URL or source label."),
12921
13080
  sourceUrl: z.string().optional().describe("Canonical source URL."),
12922
- targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
13081
+ targetId: z.string().optional().describe("Belief, question, or worktree identifier to link or preserve on the evidence record."),
12923
13082
  linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
12924
13083
  evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
12925
13084
  confidence: z.number().optional().describe("Confidence in the evidence relation."),
@@ -12952,11 +13111,6 @@ var addEvidenceArgs = z.object({
12952
13111
  contentType: z.string().optional().describe("Content format or MIME hint."),
12953
13112
  metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
12954
13113
  });
12955
- var evidenceIdInput = (input) => compactRecord4({
12956
- evidenceId: input.evidenceId,
12957
- insightId: input.insightId,
12958
- nodeId: input.nodeId ?? input.id ?? input.evidenceId
12959
- });
12960
13114
  var createEvidenceInput = (input, context) => {
12961
13115
  const parsed = createEvidenceProjection.inputSchema.safeParse(input);
12962
13116
  if (!parsed.success) {
@@ -13070,11 +13224,8 @@ var evidenceContracts = [
13070
13224
  sdkNamespace: "evidence",
13071
13225
  sdkMethod: "getEvidence",
13072
13226
  summary: "Get evidence.",
13073
- convex: {
13074
- module: "evidence",
13075
- functionName: "getById",
13076
- kind: "query",
13077
- inputProjection: evidenceIdInput
13227
+ gateway: {
13228
+ handler: "evidence.get"
13078
13229
  }
13079
13230
  }),
13080
13231
  surfaceContract({
@@ -13100,17 +13251,8 @@ var evidenceContracts = [
13100
13251
  sdkNamespace: "evidence",
13101
13252
  sdkMethod: "searchEvidence",
13102
13253
  summary: "Search evidence.",
13103
- convex: {
13104
- module: "nodes",
13105
- functionName: "search",
13106
- kind: "query",
13107
- inputProjection: (input) => compactRecord4({
13108
- searchQuery: input.searchQuery ?? input.q ?? input.query,
13109
- projectId: input.projectId,
13110
- topicId: input.topicId,
13111
- nodeType: "evidence",
13112
- limit: input.limit
13113
- })
13254
+ gateway: {
13255
+ handler: "evidence.search"
13114
13256
  }
13115
13257
  }),
13116
13258
  surfaceContract({
@@ -13698,10 +13840,8 @@ var topicsContracts = [
13698
13840
  sdkNamespace: "topics",
13699
13841
  sdkMethod: "getTopicGraphSpine",
13700
13842
  summary: "Verify topic nodes and parent-child graph edges.",
13701
- convex: {
13702
- module: "topics",
13703
- functionName: "getTopicGraphSpine",
13704
- kind: "query"
13843
+ gateway: {
13844
+ handler: "topics.graphSpine"
13705
13845
  },
13706
13846
  args: getTopicGraphSpineArgs
13707
13847
  })
@@ -15408,10 +15548,8 @@ var graphContracts = [
15408
15548
  sdkNamespace: "graphAnalysis",
15409
15549
  sdkMethod: "listGraphIntelligenceQueries",
15410
15550
  summary: "List Graph Intelligence query catalog entries.",
15411
- convex: {
15412
- module: "contextCompiler",
15413
- functionName: "listGraphIntelligenceQueries",
15414
- kind: "query"
15551
+ gateway: {
15552
+ handler: "graph.listIntelligenceQueries"
15415
15553
  },
15416
15554
  args: graphIntelligenceCatalogArgs
15417
15555
  }),