@lucern/sdk 0.3.0-alpha.0 → 0.3.0-alpha.1

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.
Files changed (61) hide show
  1. package/README.md +33 -21
  2. package/dist/beliefs/index.d.ts +7 -7
  3. package/dist/beliefs/index.js +100 -99
  4. package/dist/beliefs/index.js.map +1 -1
  5. package/dist/beliefsClient.d.ts +14 -29
  6. package/dist/beliefsClient.js +34 -71
  7. package/dist/beliefsClient.js.map +1 -1
  8. package/dist/{client-DAuKnDlx.d.ts → client-B6aWUUwp.d.ts} +25 -20
  9. package/dist/client.d.ts +1 -1
  10. package/dist/client.js +100 -99
  11. package/dist/client.js.map +1 -1
  12. package/dist/contracts/index.js +1 -1
  13. package/dist/contracts/index.js.map +1 -1
  14. package/dist/contracts/workflow-runtime.contract.js +1 -1
  15. package/dist/contracts/workflow-runtime.contract.js.map +1 -1
  16. package/dist/contracts/workflowRuntime.js +1 -1
  17. package/dist/contracts/workflowRuntime.js.map +1 -1
  18. package/dist/contradictions/index.d.ts +1 -1
  19. package/dist/contradictions/index.js +100 -99
  20. package/dist/contradictions/index.js.map +1 -1
  21. package/dist/decisions/index.d.ts +1 -1
  22. package/dist/decisions/index.js +100 -99
  23. package/dist/decisions/index.js.map +1 -1
  24. package/dist/edges/index.d.ts +1 -1
  25. package/dist/edges/index.js +100 -99
  26. package/dist/edges/index.js.map +1 -1
  27. package/dist/evidence/index.d.ts +2 -1
  28. package/dist/evidence/index.js +100 -99
  29. package/dist/evidence/index.js.map +1 -1
  30. package/dist/gatewayFacades.d.ts +18 -6
  31. package/dist/gatewayFacades.js +22 -41
  32. package/dist/gatewayFacades.js.map +1 -1
  33. package/dist/index.d.ts +2 -2
  34. package/dist/index.js +103 -69
  35. package/dist/index.js.map +1 -1
  36. package/dist/lenses/index.d.ts +7 -5
  37. package/dist/lenses/index.js +100 -99
  38. package/dist/lenses/index.js.map +1 -1
  39. package/dist/nodes/index.d.ts +1 -1
  40. package/dist/nodes/index.js +100 -99
  41. package/dist/nodes/index.js.map +1 -1
  42. package/dist/ontologies/index.d.ts +1 -1
  43. package/dist/ontologies/index.js +100 -99
  44. package/dist/ontologies/index.js.map +1 -1
  45. package/dist/opinion.d.ts +2 -2
  46. package/dist/opinion.js +4 -4
  47. package/dist/opinion.js.map +1 -1
  48. package/dist/questions/index.d.ts +1 -1
  49. package/dist/questions/index.js +100 -99
  50. package/dist/questions/index.js.map +1 -1
  51. package/dist/topics/index.d.ts +1 -1
  52. package/dist/topics/index.js +100 -99
  53. package/dist/topics/index.js.map +1 -1
  54. package/dist/types.d.ts +7 -7
  55. package/dist/workflowClient.d.ts +18 -5
  56. package/dist/workflowClient.js +19 -7
  57. package/dist/workflowClient.js.map +1 -1
  58. package/dist/worktrees/index.d.ts +10 -7
  59. package/dist/worktrees/index.js +100 -99
  60. package/dist/worktrees/index.js.map +1 -1
  61. package/package.json +4 -3
