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