@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.
package/dist/outbox.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,
@@ -10439,6 +10517,20 @@ async function emitDomainEvent(invokeMutation, input) {
10439
10517
  return await invokeMutation("events:recordEvent", input);
10440
10518
  }
10441
10519
 
10520
+ // ../contracts/src/ids.contract.ts
10521
+ var PREFIXED_ID_PATTERN = /^([a-z][a-z0-9]*)_(.+)$/;
10522
+ function decodePrefixedId(id) {
10523
+ const normalized = id.trim();
10524
+ const match = PREFIXED_ID_PATTERN.exec(normalized);
10525
+ if (!match) {
10526
+ throw new Error(`Invalid prefixed ID: ${id}`);
10527
+ }
10528
+ return {
10529
+ prefix: match[1],
10530
+ value: match[2]
10531
+ };
10532
+ }
10533
+
10442
10534
  // ../contracts/src/schema-helpers/spine/tables/epistemicNodes.ts
10443
10535
  var NODE_TYPES = [
10444
10536
  "decision",
@@ -11601,15 +11693,57 @@ function isRecord(value) {
11601
11693
  function recordValue(value) {
11602
11694
  return isRecord(value) ? value : {};
11603
11695
  }
11696
+ function normalizeTopicIdForKernel(topicId) {
11697
+ const normalized = topicId?.trim();
11698
+ if (!normalized) {
11699
+ return void 0;
11700
+ }
11701
+ try {
11702
+ const decoded = decodePrefixedId(normalized);
11703
+ return decoded.prefix === "top" ? decoded.value : normalized;
11704
+ } catch {
11705
+ return normalized;
11706
+ }
11707
+ }
11708
+ function normalizeWorktreeId(value) {
11709
+ const normalized = value?.trim();
11710
+ if (!normalized) {
11711
+ return void 0;
11712
+ }
11713
+ if (normalized.startsWith("wt_")) {
11714
+ return normalized.slice("wt_".length);
11715
+ }
11716
+ return normalized;
11717
+ }
11718
+ function targetKind(targetId) {
11719
+ const normalized = targetId?.trim();
11720
+ if (!normalized) {
11721
+ return "unknown";
11722
+ }
11723
+ if (normalized.startsWith("wt_") || /^tn[a-z0-9]+$/i.test(normalized)) {
11724
+ return "worktree";
11725
+ }
11726
+ if (normalized.startsWith("que_")) {
11727
+ return "question";
11728
+ }
11729
+ if (normalized.startsWith("bel_")) {
11730
+ return "belief";
11731
+ }
11732
+ return "unknown";
11733
+ }
11604
11734
  var createEvidenceProjection = defineProjection({
11605
11735
  contractName: "create_evidence",
11606
11736
  inputSchema: createEvidenceInputSchema,
11607
11737
  project: (input) => {
11608
11738
  const text = input.text ?? input.canonicalText;
11609
11739
  const weight = typeof input.weight === "number" ? input.weight : void 0;
11740
+ const target = input.targetId ?? input.targetNodeId;
11741
+ const kind = targetKind(target);
11742
+ const linkedWorktreeId = kind === "worktree" ? normalizeWorktreeId(target) : void 0;
11743
+ const linkedBeliefNodeId = input.linkedBeliefNodeId ?? (kind === "belief" || kind === "unknown" ? input.targetNodeId ?? input.targetId : void 0);
11610
11744
  return compactRecord({
11611
11745
  projectId: input.projectId,
11612
- topicId: input.topicId,
11746
+ topicId: normalizeTopicIdForKernel(input.topicId),
11613
11747
  text,
11614
11748
  title: input.title ?? text,
11615
11749
  content: input.content ?? text,
@@ -11628,11 +11762,13 @@ var createEvidenceProjection = defineProjection({
11628
11762
  source: input.source,
11629
11763
  targetId: input.targetId,
11630
11764
  targetNodeId: input.targetNodeId,
11765
+ targetKind: kind === "unknown" ? void 0 : kind,
11766
+ linkedWorktreeId,
11631
11767
  weight,
11632
11768
  reasoning: input.reasoning,
11633
11769
  rationale: input.rationale
11634
11770
  }),
11635
- linkedBeliefNodeId: input.linkedBeliefNodeId ?? input.targetNodeId ?? input.targetId,
11771
+ linkedBeliefNodeId,
11636
11772
  evidenceRelation: input.evidenceRelation ?? (weight === void 0 ? void 0 : weight < 0 ? "contradicts" : "supports"),
11637
11773
  confidence: input.confidence ?? (weight === void 0 ? void 0 : Math.min(1, Math.max(0, Math.abs(weight)))),
11638
11774
  rationale: input.rationale,
@@ -11935,6 +12071,7 @@ function entries(names, surfaceClass, surfaceIntent, surfaces, rationale) {
11935
12071
  );
11936
12072
  }
11937
12073
  var MCP_CORE_OPERATION_NAMES = [
12074
+ "lucern_orient",
11938
12075
  "compile_context",
11939
12076
  "identity_whoami",
11940
12077
  "resolve_interactive_principal",
@@ -12563,6 +12700,14 @@ var observationContextArgs = z.object({
12563
12700
  limit: z.number().optional().describe("Maximum observations to return."),
12564
12701
  status: z.string().optional().describe("Observation status filter.")
12565
12702
  });
12703
+ var lucernOrientArgs = z.object({
12704
+ audience: z.enum(["agent", "human", "operator", "developer"]).optional().describe("Audience for the orientation primer."),
12705
+ depth: z.enum(["quick", "standard", "deep"]).optional().describe("How much orientation detail to include."),
12706
+ situation: z.string().optional().describe("Optional task or query context for suggested next calls."),
12707
+ includeExamples: z.boolean().optional().describe("Include concrete tool-call examples."),
12708
+ includeToolMap: z.boolean().optional().describe("Include situation-to-tool routing guidance."),
12709
+ includeFuture: z.boolean().optional().describe("Include future training and pedagogy capabilities.")
12710
+ });
12566
12711
  function isRecord2(value) {
12567
12712
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
12568
12713
  }
@@ -12590,6 +12735,20 @@ var observationInput = (input, context) => withUserId(
12590
12735
  context
12591
12736
  );
12592
12737
  var contextContracts = [
12738
+ surfaceContract({
12739
+ name: "lucern_orient",
12740
+ kind: "query",
12741
+ domain: "context",
12742
+ surfaceClass: "platform_public",
12743
+ path: "/context/orient",
12744
+ sdkNamespace: "context",
12745
+ sdkMethod: "lucernOrient",
12746
+ summary: "Return the canonical Lucern operator orientation primer.",
12747
+ gateway: {
12748
+ handler: "context.lucernOrient"
12749
+ },
12750
+ args: lucernOrientArgs
12751
+ }),
12593
12752
  surfaceContract({
12594
12753
  name: "compile_context",
12595
12754
  kind: "query",
@@ -13009,7 +13168,7 @@ var createEvidenceArgs = z.object({
13009
13168
  text: z.string().describe("Canonical evidence text."),
13010
13169
  source: z.string().optional().describe("Source URL or source label."),
13011
13170
  sourceUrl: z.string().optional().describe("Canonical source URL."),
13012
- targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
13171
+ targetId: z.string().optional().describe("Belief, question, or worktree identifier to link or preserve on the evidence record."),
13013
13172
  linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
13014
13173
  evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
13015
13174
  confidence: z.number().optional().describe("Confidence in the evidence relation."),
@@ -13042,11 +13201,6 @@ var addEvidenceArgs = z.object({
13042
13201
  contentType: z.string().optional().describe("Content format or MIME hint."),
13043
13202
  metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
13044
13203
  });
13045
- var evidenceIdInput = (input) => compactRecord4({
13046
- evidenceId: input.evidenceId,
13047
- insightId: input.insightId,
13048
- nodeId: input.nodeId ?? input.id ?? input.evidenceId
13049
- });
13050
13204
  var createEvidenceInput = (input, context) => {
13051
13205
  const parsed = createEvidenceProjection.inputSchema.safeParse(input);
13052
13206
  if (!parsed.success) {
@@ -13160,11 +13314,8 @@ var evidenceContracts = [
13160
13314
  sdkNamespace: "evidence",
13161
13315
  sdkMethod: "getEvidence",
13162
13316
  summary: "Get evidence.",
13163
- convex: {
13164
- module: "evidence",
13165
- functionName: "getById",
13166
- kind: "query",
13167
- inputProjection: evidenceIdInput
13317
+ gateway: {
13318
+ handler: "evidence.get"
13168
13319
  }
13169
13320
  }),
13170
13321
  surfaceContract({
@@ -13190,17 +13341,8 @@ var evidenceContracts = [
13190
13341
  sdkNamespace: "evidence",
13191
13342
  sdkMethod: "searchEvidence",
13192
13343
  summary: "Search evidence.",
13193
- convex: {
13194
- module: "nodes",
13195
- functionName: "search",
13196
- kind: "query",
13197
- inputProjection: (input) => compactRecord4({
13198
- searchQuery: input.searchQuery ?? input.q ?? input.query,
13199
- projectId: input.projectId,
13200
- topicId: input.topicId,
13201
- nodeType: "evidence",
13202
- limit: input.limit
13203
- })
13344
+ gateway: {
13345
+ handler: "evidence.search"
13204
13346
  }
13205
13347
  }),
13206
13348
  surfaceContract({
@@ -13788,10 +13930,8 @@ var topicsContracts = [
13788
13930
  sdkNamespace: "topics",
13789
13931
  sdkMethod: "getTopicGraphSpine",
13790
13932
  summary: "Verify topic nodes and parent-child graph edges.",
13791
- convex: {
13792
- module: "topics",
13793
- functionName: "getTopicGraphSpine",
13794
- kind: "query"
13933
+ gateway: {
13934
+ handler: "topics.graphSpine"
13795
13935
  },
13796
13936
  args: getTopicGraphSpineArgs
13797
13937
  })
@@ -15498,10 +15638,8 @@ var graphContracts = [
15498
15638
  sdkNamespace: "graphAnalysis",
15499
15639
  sdkMethod: "listGraphIntelligenceQueries",
15500
15640
  summary: "List Graph Intelligence query catalog entries.",
15501
- convex: {
15502
- module: "contextCompiler",
15503
- functionName: "listGraphIntelligenceQueries",
15504
- kind: "query"
15641
+ gateway: {
15642
+ handler: "graph.listIntelligenceQueries"
15505
15643
  },
15506
15644
  args: graphIntelligenceCatalogArgs
15507
15645
  }),