@canonry/canonry 5.30.0 → 5.30.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.
- package/dist/{chunk-T3MTYL7I.js → chunk-LLVE7B3V.js} +47 -26
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +11 -11
|
@@ -7136,7 +7136,9 @@ async function executeTrackedQuery6(input) {
|
|
|
7136
7136
|
servedModel: extractServedModel6(rawResponse),
|
|
7137
7137
|
groundingSources: parsed.groundingSources,
|
|
7138
7138
|
searchQueries: parsed.searchQueries,
|
|
7139
|
-
retrievalStatus: parsed.retrievalStatus
|
|
7139
|
+
retrievalStatus: parsed.retrievalStatus,
|
|
7140
|
+
usage: extractUsage(rawResponse),
|
|
7141
|
+
stopReason: extractStopReason(rawResponse)
|
|
7140
7142
|
};
|
|
7141
7143
|
} catch (err) {
|
|
7142
7144
|
throw new Error(`[provider-muse] ${describeError(err)}`);
|
|
@@ -7145,6 +7147,26 @@ async function executeTrackedQuery6(input) {
|
|
|
7145
7147
|
function extractServedModel6(rawResponse) {
|
|
7146
7148
|
return normalizeServedModel(rawResponse.model);
|
|
7147
7149
|
}
|
|
7150
|
+
function extractUsage(rawResponse) {
|
|
7151
|
+
const usage = asRecord(rawResponse.usage);
|
|
7152
|
+
if (!usage) return void 0;
|
|
7153
|
+
const inputTokens = usageCount(usage.input_tokens);
|
|
7154
|
+
const cachedInputTokens = usageCount(asRecord(usage.input_tokens_details)?.cached_tokens);
|
|
7155
|
+
const output = Array.isArray(rawResponse.output) ? rawResponse.output : [];
|
|
7156
|
+
return {
|
|
7157
|
+
inputTokens: Math.max(0, inputTokens - cachedInputTokens),
|
|
7158
|
+
cachedInputTokens,
|
|
7159
|
+
cacheWriteTokens: 0,
|
|
7160
|
+
outputTokens: usageCount(usage.output_tokens),
|
|
7161
|
+
searchCount: output.filter((item) => asRecord(item)?.type === "web_search_call").length
|
|
7162
|
+
};
|
|
7163
|
+
}
|
|
7164
|
+
function extractStopReason(rawResponse) {
|
|
7165
|
+
const reason = asRecord(rawResponse.incomplete_details)?.reason;
|
|
7166
|
+
if (typeof reason === "string" && reason.length > 0) return reason;
|
|
7167
|
+
const status = rawResponse.status;
|
|
7168
|
+
return typeof status === "string" && status.length > 0 ? status : void 0;
|
|
7169
|
+
}
|
|
7148
7170
|
function normalizeResult7(raw) {
|
|
7149
7171
|
return reparseStoredResult5(raw.rawResponse);
|
|
7150
7172
|
}
|
|
@@ -7808,7 +7830,7 @@ function nonBlank(value) {
|
|
|
7808
7830
|
return trimmed ? trimmed : void 0;
|
|
7809
7831
|
}
|
|
7810
7832
|
function resolveBuildCommit(env = process.env) {
|
|
7811
|
-
const embedded = true ? "
|
|
7833
|
+
const embedded = true ? "b528a187897c1efc97f0211c8824961fefac800e" : void 0;
|
|
7812
7834
|
return nonBlank(embedded) ?? nonBlank(env.CANONRY_COMMIT);
|
|
7813
7835
|
}
|
|
7814
7836
|
function resolveInstanceIdentity(env = process.env) {
|
|
@@ -8709,7 +8731,7 @@ var JobRunner = class {
|
|
|
8709
8731
|
for (const provider of apiProviders) {
|
|
8710
8732
|
if (frozenModes[providerKey(provider)] !== ProviderDispatchModes.batch) continue;
|
|
8711
8733
|
if (adapterSupportsBatch(provider.adapter)) batchProviders.add(provider.adapter.name);
|
|
8712
|
-
else log2.warn("run.batch-unsupported", { runId,
|
|
8734
|
+
else log2.warn("run.batch-unsupported", { runId, provider: provider.adapter.name });
|
|
8713
8735
|
}
|
|
8714
8736
|
log2.info("run.plan-dispatch", {
|
|
8715
8737
|
runId,
|
|
@@ -9128,7 +9150,7 @@ var JobRunner = class {
|
|
|
9128
9150
|
location: unit.context ?? void 0
|
|
9129
9151
|
}, { ...config, model });
|
|
9130
9152
|
} catch (err) {
|
|
9131
|
-
log2.warn("batch.build-failed", { runId: ctx.runId, providerName, executionId: unit.executionId, error: describeError(err) });
|
|
9153
|
+
log2.warn("batch.build-failed", { runId: ctx.runId, provider: providerName, executionId: unit.executionId, error: describeError(err) });
|
|
9132
9154
|
syncUnits.push(unit);
|
|
9133
9155
|
continue;
|
|
9134
9156
|
}
|
|
@@ -9141,7 +9163,7 @@ var JobRunner = class {
|
|
|
9141
9163
|
for (const [model, lines] of linesByModel) {
|
|
9142
9164
|
const { chunks, oversized } = chunkBatchLines(lines, maxRequests, capability.maxBytesPerBatch);
|
|
9143
9165
|
if (oversized.length > 0) {
|
|
9144
|
-
log2.warn("batch.line-too-large", { runId: ctx.runId, providerName, model, count: oversized.length, maxBytes: capability.maxBytesPerBatch });
|
|
9166
|
+
log2.warn("batch.line-too-large", { runId: ctx.runId, provider: providerName, model, count: oversized.length, maxBytes: capability.maxBytesPerBatch });
|
|
9145
9167
|
syncUnits.push(...oversized.map((line) => line.unit));
|
|
9146
9168
|
}
|
|
9147
9169
|
for (const chunk of chunks) {
|
|
@@ -9201,7 +9223,7 @@ var JobRunner = class {
|
|
|
9201
9223
|
}
|
|
9202
9224
|
});
|
|
9203
9225
|
} catch (err) {
|
|
9204
|
-
log2.warn("batch.ledger-failed", { runId: ctx.runId, providerName, requests: lines.length, error: describeError(err) });
|
|
9226
|
+
log2.warn("batch.ledger-failed", { runId: ctx.runId, provider: providerName, requests: lines.length, error: describeError(err) });
|
|
9205
9227
|
return lines.map((line) => line.unit);
|
|
9206
9228
|
}
|
|
9207
9229
|
ctx.batchRowIds.push(rowId);
|
|
@@ -9220,7 +9242,7 @@ var JobRunner = class {
|
|
|
9220
9242
|
txDb.update(providerBatches).set({ quotaReleased: lines.length, updatedAt: at }).where(eq3(providerBatches.id, rowId)).run();
|
|
9221
9243
|
if (!sweepLive) releaseDailyQueryQuota(txDb, { scope: reservation.scope, period: reservation.period, count: lines.length });
|
|
9222
9244
|
});
|
|
9223
|
-
log2.warn("batch.submit-refused", { runId: ctx.runId, providerName, batchId: rowId, requests: lines.length, error: message });
|
|
9245
|
+
log2.warn("batch.submit-refused", { runId: ctx.runId, provider: providerName, batchId: rowId, requests: lines.length, error: message });
|
|
9224
9246
|
if (!sweepLive) return [];
|
|
9225
9247
|
this.countDispatched(ctx.providerDispatchCounts, providerName, -lines.length);
|
|
9226
9248
|
return lines.map((line) => line.unit);
|
|
@@ -9230,7 +9252,7 @@ var JobRunner = class {
|
|
|
9230
9252
|
error: `The provider batch of ${lines.length} answer(s) may or may not have been created, so it was not resubmitted and its answers were not recorded: ${message}`,
|
|
9231
9253
|
updatedAt: at
|
|
9232
9254
|
}).where(and3(eq3(providerBatches.id, rowId), eq3(providerBatches.status, ProviderBatchStatuses.submitting))).run();
|
|
9233
|
-
log2.error("batch.submit-unknown", { runId: ctx.runId, providerName, batchId: rowId, requests: lines.length, error: message });
|
|
9255
|
+
log2.error("batch.submit-unknown", { runId: ctx.runId, provider: providerName, batchId: rowId, requests: lines.length, error: message });
|
|
9234
9256
|
return [];
|
|
9235
9257
|
}
|
|
9236
9258
|
const submitted = /* @__PURE__ */ new Date();
|
|
@@ -9246,7 +9268,7 @@ var JobRunner = class {
|
|
|
9246
9268
|
await this.cancelAtProvider([{ id: rowId, provider: providerName, providerBatchId: result2.providerBatchId }]);
|
|
9247
9269
|
return [];
|
|
9248
9270
|
}
|
|
9249
|
-
log2.info("batch.submitted", { runId: ctx.runId, providerName, batchId: rowId, providerBatchId: result2.providerBatchId, model, requests: lines.length });
|
|
9271
|
+
log2.info("batch.submitted", { runId: ctx.runId, provider: providerName, batchId: rowId, providerBatchId: result2.providerBatchId, model, requests: lines.length });
|
|
9250
9272
|
return [];
|
|
9251
9273
|
}
|
|
9252
9274
|
countDispatched(counts, providerName, sent) {
|
|
@@ -9287,14 +9309,14 @@ var JobRunner = class {
|
|
|
9287
9309
|
if (!row.providerBatchId) continue;
|
|
9288
9310
|
const registered = this.registry.get(row.provider);
|
|
9289
9311
|
if (!registered?.adapter.batch) {
|
|
9290
|
-
log2.warn("batch.cancel-unavailable", { batchId: row.id,
|
|
9312
|
+
log2.warn("batch.cancel-unavailable", { batchId: row.id, provider: row.provider });
|
|
9291
9313
|
continue;
|
|
9292
9314
|
}
|
|
9293
9315
|
try {
|
|
9294
9316
|
await registered.adapter.batch.cancel(row.providerBatchId, registered.config);
|
|
9295
|
-
log2.info("batch.cancelled", { batchId: row.id,
|
|
9317
|
+
log2.info("batch.cancelled", { batchId: row.id, provider: row.provider, providerBatchId: row.providerBatchId });
|
|
9296
9318
|
} catch (err) {
|
|
9297
|
-
log2.warn("batch.cancel-failed", { batchId: row.id,
|
|
9319
|
+
log2.warn("batch.cancel-failed", { batchId: row.id, provider: row.provider, error: describeError(err) });
|
|
9298
9320
|
}
|
|
9299
9321
|
}
|
|
9300
9322
|
}
|
|
@@ -9355,7 +9377,7 @@ var JobRunner = class {
|
|
|
9355
9377
|
for await (const line of capability.results(batch.providerBatchId, registered.config)) {
|
|
9356
9378
|
const request = requests.get(line.customId);
|
|
9357
9379
|
if (!request) {
|
|
9358
|
-
log2.warn("batch.unknown-line", { batchId: batch.id,
|
|
9380
|
+
log2.warn("batch.unknown-line", { batchId: batch.id, provider: batch.provider, customId: line.customId });
|
|
9359
9381
|
continue;
|
|
9360
9382
|
}
|
|
9361
9383
|
if (request.outcome !== null) continue;
|
|
@@ -9382,7 +9404,7 @@ var JobRunner = class {
|
|
|
9382
9404
|
raw = adapter.parseTrackedQueryResponse(line.body, resolveProviderModel(adapter.name, request.requestedModel));
|
|
9383
9405
|
} catch (err) {
|
|
9384
9406
|
const error = describeError(err);
|
|
9385
|
-
log2.warn("batch.parse-failed", { runId: batch.runId, batchId: batch.id,
|
|
9407
|
+
log2.warn("batch.parse-failed", { runId: batch.runId, batchId: batch.id, provider: batch.provider, executionId: request.executionId, error });
|
|
9386
9408
|
return { outcome: ProviderBatchRequestOutcomes.parse_failed, error };
|
|
9387
9409
|
}
|
|
9388
9410
|
const unit = {
|
|
@@ -9425,7 +9447,7 @@ var JobRunner = class {
|
|
|
9425
9447
|
updatedAt: at
|
|
9426
9448
|
}).where(and3(eq3(providerBatches.id, batch.id), eq3(providerBatches.status, ProviderBatchStatuses.ended))).run();
|
|
9427
9449
|
const { recordedCount: recorded, notRecorded } = tally;
|
|
9428
|
-
log2.info("batch.ingested", { runId: batch.runId, batchId: batch.id,
|
|
9450
|
+
log2.info("batch.ingested", { runId: batch.runId, batchId: batch.id, provider: batch.provider, recorded, notRecorded, released });
|
|
9429
9451
|
return { kind: "ingested", recorded, notRecorded, released };
|
|
9430
9452
|
});
|
|
9431
9453
|
}
|
|
@@ -9455,7 +9477,7 @@ var JobRunner = class {
|
|
|
9455
9477
|
log2.warn("batch.abandoned-unreadable", {
|
|
9456
9478
|
runId: batch.runId,
|
|
9457
9479
|
batchId: batch.id,
|
|
9458
|
-
|
|
9480
|
+
provider: batch.provider,
|
|
9459
9481
|
recorded: tally.recordedCount,
|
|
9460
9482
|
unread: batch.requestCount - tally.ingestedCount,
|
|
9461
9483
|
released
|
|
@@ -15588,8 +15610,7 @@ var Scheduler = class {
|
|
|
15588
15610
|
log15.warn("run.dispatch-sync-fallback", {
|
|
15589
15611
|
runId,
|
|
15590
15612
|
projectName: project.name,
|
|
15591
|
-
|
|
15592
|
-
providerName: provider,
|
|
15613
|
+
provider,
|
|
15593
15614
|
reason,
|
|
15594
15615
|
message: `${provider} is set to batch for this project but runs sync on this sweep: ${describeBatchIneligibility(provider, reason)}`
|
|
15595
15616
|
});
|
|
@@ -15674,7 +15695,7 @@ var ProviderBatchPoller = class {
|
|
|
15674
15695
|
try {
|
|
15675
15696
|
if (await this.advance(row)) settledRuns.set(row.runId, row.projectId);
|
|
15676
15697
|
} catch (err) {
|
|
15677
|
-
log17.warn("batch.advance-failed", { batchId: row.id, runId: row.runId,
|
|
15698
|
+
log17.warn("batch.advance-failed", { batchId: row.id, runId: row.runId, provider: row.provider, error: describeError(err) });
|
|
15678
15699
|
this.reschedule(row.id, null);
|
|
15679
15700
|
}
|
|
15680
15701
|
}
|
|
@@ -15714,10 +15735,10 @@ var ProviderBatchPoller = class {
|
|
|
15714
15735
|
return ended ? this.ingest({ ...row, status: ProviderBatchStatuses.ended, resultsExpireAt: poll.resultsExpireAt ?? null }) : false;
|
|
15715
15736
|
}
|
|
15716
15737
|
} catch (err) {
|
|
15717
|
-
log17.warn("batch.poll-failed", { batchId: row.id, runId: row.runId,
|
|
15738
|
+
log17.warn("batch.poll-failed", { batchId: row.id, runId: row.runId, provider: row.provider, error: describeError(err) });
|
|
15718
15739
|
}
|
|
15719
15740
|
} else {
|
|
15720
|
-
log17.warn("batch.poll-unavailable", { batchId: row.id, runId: row.runId,
|
|
15741
|
+
log17.warn("batch.poll-unavailable", { batchId: row.id, runId: row.runId, provider: row.provider });
|
|
15721
15742
|
}
|
|
15722
15743
|
this.reschedule(row.id, status);
|
|
15723
15744
|
return this.enforceDeadline(row, registered);
|
|
@@ -15739,12 +15760,12 @@ var ProviderBatchPoller = class {
|
|
|
15739
15760
|
isNull3(providerBatches.cancelRequestedAt)
|
|
15740
15761
|
)).run().changes === 1;
|
|
15741
15762
|
if (!claimed) return false;
|
|
15742
|
-
log17.warn("batch.deadline-passed", { batchId: row.id, runId: row.runId,
|
|
15763
|
+
log17.warn("batch.deadline-passed", { batchId: row.id, runId: row.runId, provider: row.provider, deadlineAt: row.deadlineAt });
|
|
15743
15764
|
if (registered?.adapter.batch && row.providerBatchId) {
|
|
15744
15765
|
try {
|
|
15745
15766
|
await registered.adapter.batch.cancel(row.providerBatchId, registered.config);
|
|
15746
15767
|
} catch (err) {
|
|
15747
|
-
log17.warn("batch.cancel-failed", { batchId: row.id,
|
|
15768
|
+
log17.warn("batch.cancel-failed", { batchId: row.id, provider: row.provider, error: describeError(err) });
|
|
15748
15769
|
}
|
|
15749
15770
|
}
|
|
15750
15771
|
return false;
|
|
@@ -15756,7 +15777,7 @@ var ProviderBatchPoller = class {
|
|
|
15756
15777
|
updatedAt: at
|
|
15757
15778
|
}).where(and17(eq19(providerBatches.id, row.id), eq19(providerBatches.status, ProviderBatchStatuses.submitted))).run().changes === 1;
|
|
15758
15779
|
this.schedule.delete(row.id);
|
|
15759
|
-
if (gaveUp) log17.warn("batch.abandoned-after-deadline", { batchId: row.id, runId: row.runId,
|
|
15780
|
+
if (gaveUp) log17.warn("batch.abandoned-after-deadline", { batchId: row.id, runId: row.runId, provider: row.provider });
|
|
15760
15781
|
return gaveUp;
|
|
15761
15782
|
}
|
|
15762
15783
|
async ingest(row) {
|
|
@@ -15765,7 +15786,7 @@ var ProviderBatchPoller = class {
|
|
|
15765
15786
|
return result2.kind !== "skipped";
|
|
15766
15787
|
} catch (err) {
|
|
15767
15788
|
const error = describeError(err);
|
|
15768
|
-
log17.warn("batch.ingest-failed", { batchId: row.id, runId: row.runId,
|
|
15789
|
+
log17.warn("batch.ingest-failed", { batchId: row.id, runId: row.runId, provider: row.provider, error });
|
|
15769
15790
|
const now = this.now();
|
|
15770
15791
|
const unreadable = row.resultsExpireAt !== null && now >= Date.parse(row.resultsExpireAt);
|
|
15771
15792
|
if (unreadable || now >= Date.parse(row.deadlineAt) + PROVIDER_BATCH_CANCEL_GRACE_MS) {
|
|
@@ -21890,7 +21911,7 @@ async function createServer(opts) {
|
|
|
21890
21911
|
}
|
|
21891
21912
|
for (const name of providersWithUnsupportedBatch(providers, (provider) => adapterMap[provider])) {
|
|
21892
21913
|
log24.warn("provider.batch.unsupported", {
|
|
21893
|
-
|
|
21914
|
+
provider: name,
|
|
21894
21915
|
message: `providers.${name}.batch.enabled is true, but the ${name} adapter has no batch API; its sweeps run sync.`
|
|
21895
21916
|
});
|
|
21896
21917
|
}
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonry/canonry",
|
|
3
|
-
"version": "5.30.
|
|
3
|
+
"version": "5.30.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Self-hosted AI visibility (AEO) platform: track how ChatGPT, Claude, Gemini, and Perplexity cite your domain, join it with Search Console, GA4, server-side traffic, and paid media, and fix what you find through agent tools (CLI, REST, MCP). Local SQLite.",
|
|
6
6
|
"keywords": [
|
|
@@ -87,32 +87,32 @@
|
|
|
87
87
|
"tsup": "^8.5.1",
|
|
88
88
|
"tsx": "^4.19.0",
|
|
89
89
|
"@ainyc/canonry-api-client": "0.0.0",
|
|
90
|
-
"@ainyc/canonry-web": "0.0.0",
|
|
91
90
|
"@ainyc/canonry-api-routes": "0.0.0",
|
|
92
|
-
"@ainyc/canonry-contracts": "0.0.0",
|
|
93
91
|
"@ainyc/canonry-config": "0.0.0",
|
|
92
|
+
"@ainyc/canonry-web": "0.0.0",
|
|
93
|
+
"@ainyc/canonry-contracts": "0.0.0",
|
|
94
94
|
"@ainyc/canonry-db": "0.0.0",
|
|
95
95
|
"@ainyc/canonry-integration-bing": "0.0.0",
|
|
96
96
|
"@ainyc/canonry-integration-cloud-run": "0.0.0",
|
|
97
|
-
"@ainyc/canonry-integration-cloudflare-queue": "0.0.0",
|
|
98
97
|
"@ainyc/canonry-integration-cloudflare-worker": "0.0.0",
|
|
98
|
+
"@ainyc/canonry-integration-google": "0.0.0",
|
|
99
99
|
"@ainyc/canonry-integration-commoncrawl": "0.0.0",
|
|
100
100
|
"@ainyc/canonry-integration-google-ads": "0.0.0",
|
|
101
|
-
"@ainyc/canonry-integration-google": "0.0.0",
|
|
102
|
-
"@ainyc/canonry-integration-google-business-profile": "0.0.0",
|
|
103
|
-
"@ainyc/canonry-integration-google-tag-manager": "0.0.0",
|
|
104
101
|
"@ainyc/canonry-integration-google-places": "0.0.0",
|
|
102
|
+
"@ainyc/canonry-integration-google-tag-manager": "0.0.0",
|
|
105
103
|
"@ainyc/canonry-integration-openai-ads": "0.0.0",
|
|
104
|
+
"@ainyc/canonry-integration-google-business-profile": "0.0.0",
|
|
105
|
+
"@ainyc/canonry-integration-cloudflare-queue": "0.0.0",
|
|
106
106
|
"@ainyc/canonry-integration-traffic": "0.0.0",
|
|
107
|
-
"@ainyc/canonry-intelligence": "0.0.0",
|
|
108
107
|
"@ainyc/canonry-integration-wordpress": "0.0.0",
|
|
109
|
-
"@ainyc/canonry-provider-cdp": "0.0.0",
|
|
110
108
|
"@ainyc/canonry-provider-claude": "0.0.0",
|
|
111
|
-
"@ainyc/canonry-provider-
|
|
109
|
+
"@ainyc/canonry-provider-cdp": "0.0.0",
|
|
110
|
+
"@ainyc/canonry-intelligence": "0.0.0",
|
|
112
111
|
"@ainyc/canonry-provider-local": "0.0.0",
|
|
113
112
|
"@ainyc/canonry-provider-muse": "0.0.0",
|
|
114
|
-
"@ainyc/canonry-provider-perplexity": "0.0.0",
|
|
115
113
|
"@ainyc/canonry-provider-openai": "0.0.0",
|
|
114
|
+
"@ainyc/canonry-provider-gemini": "0.0.0",
|
|
115
|
+
"@ainyc/canonry-provider-perplexity": "0.0.0",
|
|
116
116
|
"@ainyc/canonry-integration-typesafe": "0.0.0"
|
|
117
117
|
},
|
|
118
118
|
"scripts": {
|