@ainyc/canonry 4.14.0 → 4.15.2
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/README.md +57 -223
- package/assets/assets/{index-D0EPNRDs.css → index-C1WW21tz.css} +1 -1
- package/assets/assets/index-Qq_oMI-C.js +302 -0
- package/assets/index.html +2 -2
- package/dist/{chunk-5NYG5EC7.js → chunk-7SRKUAZO.js} +131 -2
- package/dist/{chunk-UQHWSCTE.js → chunk-IVNWS2YU.js} +473 -104
- package/dist/{chunk-7HBZCGRL.js → chunk-MI33SQL6.js} +27 -2
- package/dist/{chunk-6QTH5NS5.js → chunk-ONI3TX2A.js} +62 -0
- package/dist/cli.js +354 -119
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -4
- package/dist/{intelligence-service-BCKXIKIL.js → intelligence-service-JYV3CO4H.js} +2 -2
- package/dist/mcp.js +9 -3
- package/package.json +7 -7
- package/assets/assets/index-B6Mi9Fd1.js +0 -302
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
categoryLabel,
|
|
9
9
|
determineAnswerMentioned,
|
|
10
10
|
normalizeProjectDomain
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ONI3TX2A.js";
|
|
12
12
|
|
|
13
13
|
// src/intelligence-service.ts
|
|
14
14
|
import { eq, desc, asc, and, or, inArray } from "drizzle-orm";
|
|
@@ -104,13 +104,15 @@ var runs = sqliteTable("runs", {
|
|
|
104
104
|
status: text("status").notNull().default("queued"),
|
|
105
105
|
trigger: text("trigger").notNull().default("manual"),
|
|
106
106
|
location: text("location"),
|
|
107
|
+
sourceId: text("source_id"),
|
|
107
108
|
startedAt: text("started_at"),
|
|
108
109
|
finishedAt: text("finished_at"),
|
|
109
110
|
error: text("error"),
|
|
110
111
|
createdAt: text("created_at").notNull()
|
|
111
112
|
}, (table) => [
|
|
112
113
|
index("idx_runs_project").on(table.projectId),
|
|
113
|
-
index("idx_runs_status").on(table.status)
|
|
114
|
+
index("idx_runs_status").on(table.status),
|
|
115
|
+
index("idx_runs_source").on(table.sourceId)
|
|
114
116
|
]);
|
|
115
117
|
var querySnapshots = sqliteTable("query_snapshots", {
|
|
116
118
|
id: text("id").primaryKey(),
|
|
@@ -555,6 +557,11 @@ var trafficSources = sqliteTable("traffic_sources", {
|
|
|
555
557
|
lastSyncedAt: text("last_synced_at"),
|
|
556
558
|
lastCursor: text("last_cursor"),
|
|
557
559
|
lastError: text("last_error"),
|
|
560
|
+
// JSON-encoded array of normalized event IDs (e.g. `cloud-run:<ts>:<insertId>`)
|
|
561
|
+
// observed in the most recent successful sync. Bounded ring buffer used to
|
|
562
|
+
// dedupe across sync runs at the boundary timestamp where lastSyncedAt
|
|
563
|
+
// clamping alone leaves a small overlap window.
|
|
564
|
+
lastEventIds: text("last_event_ids"),
|
|
558
565
|
archivedAt: text("archived_at"),
|
|
559
566
|
configJson: text("config_json").notNull().default("{}"),
|
|
560
567
|
createdAt: text("created_at").notNull(),
|
|
@@ -1586,6 +1593,24 @@ var MIGRATION_VERSIONS = [
|
|
|
1586
1593
|
tx.run(sql.raw(`CREATE UNIQUE INDEX IF NOT EXISTS idx_ga_ai_ref_unique_v4
|
|
1587
1594
|
ON ga_ai_referrals(project_id, date, source, medium, source_dimension, channel_group, landing_page)`));
|
|
1588
1595
|
}
|
|
1596
|
+
},
|
|
1597
|
+
{
|
|
1598
|
+
version: 51,
|
|
1599
|
+
name: "runs-source-id",
|
|
1600
|
+
statements: [
|
|
1601
|
+
`ALTER TABLE runs ADD COLUMN source_id TEXT`,
|
|
1602
|
+
`CREATE INDEX IF NOT EXISTS idx_runs_source ON runs(source_id)`
|
|
1603
|
+
]
|
|
1604
|
+
},
|
|
1605
|
+
{
|
|
1606
|
+
version: 52,
|
|
1607
|
+
name: "traffic-sources-last-event-ids",
|
|
1608
|
+
statements: [
|
|
1609
|
+
// JSON-encoded array of normalized event IDs from the previous sync,
|
|
1610
|
+
// used for cross-sync boundary-window dedupe so a longer default
|
|
1611
|
+
// sync window (or any overlapping re-sync) cannot double-count.
|
|
1612
|
+
`ALTER TABLE traffic_sources ADD COLUMN last_event_ids TEXT`
|
|
1613
|
+
]
|
|
1589
1614
|
}
|
|
1590
1615
|
];
|
|
1591
1616
|
function isDuplicateColumnError(err) {
|
|
@@ -2251,6 +2251,65 @@ var trafficSyncResponseSchema = z20.object({
|
|
|
2251
2251
|
windowStart: z20.string(),
|
|
2252
2252
|
windowEnd: z20.string()
|
|
2253
2253
|
});
|
|
2254
|
+
var trafficSourceTotalsSchema = z20.object({
|
|
2255
|
+
crawlerHits: z20.number().int().nonnegative(),
|
|
2256
|
+
aiReferralHits: z20.number().int().nonnegative(),
|
|
2257
|
+
sampleCount: z20.number().int().nonnegative()
|
|
2258
|
+
});
|
|
2259
|
+
var trafficSourceListResponseSchema = z20.object({
|
|
2260
|
+
sources: z20.array(trafficSourceDtoSchema)
|
|
2261
|
+
});
|
|
2262
|
+
var trafficSourceDetailDtoSchema = trafficSourceDtoSchema.extend({
|
|
2263
|
+
totals24h: trafficSourceTotalsSchema,
|
|
2264
|
+
latestRun: z20.object({
|
|
2265
|
+
runId: z20.string(),
|
|
2266
|
+
status: runStatusSchema,
|
|
2267
|
+
startedAt: z20.string().nullable(),
|
|
2268
|
+
finishedAt: z20.string().nullable(),
|
|
2269
|
+
error: z20.string().nullable()
|
|
2270
|
+
}).nullable()
|
|
2271
|
+
});
|
|
2272
|
+
var trafficStatusResponseSchema = z20.object({
|
|
2273
|
+
sources: z20.array(trafficSourceDetailDtoSchema)
|
|
2274
|
+
});
|
|
2275
|
+
var trafficEventKindSchema = z20.enum(["crawler", "ai-referral"]);
|
|
2276
|
+
var TrafficEventKinds = trafficEventKindSchema.enum;
|
|
2277
|
+
var trafficCrawlerEventEntrySchema = z20.object({
|
|
2278
|
+
kind: z20.literal(TrafficEventKinds.crawler),
|
|
2279
|
+
sourceId: z20.string(),
|
|
2280
|
+
tsHour: z20.string(),
|
|
2281
|
+
botId: z20.string(),
|
|
2282
|
+
operator: z20.string(),
|
|
2283
|
+
verificationStatus: z20.string(),
|
|
2284
|
+
pathNormalized: z20.string(),
|
|
2285
|
+
status: z20.number().int(),
|
|
2286
|
+
hits: z20.number().int().nonnegative()
|
|
2287
|
+
});
|
|
2288
|
+
var trafficAiReferralEventEntrySchema = z20.object({
|
|
2289
|
+
kind: z20.literal(TrafficEventKinds["ai-referral"]),
|
|
2290
|
+
sourceId: z20.string(),
|
|
2291
|
+
tsHour: z20.string(),
|
|
2292
|
+
product: z20.string(),
|
|
2293
|
+
operator: z20.string(),
|
|
2294
|
+
sourceDomain: z20.string(),
|
|
2295
|
+
evidenceType: z20.string(),
|
|
2296
|
+
landingPathNormalized: z20.string(),
|
|
2297
|
+
status: z20.number().int(),
|
|
2298
|
+
hits: z20.number().int().nonnegative()
|
|
2299
|
+
});
|
|
2300
|
+
var trafficEventEntrySchema = z20.discriminatedUnion("kind", [
|
|
2301
|
+
trafficCrawlerEventEntrySchema,
|
|
2302
|
+
trafficAiReferralEventEntrySchema
|
|
2303
|
+
]);
|
|
2304
|
+
var trafficEventsResponseSchema = z20.object({
|
|
2305
|
+
windowStart: z20.string(),
|
|
2306
|
+
windowEnd: z20.string(),
|
|
2307
|
+
totals: z20.object({
|
|
2308
|
+
crawlerHits: z20.number().int().nonnegative(),
|
|
2309
|
+
aiReferralHits: z20.number().int().nonnegative()
|
|
2310
|
+
}),
|
|
2311
|
+
events: z20.array(trafficEventEntrySchema)
|
|
2312
|
+
});
|
|
2254
2313
|
|
|
2255
2314
|
// ../contracts/src/formatting.ts
|
|
2256
2315
|
function formatRatio(value) {
|
|
@@ -2389,6 +2448,9 @@ export {
|
|
|
2389
2448
|
TrafficEventConfidences,
|
|
2390
2449
|
TrafficSourceStatuses,
|
|
2391
2450
|
TrafficSourceAuthModes,
|
|
2451
|
+
trafficConnectCloudRunRequestSchema,
|
|
2452
|
+
trafficEventKindSchema,
|
|
2453
|
+
TrafficEventKinds,
|
|
2392
2454
|
formatRatio,
|
|
2393
2455
|
formatNumber,
|
|
2394
2456
|
formatDate,
|