@agent-native/core 0.111.3 → 0.112.0

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 (109) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +18 -0
  3. package/corpus/core/package.json +3 -1
  4. package/corpus/core/src/cli/code-agent-executor.ts +17 -5
  5. package/corpus/core/src/cli/code-agent-runs.ts +43 -2
  6. package/corpus/core/src/cli/migration-codemod.ts +59 -9
  7. package/corpus/core/src/cli/multi-frontier-runs.ts +841 -0
  8. package/corpus/core/src/coding-tools/index.ts +27 -8
  9. package/corpus/core/src/embeddings/index.ts +233 -0
  10. package/corpus/core/src/index.ts +2 -0
  11. package/corpus/core/src/search/index.ts +413 -0
  12. package/corpus/templates/brain/.agents/skills/brain/RUNBOOK.md +48 -5
  13. package/corpus/templates/brain/.agents/skills/brain/SKILL.md +46 -14
  14. package/corpus/templates/brain/README.md +34 -3
  15. package/corpus/templates/brain/actions/approve-proposal.ts +2 -0
  16. package/corpus/templates/brain/actions/claim-distillation.ts +24 -27
  17. package/corpus/templates/brain/actions/create-source.ts +1 -1
  18. package/corpus/templates/brain/actions/get-knowledge.ts +6 -2
  19. package/corpus/templates/brain/actions/get-pilot-report.ts +44 -8
  20. package/corpus/templates/brain/actions/import-capture.ts +21 -9
  21. package/corpus/templates/brain/actions/import-transcript.ts +42 -14
  22. package/corpus/templates/brain/actions/list-captures.ts +10 -1
  23. package/corpus/templates/brain/actions/list-distillation-queue.ts +39 -14
  24. package/corpus/templates/brain/actions/list-projects.ts +51 -0
  25. package/corpus/templates/brain/actions/list-proposals.ts +80 -4
  26. package/corpus/templates/brain/actions/list-sources.ts +17 -3
  27. package/corpus/templates/brain/actions/manage-project.ts +118 -0
  28. package/corpus/templates/brain/actions/mark-capture-distilled.ts +68 -20
  29. package/corpus/templates/brain/actions/navigate.ts +1 -0
  30. package/corpus/templates/brain/actions/reject-proposal.ts +6 -1
  31. package/corpus/templates/brain/actions/resanitize-captures.ts +159 -33
  32. package/corpus/templates/brain/actions/review-proposal.ts +2 -0
  33. package/corpus/templates/brain/actions/search-everything.ts +10 -1
  34. package/corpus/templates/brain/actions/search-knowledge.ts +1 -1
  35. package/corpus/templates/brain/actions/set-settings.ts +36 -1
  36. package/corpus/templates/brain/actions/update-proposal.ts +2 -0
  37. package/corpus/templates/brain/app/hooks/use-distillation-bridge.ts +18 -9
  38. package/corpus/templates/brain/app/hooks/use-navigation-state.ts +3 -0
  39. package/corpus/templates/brain/app/i18n-data.ts +731 -2
  40. package/corpus/templates/brain/app/lib/brain.ts +33 -1
  41. package/corpus/templates/brain/app/routes/ops.tsx +47 -0
  42. package/corpus/templates/brain/app/routes/review.tsx +41 -2
  43. package/corpus/templates/brain/app/routes/search.tsx +33 -2
  44. package/corpus/templates/brain/app/routes/settings.tsx +158 -0
  45. package/corpus/templates/brain/app/routes/sources.tsx +31 -0
  46. package/corpus/templates/brain/changelog/2026-07-19-added-private-source-safe-semantic-search.md +6 -0
  47. package/corpus/templates/brain/jobs/process-ingest-queue.ts +270 -36
  48. package/corpus/templates/brain/package.json +1 -0
  49. package/corpus/templates/brain/server/db/index.ts +18 -0
  50. package/corpus/templates/brain/server/db/schema.ts +197 -1
  51. package/corpus/templates/brain/server/jobs/distillation-queue.ts +12 -5
  52. package/corpus/templates/brain/server/lib/audiences.ts +708 -0
  53. package/corpus/templates/brain/server/lib/brain-health.ts +251 -38
  54. package/corpus/templates/brain/server/lib/brain.ts +877 -50
  55. package/corpus/templates/brain/server/lib/capture-sanitization.ts +217 -53
  56. package/corpus/templates/brain/server/lib/connectors.ts +556 -70
  57. package/corpus/templates/brain/server/lib/demo.ts +17 -4
  58. package/corpus/templates/brain/server/lib/hybrid-search.ts +363 -0
  59. package/corpus/templates/brain/server/lib/ingest-queue.ts +104 -0
  60. package/corpus/templates/brain/server/lib/privacy-readiness.ts +24 -0
  61. package/corpus/templates/brain/server/lib/search-index-contracts.ts +72 -0
  62. package/corpus/templates/brain/server/lib/search-index.ts +714 -0
  63. package/corpus/templates/brain/server/lib/search.ts +120 -4
  64. package/corpus/templates/brain/server/lib/sensitivity-policy.ts +174 -0
  65. package/corpus/templates/brain/server/lib/slack-events.ts +281 -0
  66. package/corpus/templates/brain/server/onboarding.ts +29 -0
  67. package/corpus/templates/brain/server/plugins/db.ts +204 -0
  68. package/corpus/templates/brain/server/register-secrets.ts +46 -0
  69. package/corpus/templates/brain/server/routes/api/_agent-native/brain/ingest.post.ts +36 -16
  70. package/corpus/templates/brain/server/routes/api/_agent-native/brain/slack-events.post.ts +28 -0
  71. package/corpus/templates/brain/shared/types.ts +10 -0
  72. package/dist/cli/code-agent-executor.d.ts +8 -9
  73. package/dist/cli/code-agent-executor.d.ts.map +1 -1
  74. package/dist/cli/code-agent-executor.js +9 -3
  75. package/dist/cli/code-agent-executor.js.map +1 -1
  76. package/dist/cli/code-agent-runs.d.ts +5 -0
  77. package/dist/cli/code-agent-runs.d.ts.map +1 -1
  78. package/dist/cli/code-agent-runs.js +33 -2
  79. package/dist/cli/code-agent-runs.js.map +1 -1
  80. package/dist/cli/migration-codemod.d.ts.map +1 -1
  81. package/dist/cli/migration-codemod.js +48 -10
  82. package/dist/cli/migration-codemod.js.map +1 -1
  83. package/dist/cli/multi-frontier-runs.d.ts +131 -0
  84. package/dist/cli/multi-frontier-runs.d.ts.map +1 -0
  85. package/dist/cli/multi-frontier-runs.js +529 -0
  86. package/dist/cli/multi-frontier-runs.js.map +1 -0
  87. package/dist/coding-tools/index.d.ts +1 -0
  88. package/dist/coding-tools/index.d.ts.map +1 -1
  89. package/dist/coding-tools/index.js +25 -7
  90. package/dist/coding-tools/index.js.map +1 -1
  91. package/dist/collab/awareness.d.ts +2 -2
  92. package/dist/collab/awareness.d.ts.map +1 -1
  93. package/dist/embeddings/index.d.ts +24 -0
  94. package/dist/embeddings/index.d.ts.map +1 -0
  95. package/dist/embeddings/index.js +172 -0
  96. package/dist/embeddings/index.js.map +1 -0
  97. package/dist/index.d.ts +2 -0
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +2 -0
  100. package/dist/index.js.map +1 -1
  101. package/dist/notifications/routes.d.ts +3 -3
  102. package/dist/progress/routes.d.ts +1 -1
  103. package/dist/resources/handlers.d.ts +1 -1
  104. package/dist/search/index.d.ts +88 -0
  105. package/dist/search/index.d.ts.map +1 -0
  106. package/dist/search/index.js +267 -0
  107. package/dist/search/index.js.map +1 -0
  108. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  109. package/package.json +3 -1
