@lucern/events 0.3.0-alpha.5 → 0.3.0-alpha.7

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
@@ -4824,6 +4824,11 @@ var TENANT_CLIENT_INSTALLABLE_PACKAGES = [
4824
4824
  role: "sdk_dependency",
4825
4825
  directTenantImport: false
4826
4826
  },
4827
+ {
4828
+ packageName: "@lucern/graph-sync",
4829
+ role: "host_addon_runtime",
4830
+ directTenantImport: true
4831
+ },
4827
4832
  {
4828
4833
  packageName: "@lucern/identity",
4829
4834
  role: "component_runtime",
@@ -4943,8 +4948,11 @@ function compactRecord(input) {
4943
4948
  Object.entries(input).filter(([, value]) => value !== void 0)
4944
4949
  );
4945
4950
  }
4951
+ function isRecord(value) {
4952
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4953
+ }
4946
4954
  function recordValue(value) {
4947
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
4955
+ return isRecord(value) ? value : {};
4948
4956
  }
4949
4957
  var createEvidenceProjection = defineProjection({
4950
4958
  contractName: "create_evidence",
@@ -5650,9 +5658,16 @@ var ADD_WORKTREE = {
5650
5658
  },
5651
5659
  projectId: {
5652
5660
  type: "string",
5653
- description: "Legacy topicId alias"
5661
+ description: "Legacy topicId alias or resolver hint"
5662
+ },
5663
+ topicId: {
5664
+ type: "string",
5665
+ description: "Optional topic scope hint for resolver validation"
5666
+ },
5667
+ topicHint: {
5668
+ type: "string",
5669
+ description: "Natural-language topic hint for automatic topic resolution"
5654
5670
  },
5655
- topicId: { type: "string", description: "Optional topic scope hint" },
5656
5671
  branchId: {
5657
5672
  type: "string",
5658
5673
  description: "The branch this worktree investigates"
@@ -5750,6 +5765,22 @@ var ADD_WORKTREE = {
5750
5765
  type: "string",
5751
5766
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
5752
5767
  },
5768
+ tags: {
5769
+ type: "array",
5770
+ description: "Additional topic-resolution tags for the worktree"
5771
+ },
5772
+ touchedPaths: {
5773
+ type: "array",
5774
+ description: "File paths used as topic-resolution signals"
5775
+ },
5776
+ sourceRef: {
5777
+ type: "string",
5778
+ description: "Source reference used as a topic-resolution signal"
5779
+ },
5780
+ sourceKind: {
5781
+ type: "string",
5782
+ description: "Source kind used as a topic-resolution signal"
5783
+ },
5753
5784
  campaign: {
5754
5785
  type: "number",
5755
5786
  description: "Top-level pipeline campaign number. Campaigns define the outer execution slice."
@@ -5787,7 +5818,7 @@ var ADD_WORKTREE = {
5787
5818
  description: "Timestamp when worktree metadata was last reconciled"
5788
5819
  }
5789
5820
  },
5790
- required: ["title", "topicId"],
5821
+ required: ["title"],
5791
5822
  response: {
5792
5823
  description: "The created worktree",
5793
5824
  fields: {
@@ -7490,18 +7521,60 @@ var CREATE_TASK = {
7490
7521
  name: "create_task",
7491
7522
  description: "Create an execution task tied to the reasoning state. Like `git task` \u2014 tracks concrete work items (calls to make, data to gather, analyses to run) linked to questions, beliefs, or worktrees.",
7492
7523
  parameters: {
7493
- title: { type: "string", description: "Task description" },
7524
+ title: { type: "string", description: "Task title" },
7494
7525
  topicId: { type: "string", description: "Topic scope" },
7526
+ description: {
7527
+ type: "string",
7528
+ description: "Long-form task description"
7529
+ },
7495
7530
  taskType: {
7496
7531
  type: "string",
7497
- description: "Type: research, interview, analysis, data_collection",
7498
- enum: ["research", "interview", "analysis", "data_collection"]
7532
+ description: "Task taxonomy",
7533
+ enum: [
7534
+ "general",
7535
+ "find_evidence",
7536
+ "verify_claim",
7537
+ "research",
7538
+ "review",
7539
+ "interview",
7540
+ "analysis",
7541
+ "track_metrics"
7542
+ ]
7543
+ },
7544
+ priority: {
7545
+ type: "string",
7546
+ description: "Priority",
7547
+ enum: ["urgent", "high", "medium", "low"]
7548
+ },
7549
+ status: {
7550
+ type: "string",
7551
+ description: "Initial status (defaults to todo)",
7552
+ enum: ["todo", "in_progress", "blocked", "done"]
7553
+ },
7554
+ linkedWorktreeId: {
7555
+ type: "string",
7556
+ description: "Worktree this task belongs to"
7557
+ },
7558
+ linkedBeliefId: {
7559
+ type: "string",
7560
+ description: "Belief this task supports"
7499
7561
  },
7500
7562
  linkedQuestionId: {
7501
7563
  type: "string",
7502
7564
  description: "Question this task addresses"
7503
7565
  },
7504
- linkedWorktreeId: { type: "string", description: "Worktree scope" }
7566
+ assigneeId: {
7567
+ type: "string",
7568
+ description: "Principal assigned to the task"
7569
+ },
7570
+ dueDate: {
7571
+ type: "number",
7572
+ description: "Due date as epoch milliseconds"
7573
+ },
7574
+ tags: {
7575
+ type: "array",
7576
+ description: "Free-form string tags"
7577
+ }
7505
7578
  },
7506
7579
  required: ["title"],
7507
7580
  response: {
@@ -9584,9 +9657,7 @@ function mcpContractFromArgsSchema(base, args, contractName) {
9584
9657
  required: converted.filter(([, field]) => field.required).map(([fieldName]) => fieldName)
9585
9658
  };
9586
9659
  }
9587
- function defineFunctionContract(contract) {
9588
- return contract;
9589
- }
9660
+ var defineFunctionContract = (contract) => contract;
9590
9661
  function authUserId(context) {
9591
9662
  return context.userId ?? context.principalId ?? "lucern-agent";
9592
9663
  }
@@ -9740,6 +9811,9 @@ var observationContextArgs = z.object({
9740
9811
  limit: z.number().optional().describe("Maximum observations to return."),
9741
9812
  status: z.string().optional().describe("Observation status filter.")
9742
9813
  });
9814
+ function isRecord2(value) {
9815
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
9816
+ }
9743
9817
  var observationInput = (input, context) => withUserId(
9744
9818
  compactRecord4({
9745
9819
  projectId: input.projectId,
@@ -9794,8 +9868,8 @@ var contextContracts = [
9794
9868
  kind: "mutation",
9795
9869
  inputProjection: observationInput,
9796
9870
  outputProjection: (output, input) => ({
9797
- ...output && typeof output === "object" ? output : {},
9798
- observationId: output && typeof output === "object" ? output.nodeId : void 0,
9871
+ ...isRecord2(output) ? output : {},
9872
+ observationId: isRecord2(output) ? output.nodeId : void 0,
9799
9873
  observationType: input.observationType
9800
9874
  })
9801
9875
  },
@@ -11276,10 +11350,11 @@ var worktreeDecisionGateInputSchema = z.object({
11276
11350
  decidedBy: z.string().optional().describe("Actor that decided the gate verdict.")
11277
11351
  }).passthrough().describe("Decision gate contract for worktree activation or exit.");
11278
11352
  var addWorktreeArgs = z.object({
11279
- title: z.string().optional().describe("Human-readable worktree name or objective."),
11353
+ title: z.string().describe("Human-readable worktree name or objective."),
11280
11354
  name: z.string().optional().describe("Storage-name alias for callers that already use backend naming."),
11281
- topicId: z.string().describe("Primary topic scope for the worktree."),
11282
- projectId: z.string().optional().describe("Legacy topicId alias."),
11355
+ topicId: z.string().optional().describe("Optional primary topic scope hint for resolver validation."),
11356
+ projectId: z.string().optional().describe("Legacy topicId alias/hint."),
11357
+ topicHint: z.string().optional().describe("Natural-language topic hint for automatic topic resolution."),
11283
11358
  branchId: z.string().optional().describe("Legacy branch identifier for compatibility with workflow callers."),
11284
11359
  objective: z.string().optional().describe("Reasoning objective this worktree is intended to resolve."),
11285
11360
  hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
@@ -11304,6 +11379,10 @@ var addWorktreeArgs = z.object({
11304
11379
  autoShape: z.boolean().optional().describe("Whether to invoke inquiry auto-shaping during creation."),
11305
11380
  autoFixPolicy: autoFixPolicyInputSchema.optional(),
11306
11381
  domainPackId: z.string().optional().describe("Domain pack whose shaping hooks should influence the worktree."),
11382
+ tags: z.array(z.string()).optional().describe("Additional topic-resolution tags for the worktree."),
11383
+ touchedPaths: z.array(z.string()).optional().describe("File paths used as topic-resolution signals."),
11384
+ sourceRef: z.string().optional().describe("Source reference used as a topic-resolution signal."),
11385
+ sourceKind: z.string().optional().describe("Source kind used as a topic-resolution signal."),
11307
11386
  campaign: z.number().optional().describe("Top-level pipeline campaign number."),
11308
11387
  lane: z.string().optional().describe("Campaign lane for the worktree."),
11309
11388
  laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
@@ -11633,8 +11712,46 @@ var worktreesContracts = [
11633
11712
  args: openPullRequestArgs
11634
11713
  })
11635
11714
  ];
11636
-
11637
- // ../contracts/src/function-registry/tasks.ts
11715
+ var taskPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
11716
+ var taskStatusSchema2 = z.enum(["todo", "in_progress", "blocked", "done"]);
11717
+ var taskTypeSchema = z.enum([
11718
+ "general",
11719
+ "find_evidence",
11720
+ "verify_claim",
11721
+ "research",
11722
+ "review",
11723
+ "interview",
11724
+ "analysis",
11725
+ "track_metrics"
11726
+ ]);
11727
+ var createTaskArgs = z.object({
11728
+ title: z.string().describe("Task title."),
11729
+ topicId: z.string().optional().describe("Topic scope."),
11730
+ description: z.string().optional().describe("Long-form task description."),
11731
+ taskType: taskTypeSchema.optional().describe("Task taxonomy."),
11732
+ priority: taskPrioritySchema.optional().describe("Priority. Defaults to medium when omitted by the server."),
11733
+ status: taskStatusSchema2.optional().describe("Initial status. Defaults to todo."),
11734
+ linkedWorktreeId: z.string().optional().describe("Worktree this task belongs to."),
11735
+ linkedBeliefId: z.string().optional().describe("Belief this task supports."),
11736
+ linkedQuestionId: z.string().optional().describe("Question this task addresses."),
11737
+ assigneeId: z.string().optional().describe("Principal assigned to the task."),
11738
+ dueDate: z.number().optional().describe("Due date as epoch milliseconds."),
11739
+ tags: z.array(z.string()).optional().describe("Free-form tags.")
11740
+ });
11741
+ var createTaskInput = (input) => compactRecord4({
11742
+ title: input.title,
11743
+ topicId: input.topicId,
11744
+ description: input.description,
11745
+ taskType: input.taskType,
11746
+ priority: input.priority ?? "medium",
11747
+ status: input.status ?? "todo",
11748
+ linkedWorktreeId: input.linkedWorktreeId,
11749
+ linkedBeliefId: input.linkedBeliefId,
11750
+ linkedQuestionId: input.linkedQuestionId,
11751
+ assigneeId: input.assigneeId,
11752
+ dueDate: input.dueDate,
11753
+ tags: input.tags
11754
+ });
11638
11755
  var taskInput = (input) => compactRecord4({
11639
11756
  ...input,
11640
11757
  taskId: input.taskId ?? input.id
@@ -11666,8 +11783,10 @@ var tasksContracts = [
11666
11783
  convex: {
11667
11784
  module: "tasks",
11668
11785
  functionName: "create",
11669
- kind: "mutation"
11670
- }
11786
+ kind: "mutation",
11787
+ inputProjection: createTaskInput
11788
+ },
11789
+ args: createTaskArgs
11671
11790
  }),
11672
11791
  surfaceContract({
11673
11792
  name: "list_tasks",
@@ -12785,9 +12904,12 @@ var ALL_FUNCTION_CONTRACTS = [
12785
12904
  ...legacyContracts
12786
12905
  ];
12787
12906
  assertSurfaceCoverage(ALL_FUNCTION_CONTRACTS);
12788
- new Map(
12907
+ var FUNCTION_CONTRACTS_BY_NAME = new Map(
12789
12908
  ALL_FUNCTION_CONTRACTS.map((contract) => [contract.name, contract])
12790
12909
  );
12910
+ FUNCTION_CONTRACTS_BY_NAME.get.bind(
12911
+ FUNCTION_CONTRACTS_BY_NAME
12912
+ );
12791
12913
 
12792
12914
  // ../contracts/src/tenant-bootstrap-seed.contract.ts
12793
12915
  function isCopyableSeedRequirement(entry) {
@@ -13389,11 +13511,16 @@ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
13389
13511
 
13390
13512
  // src/webhooks.ts
13391
13513
  var LOCALHOST_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
13514
+ function invalidWebhookUrlError(error) {
13515
+ return new Error("Webhook URL must be a valid absolute URL.", {
13516
+ cause: error
13517
+ });
13518
+ }
13392
13519
  function normalizeUrl(url) {
13393
13520
  try {
13394
13521
  return new URL(url.trim());
13395
- } catch {
13396
- throw new Error("Webhook URL must be a valid absolute URL.");
13522
+ } catch (error) {
13523
+ throw invalidWebhookUrlError(error);
13397
13524
  }
13398
13525
  }
13399
13526
  function assertValidWebhookUrl(url) {