@@ -4,7 +4,7 @@ import { HarnessClientConfig, HarnessAgentWriteInput, HarnessInvokeManagedAgentI
4
4
  import { IdentityClientConfig, ClerkUserSearchResult } from './identityClient.js';
5
5
  import { AdminClientConfig, TenantApiKeyRecord, TenantVaultSecretRecord, TenantConfigRecord, TenantModelRoutingSnapshot } from './adminClient.js';
6
6
  import { ControlObjectOwnershipContract } from './controlObjectOwnership.js';
7
- import { BeliefsClientConfig, ModulateConfidenceInput, OpinionHistoryEntry, CreateBeliefInput, RefineBeliefInput, ModulateConfidenceOpinionInput, ModulateConfidenceScalarInput, ForkBeliefInput, UpdateBeliefStatusInput, UpdateBeliefRationaleInput, LinkBeliefsInput, UnlinkBeliefEvidenceInput, UpdateBeliefCriticalityInput, BatchUpdateBeliefCriticalityInput, ReassignBeliefsTopicInput } from './beliefsClient.js';
7
+ import { BeliefsClientConfig, ModulateConfidenceInput, OpinionHistoryEntry, CreateBeliefInput, RefineBeliefInput, ModulateConfidenceOpinionInput, ForkBeliefInput, UpdateBeliefStatusInput, UpdateBeliefRationaleInput, LinkBeliefsInput, UnlinkBeliefEvidenceInput, UpdateBeliefCriticalityInput, BatchUpdateBeliefCriticalityInput, ReassignBeliefsTopicInput } from './beliefsClient.js';
8
8
  import { PacksClientConfig, PackInstallInput, PackEnableInput, PackDisableInput, PackEntitlementInput, PackUninstallInput, PackUpgradeInput } from './packsClient.js';
9
9
  import { CustomToolRegistration, RegisteredCustomTool } from './customTools.js';
10
10
  import { PolicyClientConfig, PermissionDecision, PermissionKind, WritePolicyRecord, WritePolicyCreateInput, WritePolicyUpdateInput, TenantPolicyRecord, TenantPolicyPermission } from './policyClient.js';
@@ -28,7 +28,7 @@ import { WorkflowClientConfig, WorkflowLensPerspectiveType, WorkflowLensStatus,
28
28
  type FunctionSurfaceClientConfig = GatewayClientConfig;
29
29
  type FunctionSurfaceInput = JsonObject;
30
30
  type FunctionSurfaceResult<T = unknown> = Promise<PlatformGatewaySuccess<T>>;
31
- declare const FUNCTION_SURFACE_METHOD_PATHS: readonly ["answers.answerQuestion", "answers.createAnswer", "answers.getAnswer", "beliefs.archiveBelief", "beliefs.bisectConfidence", "beliefs.createBelief", "beliefs.forkBelief", "beliefs.getBelief", "beliefs.getConfidenceHistory", "beliefs.listBeliefs", "beliefs.modulateConfidence", "beliefs.refineBelief", "beliefs.searchBeliefs", "bootstrap.generateSessionHandoff", "coding.getChangeHistory", "coding.getCodeContext", "coding.getFailureLog", "coding.recordAttempt", "context.analyzeTopicDensity", "context.applyAutoBranching", "context.compileContext", "context.discover", "context.discoverEntityConnections", "context.getLatticeCoverage", "context.recordScopeLearning", "context.seedBeliefLattice", "context.triggerBeliefReview", "contracts.createEpistemicContract", "contracts.evaluateContract", "contracts.getContractStatus", "contradictions.flagContradiction", "coordination.broadcastMessage", "coordination.claimFiles", "coordination.endSession", "coordination.getAgentInbox", "coordination.heartbeatSession", "coordination.listActiveSessions", "coordination.registerSession", "coordination.sendAgentMessage", "edges.createEdge", "edges.queryLineage", "evidence.addEvidence", "evidence.createEvidence", "evidence.getEvidence", "evidence.linkEvidence", "evidence.linkEvidenceToBelief", "evidence.linkEvidenceToQuestion", "evidence.listEvidence", "evidence.searchEvidence", "graph.detectConfirmationBias", "graph.findContradictions", "graph.getGraphGaps", "graph.getGraphNeighborhood", "graph.getGraphStructureAnalysis", "graph.getTopicCoverage", "graph.traceEntityImpact", "graph.traverseGraph", "identity.checkPermission", "identity.filterByPermission", "identity.whoami", "judgments.getAuditTrail", "judgments.recordJudgment", "lenses.applyLensToTopic", "lenses.createLens", "lenses.listLenses", "lenses.removeLensFromTopic", "observations.getObservationContext", "observations.ingestObservation", "ontologies.applyOntology", "ontologies.archiveOntology", "ontologies.createOntology", "ontologies.createOntologyVersion", "ontologies.deprecateOntologyVersion", "ontologies.getOntology", "ontologies.listOntologies", "ontologies.matchEntityType", "ontologies.publishOntologyVersion", "ontologies.resolveEffectiveOntology", "ontologies.updateOntology", "policy.manageWritePolicy", "questions.archiveQuestion", "questions.createQuestion", "questions.findMissingQuestions", "questions.getFalsificationQuestions", "questions.getHighPriorityQuestions", "questions.getQuestion", "questions.listQuestions", "questions.refineQuestion", "questions.updateQuestionStatus", "tasks.completeTask", "tasks.createTask", "tasks.listTasks", "tasks.updateTask", "topics.createTopic", "topics.getTopic", "topics.getTopicTree", "topics.listTopics", "topics.updateTopic", "worktrees.activateWorktree", "worktrees.addWorktree", "worktrees.listAllWorktrees", "worktrees.listWorktrees", "worktrees.merge", "worktrees.openPullRequest", "worktrees.pipelineSnapshot", "worktrees.push", "worktrees.updateWorktreeMetadata", "worktrees.updateWorktreeTargets"];
31
+ declare const FUNCTION_SURFACE_METHOD_PATHS: readonly ["answers.answerQuestion", "answers.createAnswer", "answers.getAnswer", "beliefs.archiveBelief", "beliefs.bisectConfidence", "beliefs.createBelief", "beliefs.forkBelief", "beliefs.getBelief", "beliefs.getConfidenceHistory", "beliefs.listBeliefs", "beliefs.modulateConfidence", "beliefs.refineBelief", "beliefs.searchBeliefs", "bootstrap.generateSessionHandoff", "coding.getChangeHistory", "coding.getCodeContext", "coding.getFailureLog", "coding.recordAttempt", "context.analyzeTopicDensity", "context.applyAutoBranching", "context.compileContext", "context.discover", "context.discoverEntityConnections", "context.getLatticeCoverage", "context.recordScopeLearning", "context.seedBeliefLattice", "context.triggerBeliefReview", "contracts.createEpistemicContract", "contracts.evaluateContract", "contracts.getContractStatus", "contradictions.flagContradiction", "coordination.broadcastMessage", "coordination.claimFiles", "coordination.endSession", "coordination.getAgentInbox", "coordination.heartbeatSession", "coordination.listActiveSessions", "coordination.registerSession", "coordination.sendAgentMessage", "edges.createEdge", "edges.queryLineage", "evidence.addEvidence", "evidence.createEvidence", "evidence.getEvidence", "evidence.linkEvidence", "evidence.linkEvidenceToBelief", "evidence.linkEvidenceToQuestion", "evidence.listEvidence", "evidence.searchEvidence", "graph.detectConfirmationBias", "graph.findContradictions", "graph.getGraphGaps", "graph.getGraphNeighborhood", "graph.getGraphStructureAnalysis", "graph.getTopicCoverage", "graph.traceEntityImpact", "graph.traverseGraph", "identity.checkPermission", "identity.filterByPermission", "identity.whoami", "judgments.getAuditTrail", "judgments.recordJudgment", "lenses.applyLensToTopic", "lenses.createLens", "lenses.listLenses", "lenses.removeLensFromTopic", "observations.getObservationContext", "observations.ingestObservation", "ontologies.applyOntology", "ontologies.archiveOntology", "ontologies.createOntology", "ontologies.createOntologyVersion", "ontologies.deprecateOntologyVersion", "ontologies.getOntology", "ontologies.listOntologies", "ontologies.matchEntityType", "ontologies.publishOntologyVersion", "ontologies.resolveEffectiveOntology", "ontologies.updateOntology", "policy.manageWritePolicy", "questions.archiveQuestion", "questions.createQuestion", "questions.findMissingQuestions", "questions.getFalsificationQuestions", "questions.getHighPriorityQuestions", "questions.getQuestion", "questions.listQuestions", "questions.refineQuestion", "questions.updateQuestionStatus", "tasks.completeTask", "tasks.createTask", "tasks.listTasks", "tasks.updateTask", "topics.createTopic", "topics.getTopic", "topics.getTopicTree", "topics.listTopics", "topics.updateTopic", "worktrees.activateWorktree", "worktrees.addWorktree", "worktrees.listAllWorktrees", "worktrees.listCampaigns", "worktrees.listWorktrees", "worktrees.merge", "worktrees.openPullRequest", "worktrees.pipelineSnapshot", "worktrees.push", "worktrees.updateWorktreeMetadata", "worktrees.updateWorktreeTargets"];
32
32
  declare function createFunctionSurfaceClient(config?: FunctionSurfaceClientConfig): {
33
33
  sessionId: string;
34
34
  activateWorktree(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
@@ -102,6 +102,7 @@ declare function createFunctionSurfaceClient(config?: FunctionSurfaceClientConfi
102
102
  listActiveSessions(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
103
103
  listAllWorktrees(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
104
104
  listBeliefs(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
105
+ listCampaigns(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
105
106
  listEvidence(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
106
107
  listLenses(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
107
108
  listOntologies(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
@@ -154,7 +155,7 @@ type BeliefsCompatCreateInput = {
154
155
  rationale?: string;
155
156
  worktreeId?: string;
156
157
  pillar?: string;
157
- baseRate: number;
158
+ baseRate?: number;
158
159
  sourceBeliefIds?: string[];
159
160
  sourceType?: string;
160
161
  beliefType?: string;
@@ -608,6 +609,7 @@ declare function createLucernClient(config?: LucernClientConfig): {
608
609
  content?: string;
609
610
  contentType?: string;
610
611
  kind?: string;
612
+ rationale?: string;
611
613
  supports?: {
612
614
  nodeId: string;
613
615
  weight: number;
@@ -1039,8 +1041,9 @@ declare function createLucernClient(config?: LucernClientConfig): {
1039
1041
  topicId?: string;
1040
1042
  branchId?: string;
1041
1043
  status?: WorkflowWorktreeStatus;
1042
- track?: string;
1043
- executionBand?: number;
1044
+ groupBy?: "campaign" | "lane" | "flat";
1045
+ lane?: string;
1046
+ campaign?: number;
1044
1047
  limit?: number;
1045
1048
  } & TopicIdentifierInput) => Promise<PlatformGatewaySuccess<ListResult<WorkflowWorktreeRecord, "worktrees">>>>[0]): Promise<PlatformGatewaySuccess<{
1046
1049
  [x: string]: unknown;
@@ -1066,8 +1069,9 @@ declare function createLucernClient(config?: LucernClientConfig): {
1066
1069
  }>>;
1067
1070
  listAll(query?: Parameters<(query?: {
1068
1071
  status?: WorkflowWorktreeStatus;
1069
- track?: string;
1070
- executionBand?: number;
1072
+ groupBy?: "campaign" | "lane" | "flat";
1073
+ lane?: string;
1074
+ campaign?: number;
1071
1075
  limit?: number;
1072
1076
  }) => Promise<PlatformGatewaySuccess<ListWorktreesResponse>>>[0]): Promise<PlatformGatewaySuccess<ListWorktreesResponse>>;
1073
1077
  merge(worktreeId: string, input: MergeInput): Promise<PlatformGatewaySuccess<{
@@ -1628,10 +1632,7 @@ declare function createLucernClient(config?: LucernClientConfig): {
1628
1632
  beliefs: {
1629
1633
  createBelief(input: CreateBeliefInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<PlatformBeliefRecord>>;
1630
1634
  refineBelief(beliefId: string, input: RefineBeliefInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<PlatformBeliefRecord>>;
1631
- modulateConfidence: {
1632
- (beliefId: string, input: ModulateConfidenceOpinionInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<ModulateConfidenceResponse>>;
1633
- (beliefId: string, input: ModulateConfidenceScalarInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<ModulateConfidenceResponse>>;
1634
- };
1635
+ modulateConfidence: (beliefId: string, input: ModulateConfidenceOpinionInput, idempotencyKey?: string) => Promise<PlatformGatewaySuccess<ModulateConfidenceResponse>>;
1635
1636
  getOpinionHistory(beliefId: string): Promise<OpinionHistoryEntry[]>;
1636
1637
  getConfidenceHistory(beliefId: string): Promise<OpinionHistoryEntry[]>;
1637
1638
  forkBelief(beliefId: string, input: ForkBeliefInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<ForkBeliefResponse>>;
@@ -1732,16 +1733,23 @@ declare function createLucernClient(config?: LucernClientConfig): {
1732
1733
  topicId?: string;
1733
1734
  branchId?: string;
1734
1735
  status?: WorkflowWorktreeStatus;
1735
- track?: string;
1736
- executionBand?: number;
1736
+ groupBy?: "campaign" | "lane" | "flat";
1737
+ lane?: string;
1738
+ campaign?: number;
1737
1739
  limit?: number;
1738
1740
  } & TopicIdentifierInput): Promise<PlatformGatewaySuccess<ListResult<WorkflowWorktreeRecord, "worktrees">>>;
1739
1741
  listAllWorktrees(query?: {
1740
1742
  status?: WorkflowWorktreeStatus;
1741
- track?: string;
1742
- executionBand?: number;
1743
+ groupBy?: "campaign" | "lane" | "flat";
1744
+ lane?: string;
1745
+ campaign?: number;
1743
1746
  limit?: number;
1744
1747
  }): Promise<PlatformGatewaySuccess<ListWorktreesResponse>>;
1748
+ listCampaigns(query?: {
1749
+ topicId?: string;
1750
+ status?: WorkflowWorktreeStatus;
1751
+ limit?: number;
1752
+ } & TopicIdentifierInput): Promise<PlatformGatewaySuccess<Record<string, unknown>>>;
1745
1753
  createWorktree(input: AddWorktreeInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<WorkflowWorktreeRecord>>;
1746
1754
  addWorktree(input: AddWorktreeInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<WorkflowWorktreeRecord>>;
1747
1755
  merge(worktreeId: string, input: MergeInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<MergeWorktreeResponse>>;
@@ -2334,6 +2342,7 @@ declare function createLucernClient(config?: LucernClientConfig): {
2334
2342
  listActiveSessions(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
2335
2343
  listAllWorktrees(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
2336
2344
  listBeliefs(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
2345
+ listCampaigns(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
2337
2346
  listEvidence(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
2338
2347
  listLenses(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
2339
2348
  listOntologies(input?: FunctionSurfaceInput, idempotencyKey?: string): FunctionSurfaceResult<unknown>;
@@ -2444,11 +2453,7 @@ declare function createLucernClient(config?: LucernClientConfig): {
2444
2453
  invokeManagedAgentDefinition(agentId: string, input: Omit<HarnessInvokeManagedAgentInput, "agentDefinitionId">, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
2445
2454
  listAgentRuns(agentId: string, scope?: GatewayScope & {
2446
2455
  status?: string;
2447
- limit? /**
2448
- * Optional Clerk JWT for per-user identity and RBAC.
2449
- * When present, the SDK operates in user-scoped mode with
2450
- * pack-aware tool filtering. When absent, operates in agent mode.
2451
- */: number;
2456
+ limit?: number;
2452
2457
  cursor?: string;
2453
2458
  }): Promise<PlatformGatewaySuccess<ListResult<any, "runs">>>;
2454
2459
  listRunsForAgent(agentId: string, scope?: GatewayScope & {
package/dist/client.d.ts CHANGED
@@ -14,7 +14,7 @@ import './contextTypes.js';
14
14
  import './topicsClient.js';
15
15
  import './answersClient.js';
16
16
  import './auditClient.js';
17
- export { L as LucernClientConfig, c as createLucernClient } from './client-DAuKnDlx.js';
17
+ export { L as LucernClientConfig, c as createLucernClient } from './client-B6aWUUwp.js';
18
18
  import './contextClient.js';
19
19
  import './contracts/lens-workflow.contract.js';
20
20
  import './decisionsClient.js';
package/dist/client.js CHANGED
@@ -997,38 +997,6 @@ function createAuditClient(config = {}) {
997
997
  };
998
998
  }
999
999
 
1000
- // src/opinion.ts
1001
- function clamp01(value) {
1002
- if (!Number.isFinite(value)) {
1003
- return 0;
1004
- }
1005
- return Math.max(0, Math.min(1, value));
1006
- }
1007
- function vacuous(baseRate = 0.5) {
1008
- return { b: 0, d: 0, u: 1, a: clamp01(baseRate) };
1009
- }
1010
- function dogmatic(probability, baseRate = 0.5) {
1011
- const p = clamp01(probability);
1012
- return { b: p, d: 1 - p, u: 0, a: clamp01(baseRate) };
1013
- }
1014
- function opinionFromBaseRate(probability) {
1015
- return vacuous(clamp01(probability));
1016
- }
1017
- function opinionFromDogmatic(probability, baseRate = 0.5) {
1018
- return dogmatic(clamp01(probability), clamp01(baseRate));
1019
- }
1020
- function opinionFromProjected(probability, uncertainty, baseRate = 0.5) {
1021
- const p = clamp01(probability);
1022
- const u = clamp01(uncertainty);
1023
- const remainingMass = 1 - u;
1024
- return {
1025
- b: p * remainingMass,
1026
- d: (1 - p) * remainingMass,
1027
- u,
1028
- a: clamp01(baseRate)
1029
- };
1030
- }
1031
-
1032
1000
  // src/beliefsClient.ts
1033
1001
  function asRecord2(value) {
1034
1002
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
@@ -1043,7 +1011,7 @@ function readString(value) {
1043
1011
  function readNumber(value) {
1044
1012
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
1045
1013
  }
1046
- function clamp012(value) {
1014
+ function clamp01(value) {
1047
1015
  return Math.max(0, Math.min(1, value));
1048
1016
  }
1049
1017
  function normalizeOpinionTuple(record) {
@@ -1052,20 +1020,16 @@ function normalizeOpinionTuple(record) {
1052
1020
  const rawDisbelief = readNumber(opinion.d) ?? readNumber(record.disbelief);
1053
1021
  const rawUncertainty = readNumber(opinion.u) ?? readNumber(record.uncertainty);
1054
1022
  const rawBaseRate = readNumber(opinion.a) ?? readNumber(record.baseRate);
1055
- if (rawBelief === void 0 && rawDisbelief === void 0 && rawUncertainty === void 0) {
1056
- const projected = clamp012(readNumber(record.confidence) ?? 0);
1057
- return {
1058
- b: projected,
1059
- d: 1 - projected,
1060
- u: 0,
1061
- a: 0.5
1062
- };
1023
+ if (rawBelief === void 0 || rawDisbelief === void 0 || rawUncertainty === void 0 || rawBaseRate === void 0) {
1024
+ throw new Error(
1025
+ "Gateway opinion history entries must include belief, disbelief, uncertainty, and baseRate."
1026
+ );
1063
1027
  }
1064
1028
  return {
1065
- b: clamp012(rawBelief ?? 0),
1066
- d: clamp012(rawDisbelief ?? 0),
1067
- u: clamp012(rawUncertainty ?? 0),
1068
- a: clamp012(rawBaseRate ?? 0.5)
1029
+ b: clamp01(rawBelief),
1030
+ d: clamp01(rawDisbelief),
1031
+ u: clamp01(rawUncertainty),
1032
+ a: clamp01(rawBaseRate)
1069
1033
  };
1070
1034
  }
1071
1035
  function mapOpinionHistoryEntriesFromGatewayData(payload) {
@@ -1073,28 +1037,28 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
1073
1037
  return entries.map((value) => {
1074
1038
  const record = asRecord2(value);
1075
1039
  const tuple = normalizeOpinionTuple(record);
1076
- const projected = readNumber(record.confidence) ?? clamp012(tuple.b + tuple.a * tuple.u);
1040
+ const projected = readNumber(record.confidence) ?? clamp01(tuple.b + tuple.a * tuple.u);
1077
1041
  const triggeringEvidenceId = readString(record.triggeringEvidenceId);
1042
+ const triggeringQuestionId = readString(record.triggeringQuestionId);
1043
+ const triggeringAnswerId = readString(record.triggeringAnswerId);
1044
+ const triggeringContradictionId = readString(
1045
+ record.triggeringContradictionId
1046
+ );
1078
1047
  const triggeringWorktreeId = readString(record.triggeringWorktreeId);
1048
+ const triggeringRef = triggeringEvidenceId ? { kind: "evidence", id: triggeringEvidenceId } : triggeringQuestionId ? { kind: "question", id: triggeringQuestionId } : triggeringAnswerId ? { kind: "answer", id: triggeringAnswerId } : triggeringContradictionId ? { kind: "contradiction", id: triggeringContradictionId } : triggeringWorktreeId ? { kind: "worktree", id: triggeringWorktreeId } : void 0;
1049
+ const trigger = readString(record.trigger);
1050
+ if (!trigger) {
1051
+ throw new Error("Gateway opinion history entries must include trigger.");
1052
+ }
1079
1053
  return {
1080
1054
  t: readNumber(record.timestamp) ?? readNumber(record.assessedAt) ?? 0,
1081
1055
  b: tuple.b,
1082
1056
  d: tuple.d,
1083
1057
  u: tuple.u,
1084
1058
  a: tuple.a,
1085
- P: clamp012(projected),
1086
- trigger: readString(record.trigger) ?? "manual",
1087
- ...triggeringEvidenceId ? {
1088
- triggeringRef: {
1089
- kind: "evidence",
1090
- id: triggeringEvidenceId
1091
- }
1092
- } : triggeringWorktreeId ? {
1093
- triggeringRef: {
1094
- kind: "worktree",
1095
- id: triggeringWorktreeId
1096
- }
1097
- } : {},
1059
+ P: clamp01(projected),
1060
+ trigger,
1061
+ ...triggeringRef ? { triggeringRef } : {},
1098
1062
  ...readString(record.rationale) ? { rationale: readString(record.rationale) } : {},
1099
1063
  ...readString(record.userId) ? { userId: readString(record.userId) } : {},
1100
1064
  ...readString(record.slOperator) ? { slOperator: readString(record.slOperator) } : {}
@@ -1102,11 +1066,7 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
1102
1066
  }).sort((left, right) => left.t - right.t);
1103
1067
  }
1104
1068
  function normalizeModulateConfidenceInput(input) {
1105
- const opinion = "opinion" in input ? input.opinion : input.interpretation === "base_rate" ? opinionFromBaseRate(input.confidence) : input.interpretation === "dogmatic" ? opinionFromDogmatic(input.confidence, input.baseRate) : opinionFromProjected(
1106
- input.confidence,
1107
- input.uncertainty,
1108
- input.baseRate
1109
- );
1069
+ const opinion = input.opinion;
1110
1070
  return {
1111
1071
  belief: opinion.b,
1112
1072
  disbelief: opinion.d,
@@ -1114,20 +1074,23 @@ function normalizeModulateConfidenceInput(input) {
1114
1074
  baseRate: opinion.a,
1115
1075
  trigger: input.trigger,
1116
1076
  rationale: input.rationale,
1077
+ triggeringEvidenceId: input.triggeringEvidenceId,
1078
+ triggeringQuestionId: input.triggeringQuestionId,
1079
+ triggeringAnswerId: input.triggeringAnswerId,
1080
+ triggeringContradictionId: input.triggeringContradictionId,
1081
+ triggeringWorktreeId: input.triggeringWorktreeId,
1117
1082
  maxInlinePropagationTargets: input.maxInlinePropagationTargets
1118
1083
  };
1119
1084
  }
1120
1085
  function createBeliefsClient(config = {}) {
1121
1086
  const gateway = createGatewayRequestClient(config);
1122
- function requireBaseRate2(value) {
1087
+ function normalizeBaseRate(value) {
1123
1088
  const baseRate = readNumber(value);
1124
- if (baseRate === void 0) {
1125
- throw new Error("baseRate is required for belief creation.");
1126
- }
1127
- if (baseRate < 0 || baseRate > 1) {
1089
+ const normalized = baseRate ?? 0.5;
1090
+ if (normalized < 0 || normalized > 1) {
1128
1091
  throw new Error("baseRate must be within [0, 1].");
1129
1092
  }
1130
- return baseRate;
1093
+ return normalized;
1131
1094
  }
1132
1095
  const modulateConfidence = async (beliefId, input, idempotencyKey) => gateway.request({
1133
1096
  path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}/confidence`,
@@ -1146,7 +1109,7 @@ function createBeliefsClient(config = {}) {
1146
1109
  * Create a belief within a topic scope.
1147
1110
  */
1148
1111
  async createBelief(input, idempotencyKey) {
1149
- const baseRate = requireBaseRate2(input.baseRate);
1112
+ const baseRate = normalizeBaseRate(input.baseRate);
1150
1113
  return gateway.request({
1151
1114
  path: "/api/platform/v1/beliefs",
1152
1115
  method: "POST",
@@ -2242,11 +2205,7 @@ function createTopicsClient(config = {}) {
2242
2205
 
2243
2206
  // src/gatewayFacades.ts
2244
2207
  function normalizeBeliefConfidenceInput(input) {
2245
- const opinion = "opinion" in input ? input.opinion : input.interpretation === "base_rate" ? opinionFromBaseRate(input.confidence) : input.interpretation === "dogmatic" ? opinionFromDogmatic(input.confidence, input.baseRate) : opinionFromProjected(
2246
- input.confidence,
2247
- input.uncertainty,
2248
- input.baseRate
2249
- );
2208
+ const opinion = input.opinion;
2250
2209
  return {
2251
2210
  belief: opinion.b,
2252
2211
  disbelief: opinion.d,
@@ -2254,6 +2213,11 @@ function normalizeBeliefConfidenceInput(input) {
2254
2213
  baseRate: opinion.a,
2255
2214
  trigger: input.trigger,
2256
2215
  rationale: input.rationale,
2216
+ triggeringEvidenceId: input.triggeringEvidenceId,
2217
+ triggeringQuestionId: input.triggeringQuestionId,
2218
+ triggeringAnswerId: input.triggeringAnswerId,
2219
+ triggeringContradictionId: input.triggeringContradictionId,
2220
+ triggeringWorktreeId: input.triggeringWorktreeId,
2257
2221
  maxInlinePropagationTargets: input.maxInlinePropagationTargets
2258
2222
  };
2259
2223
  }
@@ -2993,6 +2957,18 @@ function createWorktreesFacade(config = {}) {
2993
2957
  async list(query) {
2994
2958
  return gateway.request({
2995
2959
  path: `/api/platform/v1/worktrees${toQueryString({
2960
+ topicId: query.topicId,
2961
+ status: query.status,
2962
+ groupBy: query.groupBy,
2963
+ lane: query.lane,
2964
+ campaign: query.campaign,
2965
+ limit: query.limit
2966
+ })}`
2967
+ });
2968
+ },
2969
+ async listCampaigns(query = {}) {
2970
+ return gateway.request({
2971
+ path: `/api/platform/v1/worktrees/campaigns${toQueryString({
2996
2972
  topicId: query.topicId,
2997
2973
  status: query.status,
2998
2974
  limit: query.limit
@@ -3015,10 +2991,10 @@ function createWorktreesFacade(config = {}) {
3015
2991
  objective: input.objective,
3016
2992
  hypothesis: input.hypothesis,
3017
2993
  rationale: input.rationale,
3018
- track: input.track,
3019
- trackPosition: input.trackPosition,
3020
- executionBand: input.executionBand,
3021
- executionOrder: input.executionOrder,
2994
+ campaign: input.campaign,
2995
+ lane: input.lane,
2996
+ laneOrderInCampaign: input.laneOrderInCampaign,
2997
+ orderInLane: input.orderInLane,
3022
2998
  dependsOn: input.dependsOn,
3023
2999
  blocks: input.blocks,
3024
3000
  gate: input.gate,
@@ -3684,6 +3660,7 @@ var CONTRACTS = {
3684
3660
  "list_active_sessions": { method: "POST", path: "/coordination/active-sessions", kind: "query", idempotent: false, surfaceIntent: "system" },
3685
3661
  "list_all_worktrees": { method: "GET", path: "/worktrees/all", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
3686
3662
  "list_beliefs": { method: "GET", path: "/beliefs", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
3663
+ "list_campaigns": { method: "GET", path: "/worktrees/campaigns", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
3687
3664
  "list_evidence": { method: "GET", path: "/evidence", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
3688
3665
  "list_lenses": { method: "GET", path: "/lenses", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
3689
3666
  "list_ontologies": { method: "GET", path: "/ontologies", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
@@ -3974,6 +3951,9 @@ function createFunctionSurfaceClient(config = {}) {
3974
3951
  listBeliefs(input = {}, idempotencyKey) {
3975
3952
  return execute("list_beliefs", input, idempotencyKey);
3976
3953
  },
3954
+ listCampaigns(input = {}, idempotencyKey) {
3955
+ return execute("list_campaigns", input, idempotencyKey);
3956
+ },
3977
3957
  listEvidence(input = {}, idempotencyKey) {
3978
3958
  return execute("list_evidence", input, idempotencyKey);
3979
3959
  },
@@ -4785,10 +4765,11 @@ function createWorkflowClient(config = {}) {
4785
4765
  async listWorktrees(query) {
4786
4766
  const normalized = normalizeTopicQuery(query);
4787
4767
  return gateway.request({
4788
- path: `/api/platform/v1/worktrees${toQueryString({
4768
+ path: `/api/platform/v1/worktrees/all${toQueryString({
4789
4769
  ...normalized,
4790
- track: query.track,
4791
- executionBand: query.executionBand
4770
+ groupBy: query.groupBy,
4771
+ lane: query.lane,
4772
+ campaign: query.campaign
4792
4773
  })}`
4793
4774
  }).then(
4794
4775
  (response) => mapGatewayData(
@@ -4807,8 +4788,9 @@ function createWorkflowClient(config = {}) {
4807
4788
  return gateway.request({
4808
4789
  path: `/api/platform/v1/worktrees${toQueryString({
4809
4790
  status: query.status,
4810
- track: query.track,
4811
- executionBand: query.executionBand,
4791
+ groupBy: query.groupBy,
4792
+ lane: query.lane,
4793
+ campaign: query.campaign,
4812
4794
  limit: query.limit
4813
4795
  })}`
4814
4796
  }).then(
@@ -4820,12 +4802,22 @@ function createWorkflowClient(config = {}) {
4820
4802
  );
4821
4803
  return {
4822
4804
  ...list,
4823
- ...record.tracks && typeof record.tracks === "object" && !Array.isArray(record.tracks) ? { tracks: record.tracks } : {},
4824
- ...record.bands && typeof record.bands === "object" && !Array.isArray(record.bands) ? { bands: record.bands } : {}
4805
+ ...record.lanes && typeof record.lanes === "object" && !Array.isArray(record.lanes) ? { lanes: record.lanes } : {},
4806
+ ...record.campaigns && typeof record.campaigns === "object" && !Array.isArray(record.campaigns) ? { campaigns: record.campaigns } : {}
4825
4807
  };
4826
4808
  })
4827
4809
  );
4828
4810
  },
4811
+ /**
4812
+ * List compact pipeline campaigns with nested lanes.
4813
+ */
4814
+ async listCampaigns(query = {}) {
4815
+ return gateway.request({
4816
+ path: `/api/platform/v1/worktrees/campaigns${toQueryString(
4817
+ normalizeTopicQuery(query)
4818
+ )}`
4819
+ });
4820
+ },
4829
4821
  /**
4830
4822
  * Create a workflow worktree.
4831
4823
  */
@@ -5151,13 +5143,11 @@ function requireText(args) {
5151
5143
  return text;
5152
5144
  }
5153
5145
  function requireBaseRate(args) {
5154
- if (typeof args.baseRate !== "number" || !Number.isFinite(args.baseRate)) {
5155
- throw new Error("baseRate is required.");
5156
- }
5157
- if (args.baseRate < 0 || args.baseRate > 1) {
5146
+ const baseRate = typeof args.baseRate === "number" && Number.isFinite(args.baseRate) ? args.baseRate : 0.5;
5147
+ if (baseRate < 0 || baseRate > 1) {
5158
5148
  throw new Error("baseRate must be within [0, 1].");
5159
5149
  }
5160
- return args.baseRate;
5150
+ return baseRate;
5161
5151
  }
5162
5152
  function exposeGatewayData(response) {
5163
5153
  return Object.assign({}, response, response.data);
@@ -5275,9 +5265,13 @@ function createLucernClient(config = {}) {
5275
5265
  if (!text) {
5276
5266
  throw new Error("text is required");
5277
5267
  }
5268
+ const rationale = args.rationale ?? args.supports?.reasoning;
5269
+ if (!rationale) {
5270
+ throw new Error("rationale is required");
5271
+ }
5278
5272
  const metadata = {
5279
5273
  ...args.metadata ?? {},
5280
- ...args.supports?.reasoning ? { rationale: args.supports.reasoning } : {}
5274
+ rationale
5281
5275
  };
5282
5276
  return evidenceFacade.create({
5283
5277
  topicId: resolveTopicId(args),
@@ -5285,6 +5279,7 @@ function createLucernClient(config = {}) {
5285
5279
  source: args.source ?? args.sourceUrl,
5286
5280
  targetId: args.targetId ?? args.supports?.nodeId,
5287
5281
  weight: args.weight ?? args.supports?.weight,
5282
+ rationale,
5288
5283
  metadata: Object.keys(metadata).length > 0 ? metadata : void 0,
5289
5284
  title: args.title,
5290
5285
  content: args.content,
@@ -6115,7 +6110,10 @@ function createLucernClient(config = {}) {
6115
6110
  beliefIds: input.beliefIds,
6116
6111
  autoShape: input.autoShape,
6117
6112
  domainPackId: input.domainPackId,
6118
- executionOrder: input.executionOrder,
6113
+ campaign: input.campaign,
6114
+ lane: input.lane,
6115
+ laneOrderInCampaign: input.laneOrderInCampaign,
6116
+ orderInLane: input.orderInLane,
6119
6117
  dependsOn: input.dependsOn,
6120
6118
  blocks: input.blocks,
6121
6119
  gate: input.gate,
@@ -6134,7 +6132,10 @@ function createLucernClient(config = {}) {
6134
6132
  beliefIds: input.beliefIds,
6135
6133
  autoShape: input.autoShape,
6136
6134
  domainPackId: input.domainPackId,
6137
- executionOrder: input.executionOrder,
6135
+ campaign: input.campaign,
6136
+ lane: input.lane,
6137
+ laneOrderInCampaign: input.laneOrderInCampaign,
6138
+ orderInLane: input.orderInLane,
6138
6139
  dependsOn: input.dependsOn,
6139
6140
  blocks: input.blocks,
6140
6141
  gate: input.gate,
@@ -6162,10 +6163,10 @@ function createLucernClient(config = {}) {
6162
6163
  return worktreesFacade.update({
6163
6164
  id: typeof input.worktreeId === "string" ? input.worktreeId : "",
6164
6165
  hypothesis: typeof input.hypothesis === "string" ? input.hypothesis : void 0,
6165
- track: typeof input.track === "string" ? input.track : void 0,
6166
- trackPosition: typeof input.trackPosition === "number" ? input.trackPosition : void 0,
6167
- executionBand: typeof input.executionBand === "number" ? input.executionBand : void 0,
6168
- executionOrder: typeof input.executionOrder === "number" ? input.executionOrder : void 0,
6166
+ campaign: typeof input.campaign === "number" ? input.campaign : void 0,
6167
+ lane: typeof input.lane === "string" ? input.lane : void 0,
6168
+ laneOrderInCampaign: typeof input.laneOrderInCampaign === "number" ? input.laneOrderInCampaign : void 0,
6169
+ orderInLane: typeof input.orderInLane === "number" ? input.orderInLane : void 0,
6169
6170
  dependsOn,
6170
6171
  blocks,
6171
6172
  gate: typeof input.gate === "string" ? input.gate : void 0