@@ -45,6 +45,13 @@ export const brainRawCaptures = table("brain_raw_captures", {
45
45
  .default("generic"),
46
46
  content: text("content").notNull(),
47
47
  contentHash: text("content_hash"),
48
+ sensitivityDisposition: text("sensitivity_disposition", {
49
+ enum: ["pending", "allowed"],
50
+ })
51
+ .notNull()
52
+ .default("pending"),
53
+ sensitivityPolicyVersion: text("sensitivity_policy_version"),
54
+ audienceAclHash: text("audience_acl_hash"),
48
55
  metadataJson: text("metadata_json").notNull().default("{}"),
49
56
  capturedAt: text("captured_at").notNull(),
50
57
  importedBy: text("imported_by").notNull(),
@@ -62,6 +69,8 @@ export const brainKnowledge = table("brain_knowledge", {
62
69
  id: text("id").primaryKey(),
63
70
  sourceId: text("source_id"),
64
71
  captureId: text("capture_id"),
72
+ audienceId: text("audience_id"),
73
+ audienceAclHash: text("audience_acl_hash"),
65
74
  kind: text("kind", {
66
75
  enum: [
67
76
  "decision",
@@ -111,6 +120,8 @@ export const brainProposals = table("brain_proposals", {
111
120
  knowledgeId: text("knowledge_id"),
112
121
  sourceId: text("source_id"),
113
122
  captureId: text("capture_id"),
123
+ audienceId: text("audience_id"),
124
+ audienceAclHash: text("audience_acl_hash"),
114
125
  title: text("title").notNull(),
115
126
  body: text("body").notNull(),
116
127
  rationale: text("rationale").notNull().default(""),
@@ -157,7 +168,13 @@ export const brainIngestQueue = table("brain_ingest_queue", {
157
168
  sourceId: text("source_id"),
158
169
  captureId: text("capture_id"),
159
170
  operation: text("operation", {
160
- enum: ["distill", "sync"],
171
+ enum: [
172
+ "distill",
173
+ "sync",
174
+ "search-index",
175
+ "search-unindex",
176
+ "slack-thread-refresh",
177
+ ],
161
178
  })
162
179
  .notNull()
163
180
  .default("distill"),
@@ -169,8 +186,187 @@ export const brainIngestQueue = table("brain_ingest_queue", {
169
186
  priority: integer("priority").notNull().default(0),
170
187
  attempts: integer("attempts").notNull().default(0),
171
188
  payloadJson: text("payload_json").notNull().default("{}"),
189
+ dedupeKey: text("dedupe_key"),
190
+ leaseToken: text("lease_token"),
191
+ leaseExpiresAt: text("lease_expires_at"),
172
192
  error: text("error"),
173
193
  runAfter: text("run_after"),
174
194
  createdAt: text("created_at").notNull().default(now()),
175
195
  updatedAt: text("updated_at").notNull().default(now()),
176
196
  });
197
+
198
+ export const brainAudiences = table("brain_audiences", {
199
+ id: text("id").primaryKey(),
200
+ sourceId: text("source_id").notNull(),
201
+ kind: text("kind", {
202
+ enum: ["org", "slack-private-channel", "meeting", "restricted"],
203
+ }).notNull(),
204
+ upstreamRefHash: text("upstream_ref_hash"),
205
+ aclHash: text("acl_hash").notNull(),
206
+ membershipState: text("membership_state", {
207
+ enum: ["current", "stale", "error"],
208
+ })
209
+ .notNull()
210
+ .default("stale"),
211
+ lastSyncedAt: text("last_synced_at"),
212
+ createdAt: text("created_at").notNull().default(now()),
213
+ updatedAt: text("updated_at").notNull().default(now()),
214
+ });
215
+
216
+ export const brainAudienceMembers = table("brain_audience_members", {
217
+ id: text("id").primaryKey(),
218
+ audienceId: text("audience_id").notNull(),
219
+ principalType: text("principal_type", { enum: ["user", "org"] }).notNull(),
220
+ principalId: text("principal_id").notNull(),
221
+ upstreamPrincipalHash: text("upstream_principal_hash"),
222
+ status: text("status", { enum: ["active", "revoked"] })
223
+ .notNull()
224
+ .default("active"),
225
+ syncedAt: text("synced_at").notNull(),
226
+ createdAt: text("created_at").notNull().default(now()),
227
+ updatedAt: text("updated_at").notNull().default(now()),
228
+ });
229
+
230
+ export const brainAudienceDependencies = table("brain_audience_dependencies", {
231
+ id: text("id").primaryKey(),
232
+ audienceId: text("audience_id").notNull(),
233
+ dependsOnAudienceId: text("depends_on_audience_id").notNull(),
234
+ createdAt: text("created_at").notNull().default(now()),
235
+ });
236
+
237
+ export const brainAudienceSourceDependencies = table(
238
+ "brain_audience_source_dependencies",
239
+ {
240
+ id: text("id").primaryKey(),
241
+ audienceId: text("audience_id").notNull(),
242
+ sourceId: text("source_id").notNull(),
243
+ createdAt: text("created_at").notNull().default(now()),
244
+ },
245
+ );
246
+
247
+ export const brainCaptureAudiences = table("brain_capture_audiences", {
248
+ id: text("id").primaryKey(),
249
+ captureId: text("capture_id").notNull(),
250
+ audienceId: text("audience_id").notNull(),
251
+ aclHash: text("acl_hash").notNull(),
252
+ createdAt: text("created_at").notNull().default(now()),
253
+ });
254
+
255
+ export const brainSensitivityEvents = table("brain_sensitivity_events", {
256
+ id: text("id").primaryKey(),
257
+ sourceId: text("source_id").notNull(),
258
+ captureId: text("capture_id"),
259
+ locatorHmac: text("locator_hmac").notNull(),
260
+ disposition: text("disposition", {
261
+ enum: ["suppressed", "quarantined", "released", "discarded", "expired"],
262
+ }).notNull(),
263
+ categoriesJson: text("categories_json").notNull().default("[]"),
264
+ confidenceBand: text("confidence_band", {
265
+ enum: ["deterministic", "high", "medium", "uncertain"],
266
+ }).notNull(),
267
+ policyVersion: text("policy_version").notNull(),
268
+ upstreamProvider: text("upstream_provider").notNull(),
269
+ quarantineBlobHandle: text("quarantine_blob_handle"),
270
+ expiresAt: text("expires_at"),
271
+ reviewedBy: text("reviewed_by"),
272
+ reviewedAt: text("reviewed_at"),
273
+ createdAt: text("created_at").notNull().default(now()),
274
+ updatedAt: text("updated_at").notNull().default(now()),
275
+ });
276
+
277
+ export const brainSearchArtifacts = table("brain_search_artifacts", {
278
+ id: text("id").primaryKey(),
279
+ captureId: text("capture_id").notNull(),
280
+ sourceId: text("source_id").notNull(),
281
+ audienceId: text("audience_id").notNull(),
282
+ aclHash: text("acl_hash").notNull(),
283
+ title: text("title").notNull(),
284
+ question: text("question").notNull().default(""),
285
+ summary: text("summary").notNull().default(""),
286
+ resolution: text("resolution").notNull().default(""),
287
+ systemsJson: text("systems_json").notNull().default("[]"),
288
+ codeRefsJson: text("code_refs_json").notNull().default("[]"),
289
+ contentHash: text("content_hash").notNull(),
290
+ sensitivityPolicyVersion: text("sensitivity_policy_version").notNull(),
291
+ indexVersion: text("index_version").notNull(),
292
+ status: text("status", { enum: ["active", "stale", "deleted"] })
293
+ .notNull()
294
+ .default("active"),
295
+ capturedAt: text("captured_at").notNull(),
296
+ createdAt: text("created_at").notNull().default(now()),
297
+ updatedAt: text("updated_at").notNull().default(now()),
298
+ });
299
+
300
+ export const brainSearchBursts = table("brain_search_bursts", {
301
+ id: text("id").primaryKey(),
302
+ artifactId: text("artifact_id").notNull(),
303
+ captureId: text("capture_id").notNull(),
304
+ sourceId: text("source_id").notNull(),
305
+ audienceId: text("audience_id").notNull(),
306
+ aclHash: text("acl_hash").notNull(),
307
+ ordinal: integer("ordinal").notNull(),
308
+ startOffset: integer("start_offset").notNull(),
309
+ endOffset: integer("end_offset").notNull(),
310
+ content: text("content").notNull(),
311
+ contextualText: text("contextual_text").notNull(),
312
+ charCount: integer("char_count").notNull(),
313
+ rareTermScore: integer("rare_term_score").notNull().default(0),
314
+ reactionCount: integer("reaction_count").notNull().default(0),
315
+ indexed: integer("indexed").notNull().default(0),
316
+ contentHash: text("content_hash").notNull(),
317
+ indexVersion: text("index_version").notNull(),
318
+ createdAt: text("created_at").notNull().default(now()),
319
+ updatedAt: text("updated_at").notNull().default(now()),
320
+ });
321
+
322
+ export const brainSearchEmbeddings = table("brain_search_embeddings", {
323
+ id: text("id").primaryKey(),
324
+ targetType: text("target_type", {
325
+ enum: ["artifact", "burst", "knowledge"],
326
+ }).notNull(),
327
+ targetId: text("target_id").notNull(),
328
+ vectorKey: text("vector_key").notNull(),
329
+ sourceId: text("source_id").notNull(),
330
+ audienceId: text("audience_id").notNull(),
331
+ aclHash: text("acl_hash").notNull(),
332
+ embeddingSetId: text("embedding_set_id").notNull(),
333
+ dimensions: integer("dimensions").notNull(),
334
+ contentHash: text("content_hash").notNull(),
335
+ sensitivityPolicyVersion: text("sensitivity_policy_version").notNull(),
336
+ indexVersion: text("index_version").notNull(),
337
+ status: text("status", { enum: ["active", "stale", "deleted"] })
338
+ .notNull()
339
+ .default("active"),
340
+ createdAt: text("created_at").notNull().default(now()),
341
+ updatedAt: text("updated_at").notNull().default(now()),
342
+ });
343
+
344
+ export const brainTermStats = table("brain_term_stats", {
345
+ term: text("term").primaryKey(),
346
+ documentCount: integer("document_count").notNull().default(0),
347
+ updatedAt: text("updated_at").notNull().default(now()),
348
+ });
349
+
350
+ export const brainSearchCorpusStats = table("brain_search_corpus_stats", {
351
+ id: text("id").primaryKey(),
352
+ documentCount: integer("document_count").notNull().default(0),
353
+ updatedAt: text("updated_at").notNull().default(now()),
354
+ });
355
+
356
+ export const brainProjects = table("brain_projects", {
357
+ id: text("id").primaryKey(),
358
+ title: text("title").notNull(),
359
+ description: text("description").notNull().default(""),
360
+ createdAt: text("created_at").notNull().default(now()),
361
+ updatedAt: text("updated_at").notNull().default(now()),
362
+ ...ownableColumns(),
363
+ });
364
+
365
+ export const brainProjectShares = createSharesTable("brain_project_shares");
366
+
367
+ export const brainProjectSources = table("brain_project_sources", {
368
+ id: text("id").primaryKey(),
369
+ projectId: text("project_id").notNull(),
370
+ sourceId: text("source_id").notNull(),
371
+ createdAt: text("created_at").notNull().default(now()),
372
+ });
@@ -1,4 +1,5 @@
1
1
  import { processBrainIngestQueueOnce } from "../../jobs/process-ingest-queue.js";
2
+ import { expireSensitivityQuarantines } from "../lib/brain.js";
2
3
 
3
4
  const DISTILL_QUEUE_INTERVAL_MS = 60 * 1000;
4
5
  let skippingLogged = false;
@@ -30,11 +31,14 @@ export default function registerBrainDistillationQueueJob(): void {
30
31
  setInterval(() => {
31
32
  if (running) return;
32
33
  running = true;
33
- processBrainIngestQueueOnce({
34
- limit: sweepLimit(),
35
- runDistillation: true,
36
- })
37
- .then((result) => {
34
+ Promise.all([
35
+ processBrainIngestQueueOnce({
36
+ limit: sweepLimit(),
37
+ runDistillation: true,
38
+ }),
39
+ expireSensitivityQuarantines(),
40
+ ])
41
+ .then(([result, expired]) => {
38
42
  const count =
39
43
  result.processed.length +
40
44
  result.deferred.length +
@@ -44,6 +48,9 @@ export default function registerBrainDistillationQueueJob(): void {
44
48
  `[brain-distillation] processed=${result.processed.length} deferred=${result.deferred.length} failed=${result.failed.length}`,
45
49
  );
46
50
  }
51
+ if (expired) {
52
+ console.log(`[brain-privacy] expired=${expired}`);
53
+ }
47
54
  })
48
55
  .catch((err) =>
49
56
  console.error("[brain-distillation] interval failed:", err),