@sentry/junior 0.284.0 → 0.286.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.
- package/dist/{adapter-CW5UW7vL.js → adapter-JQZaJ-B_.js} +37 -3
- package/dist/{admin-DUWN8zZX.js → admin-Dm2bimJ-.js} +1 -1
- package/dist/{agent-runner-Cqr21pOU.js → agent-runner-DGCwOEyL.js} +2180 -2735
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +8 -7
- package/dist/api.d.ts +1 -1
- package/dist/api.js +166 -90
- package/dist/{app-CvGalMxi.d.ts → app-BKq0JzWx.d.ts} +2 -3
- package/dist/app.d.ts +1 -1
- package/dist/app.js +225 -188
- package/dist/{assistant-reply-CFE-OZMS.js → assistant-reply-CAPafcUY.js} +1 -1
- package/dist/{automation-Zvx_I9Z5.js → automation-B-jJN_gM.js} +1 -1
- package/dist/{background-compaction-queue-CHFzrQbS.js → background-compaction-queue-Btu2oab_.js} +137 -3
- package/dist/{briefs-Cx7mkfSk.js → briefs-UMeYehUe.js} +5 -5
- package/dist/{catalog-runtime-dKOVbR7l.js → catalog-runtime-Bym8GVdh.js} +1 -1
- package/dist/cli/chat.js +19 -16
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +3 -0
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +5 -6
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +12 -17
- package/dist/{client-CMyH5rDz.js → client-B0aAs7wC.js} +2 -2
- package/dist/{config-Dt3CpG17.js → config-B9f9Lqo5.js} +1 -1
- package/dist/{connections-CCHPybZP.js → connections-CQ7p0aNJ.js} +16 -50
- package/dist/{conversation-DdT7SNar.js → conversation-BusI2uzj.js} +68 -7
- package/dist/{conversation-pending-messages-Dct5pheX.js → conversation-pending-messages-DwehU0Fd.js} +1 -1
- package/dist/{conversation-privacy-BpHHhEVp.js → conversation-privacy-Cd_nZZBM.js} +1 -1
- package/dist/{credential-sync-BBPw8dam.js → credential-sync-DmiJi_At.js} +13 -13
- package/dist/{db-D7CCwAo8.d.ts → db-C5zi4ecs.d.ts} +18 -2
- package/dist/{executor-CyIwHz9r.js → executor-Dipi2Ixl.js} +19 -17
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-Qo-7xGp1.js → logging-CMFhLLj4.js} +1 -1
- package/dist/{media-Bu9C6lz0.js → media-B-BpXo41.js} +14 -2
- package/dist/{message-DFbtOWqv.js → message-D1xLljUF.js} +13 -23
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +2 -3
- package/dist/{oauth-callback-server-BB1gixWo.js → oauth-callback-server-DCAFIUQr.js} +2 -2
- package/dist/{projection-0UcUeuzn.js → projection-CoeMNxJ4.js} +545 -262
- package/dist/{prompt-CCtaGgbI.js → prompt-C9OQEfan.js} +8 -6
- package/dist/{registry-DOnPkI8g.js → registry-u-sFYtx_.js} +1 -1
- package/dist/{reporting-window-B-QP9zX1.js → reporting-window-B4TwyuJo.js} +14 -14
- package/dist/{resolve-Di3omymY.js → resolve-DYqgL3Eo.js} +3 -3
- package/dist/result-CescSwAw.js +299 -0
- package/dist/result-event-type-DD6BAgT7.js +11 -0
- package/dist/{runner-CnX_dTKw.js → runner-Cr67a8TB.js} +16 -12
- package/dist/{sandbox-egress-signals-CtxLJmmg.js → sandbox-egress-signals-DLOazy5W.js} +1 -1
- package/dist/{schema-Bn3miEd_.js → schema-BUSi3sgv.js} +63 -5
- package/dist/{schema-B017enNE.d.ts → schema-Ih60j59-.d.ts} +194 -220
- package/dist/{service-account-KhZIqXRi.js → service-account-CGEqz9wG.js} +3 -3
- package/dist/{service-account-ewDAx4Mx.js → service-account-CsKxktLk.js} +3 -3
- package/dist/session-stop-CGz5DByb.js +2926 -0
- package/dist/{skills-CKyotM4g.js → skills-COCqf61f.js} +2 -2
- package/dist/{spawn-D5D2MQdz.js → spawn-C8F_iXWO.js} +13 -2
- package/dist/{stop-BSKRTaRS.js → stop-GyFZkHuQ.js} +7730 -7818
- package/dist/{store-ymkEUWe4.js → store-D0-8plWp.js} +30 -5
- package/dist/{turn-session-routing-D_GXfcAG.js → task-runner-xPuQmEot.js} +1440 -994
- package/dist/{store-G3S0kWSD.js → turn-failure-response-BOviBdT-.js} +404 -311
- package/dist/{validation-DJG_wrg2.js → validation-DZDKorGz.js} +1 -1
- package/dist/{version-i1An1eTS.js → version-BTIz7fGi.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-BlpnzZZa.js → viewer-CH-ASQzh.js} +208 -68
- package/dist/{work-BgCW3FDC.js → work-C75_IM5e.js} +311 -100
- package/dist/{worker-BJz1mwYt.js → worker-Dl47I729.js} +6 -6
- package/migrations/0083_conversation_kind.sql +11 -0
- package/migrations/0084_read_position_backfill.sql +25 -0
- package/migrations/0085_child_archived_at.sql +1 -0
- package/migrations/0086_shared_archive.sql +31 -0
- package/migrations/0087_child_location.sql +64 -0
- package/migrations/meta/0083_snapshot.json +4388 -0
- package/migrations/meta/0084_snapshot.json +4388 -0
- package/migrations/meta/0085_snapshot.json +4394 -0
- package/migrations/meta/0086_snapshot.json +4366 -0
- package/migrations/meta/0087_snapshot.json +4366 -0
- package/migrations/meta/_journal.json +35 -0
- package/package.json +5 -4
- package/dist/result-NvndYzCb.js +0 -483
- package/dist/session-stop-D_1SysjC.js +0 -1438
- package/dist/task-queue-BcOHzXxe.js +0 -139
- package/dist/task-runner-B65cDumh.js +0 -290
- package/dist/thread-state-D6rNGQu9.js +0 -173
- package/dist/turn-failure-response-BlO4nuDJ.js +0 -224
- package/dist/turn-lifecycle-BQ8ETk63.js +0 -58
package/dist/{background-compaction-queue-CHFzrQbS.js → background-compaction-queue-Btu2oab_.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as getChatConfig } from "./config-
|
|
2
|
-
import { E as withSpan, m as logInfo, p as logException } from "./logging-
|
|
1
|
+
import { i as getChatConfig } from "./config-B9f9Lqo5.js";
|
|
2
|
+
import { E as withSpan, h as logWarn, m as logInfo, p as logException } from "./logging-CMFhLLj4.js";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
5
5
|
import * as z from "zod";
|
|
@@ -381,6 +381,140 @@ async function sendWorkspaceSnapshotJob(message) {
|
|
|
381
381
|
async function sendNextWorkspaceSnapshotJob(message) {
|
|
382
382
|
await send(message);
|
|
383
383
|
}
|
|
384
|
+
// src/chat/queue/callback.ts
|
|
385
|
+
/** Shared queue callback wiring for signed messages. */
|
|
386
|
+
/** Build the HTTP callback and local-dev consumer for one signed queue. */
|
|
387
|
+
function queueCallback(options) {
|
|
388
|
+
const consume = async (message, metadata) => {
|
|
389
|
+
if (options.skip?.(metadata)) return;
|
|
390
|
+
try {
|
|
391
|
+
await runWithTurnRequestDeadline(() => options.run(message, metadata));
|
|
392
|
+
} catch (error) {
|
|
393
|
+
const reason = options.permanentError?.(error);
|
|
394
|
+
if (!reason) throw error;
|
|
395
|
+
options.onRejected(reason, metadata, error);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
const handler = async (value, metadata) => {
|
|
399
|
+
if (options.skip?.(metadata)) return;
|
|
400
|
+
const checked = options.verify(value);
|
|
401
|
+
if (checked.status === "rejected") {
|
|
402
|
+
options.onRejected(checked.reason, metadata);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (checked.status === "unavailable") throw new Error(`Queue message verification unavailable: ${checked.reason}`);
|
|
406
|
+
await consume(checked.message, metadata);
|
|
407
|
+
};
|
|
408
|
+
const retry = (error, metadata) => {
|
|
409
|
+
const reason = options.permanentError?.(error);
|
|
410
|
+
if (reason) {
|
|
411
|
+
options.onRejected(reason, metadata, error);
|
|
412
|
+
return { acknowledge: true };
|
|
413
|
+
}
|
|
414
|
+
if (options.maxDeliveries !== null && metadata.deliveryCount >= options.maxDeliveries) return { acknowledge: true };
|
|
415
|
+
};
|
|
416
|
+
const consumer = {
|
|
417
|
+
consumerGroup: options.consumerGroup,
|
|
418
|
+
handler,
|
|
419
|
+
retry,
|
|
420
|
+
topic: options.topic,
|
|
421
|
+
visibilityTimeoutSeconds: options.visibilityTimeoutSeconds
|
|
422
|
+
};
|
|
423
|
+
return {
|
|
424
|
+
/** Run a message that an in-process queue already trusts. */
|
|
425
|
+
consume,
|
|
426
|
+
consumer,
|
|
427
|
+
create: () => getQueueProvider().createCallback(consumer),
|
|
428
|
+
registerDev: () => {
|
|
429
|
+
if (process.env.NODE_ENV !== "development") return;
|
|
430
|
+
return getQueueProvider().registerDevConsumer?.(consumer);
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
// src/chat/plugins/task-queue.ts
|
|
435
|
+
/**
|
|
436
|
+
* Delivery for plugin-registered tasks.
|
|
437
|
+
*
|
|
438
|
+
* Plugins register named tasks. This module owns the shared signed message,
|
|
439
|
+
* send path, and HTTP/local callback. Core keeps one topic and one runner.
|
|
440
|
+
*/
|
|
441
|
+
/** Deploy topic name. Keep stable for Vercel queue wiring. */
|
|
442
|
+
const PLUGIN_TASK_QUEUE_TOPIC = "junior_plugin_tasks";
|
|
443
|
+
const PLUGIN_TASK_DEV_CONSUMER_GROUP = "junior_plugin_tasks_dev";
|
|
444
|
+
const PLUGIN_TASK_MAX_DELIVERIES = 5;
|
|
445
|
+
const PLUGIN_TASK_SIGN_CONTEXT = "junior.plugin_task_queue.v1";
|
|
446
|
+
const PLUGIN_TASK_SIGN_VERSION = "v1";
|
|
447
|
+
const pluginTaskParamsSchema = z.object({
|
|
448
|
+
conversationId: z.string().min(1),
|
|
449
|
+
sessionId: z.string().min(1)
|
|
450
|
+
}).strict();
|
|
451
|
+
const pluginTaskSign = {
|
|
452
|
+
context: PLUGIN_TASK_SIGN_CONTEXT,
|
|
453
|
+
schema: z.object({
|
|
454
|
+
name: z.string().min(1),
|
|
455
|
+
params: pluginTaskParamsSchema,
|
|
456
|
+
plugin: z.string().min(1)
|
|
457
|
+
}).strict(),
|
|
458
|
+
signatureVersion: PLUGIN_TASK_SIGN_VERSION,
|
|
459
|
+
parts: (message) => [
|
|
460
|
+
message.plugin,
|
|
461
|
+
message.name,
|
|
462
|
+
message.params.conversationId,
|
|
463
|
+
message.params.sessionId
|
|
464
|
+
]
|
|
465
|
+
};
|
|
466
|
+
/** Build the stable id used for delivery dedupe and tracing. */
|
|
467
|
+
function pluginTaskId(args) {
|
|
468
|
+
return `plugin-task_${createHash("sha256").update(args.plugin).update("\0").update(args.name).update("\0").update(args.params.conversationId).update("\0").update(args.params.sessionId).digest("hex").slice(0, 32)}`;
|
|
469
|
+
}
|
|
470
|
+
/** Sign a plugin task message for tests and local checks. */
|
|
471
|
+
function signPluginTaskQueueMessage(message, nowMs = Date.now()) {
|
|
472
|
+
return signQueueMessage(pluginTaskSign, message, nowMs);
|
|
473
|
+
}
|
|
474
|
+
function verifyPluginTaskQueueMessage(value, nowMs = Date.now()) {
|
|
475
|
+
return verifyQueueMessage(pluginTaskSign, value, nowMs);
|
|
476
|
+
}
|
|
477
|
+
function logPluginTaskQueueMessageRejected(reason, metadata) {
|
|
478
|
+
logWarn("plugin.task.queue_message.rejected", {
|
|
479
|
+
"app.queue.consumer_group": metadata.consumerGroup,
|
|
480
|
+
"app.queue.delivery_count": metadata.deliveryCount,
|
|
481
|
+
"app.queue.message_id": metadata.messageId,
|
|
482
|
+
"app.queue.reject_reason": reason,
|
|
483
|
+
"app.queue.topic_name": metadata.topicName
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
function pluginTaskCallback() {
|
|
487
|
+
return queueCallback({
|
|
488
|
+
consumerGroup: PLUGIN_TASK_DEV_CONSUMER_GROUP,
|
|
489
|
+
maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
|
|
490
|
+
onRejected: logPluginTaskQueueMessageRejected,
|
|
491
|
+
run: async (message) => {
|
|
492
|
+
const { processPluginTask } = await import("./task-runner-xPuQmEot.js").then((n) => n.r);
|
|
493
|
+
await processPluginTask(message);
|
|
494
|
+
},
|
|
495
|
+
topic: PLUGIN_TASK_QUEUE_TOPIC,
|
|
496
|
+
verify: verifyPluginTaskQueueMessage
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
/** Send one plugin task through the shared signed delivery path. */
|
|
500
|
+
async function sendVercelPluginTask(message) {
|
|
501
|
+
await getQueueProvider().send(PLUGIN_TASK_QUEUE_TOPIC, signPluginTaskQueueMessage(message), {
|
|
502
|
+
idempotencyKey: pluginTaskId(message),
|
|
503
|
+
retentionSeconds: QUEUE_SIGNATURE_MAX_AGE_MS / 1e3
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
/** Create the HTTP callback for plugin tasks. */
|
|
507
|
+
function createVercelPluginTaskCallback() {
|
|
508
|
+
return pluginTaskCallback().create();
|
|
509
|
+
}
|
|
510
|
+
/** Return the queue consumer for plugin tasks, for a pulling queue worker. */
|
|
511
|
+
function pluginTaskQueueConsumer() {
|
|
512
|
+
return pluginTaskCallback().consumer;
|
|
513
|
+
}
|
|
514
|
+
/** Register the local-dev consumer for plugin tasks. */
|
|
515
|
+
function registerVercelPluginTaskDevConsumer() {
|
|
516
|
+
return pluginTaskCallback().registerDev();
|
|
517
|
+
}
|
|
384
518
|
// src/chat/services/background-compaction-queue.ts
|
|
385
519
|
/**
|
|
386
520
|
* Messages of background compaction jobs.
|
|
@@ -420,4 +554,4 @@ const vercelBackgroundCompactionQueue = { send: async (message) => {
|
|
|
420
554
|
retentionSeconds: QUEUE_SIGNATURE_MAX_AGE_MS / 1e3
|
|
421
555
|
});
|
|
422
556
|
} };
|
|
423
|
-
export {
|
|
557
|
+
export { ConversationQueueMessageRejectedError as C, getTurnRequestDeadline as S, isConversationQueueMessageRejectedError as T, getVercelConversationWorkQueue as _, PLUGIN_TASK_QUEUE_TOPIC as a, QUEUE_SIGNATURE_MAX_AGE_MS as b, pluginTaskParamsSchema as c, sendVercelPluginTask as d, queueCallback as f, verifyWorkspaceSnapshotJobMessage as g, sendWorkspaceSnapshotJob as h, verifyBackgroundCompactionMessage as i, pluginTaskQueueConsumer as l, sendNextWorkspaceSnapshotJob as m, backgroundCompactionId as n, createVercelPluginTaskCallback as o, WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC as p, vercelBackgroundCompactionQueue as r, pluginTaskId as s, BACKGROUND_COMPACTION_QUEUE_TOPIC as t, registerVercelPluginTaskDevConsumer as u, resolveConversationWorkQueueTopic as v, conversationQueueMessageSchema as w, getQueueProvider as x, verifyConversationQueueMessage as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as completeObject } from "./client-
|
|
2
|
-
import {
|
|
3
|
-
import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-
|
|
1
|
+
import { i as completeObject } from "./client-B0aAs7wC.js";
|
|
2
|
+
import { K as parseBriefInput, V as briefCodeChangeSchema, W as briefResourceLabel, d as conversationEventPageSchema, l as conversationDetailReportSchema } from "./conversation-BusI2uzj.js";
|
|
3
|
+
import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-C9OQEfan.js";
|
|
4
4
|
import { CLI_USAGE } from "./cli/run.js";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import * as z from "zod";
|
|
@@ -174,7 +174,7 @@ function briefInputFromSnapshot(snapshot, throughIndex) {
|
|
|
174
174
|
return bounded ? [bounded] : [];
|
|
175
175
|
}),
|
|
176
176
|
resources: (detail.annotations ?? []).flatMap((annotation) => annotation.url !== null && Date.parse(annotation.createdAt) <= boundaryMs ? [{
|
|
177
|
-
label: annotation
|
|
177
|
+
label: briefResourceLabel(annotation),
|
|
178
178
|
url: annotation.url,
|
|
179
179
|
...annotation.status ? { status: annotation.status } : void 0
|
|
180
180
|
}] : [])
|
|
@@ -263,7 +263,7 @@ async function parseRunOptions(argv) {
|
|
|
263
263
|
* token.
|
|
264
264
|
*/
|
|
265
265
|
async function configuredBriefModelId() {
|
|
266
|
-
const { botConfig } = await import("./config-
|
|
266
|
+
const { botConfig } = await import("./config-B9f9Lqo5.js").then((n) => n.r);
|
|
267
267
|
return botConfig.fastModelId;
|
|
268
268
|
}
|
|
269
269
|
function apiUrl(baseUrl, pathname) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { t as createPluginCatalogRuntime } from "./registry-
|
|
2
|
+
import { t as createPluginCatalogRuntime } from "./registry-u-sFYtx_.js";
|
|
3
3
|
// src/chat/plugins/catalog-runtime.ts
|
|
4
4
|
var catalog_runtime_exports = /* @__PURE__ */ __exportAll({ pluginCatalogRuntime: () => pluginCatalogRuntime });
|
|
5
5
|
const pluginCatalogRuntime = createPluginCatalogRuntime();
|
package/dist/cli/chat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-
|
|
1
|
+
import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-DGCwOEyL.js";
|
|
2
2
|
import { t as loadAppPluginSet } from "../plugin-module-Cf5gVPWP.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -99,10 +99,10 @@ async function loadLocalPluginSet() {
|
|
|
99
99
|
async function configureLocalChatPlugins(pluginSet) {
|
|
100
100
|
const [pluginsModule, agentHooksModule, catalogRuntimeModule, validationModule, databaseModule] = await Promise.all([
|
|
101
101
|
import("../plugins-HYh_JOdw.js").then((n) => n.o),
|
|
102
|
-
import("../projection-
|
|
103
|
-
import("../catalog-runtime-
|
|
104
|
-
import("../validation-
|
|
105
|
-
import("../viewer-
|
|
102
|
+
import("../projection-CoeMNxJ4.js").then((n) => n.Vn),
|
|
103
|
+
import("../catalog-runtime-Bym8GVdh.js").then((n) => n.t),
|
|
104
|
+
import("../validation-DZDKorGz.js").then((n) => n.r),
|
|
105
|
+
import("../viewer-CH-ASQzh.js").then((n) => n.v)
|
|
106
106
|
]);
|
|
107
107
|
const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
|
|
108
108
|
const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
|
|
@@ -152,29 +152,32 @@ function localDevServerUrl() {
|
|
|
152
152
|
async function prepareLocalChatRun(io, pluginSet) {
|
|
153
153
|
defaultStateAdapterForLocalChat();
|
|
154
154
|
await configureLocalChatPlugins(pluginSet);
|
|
155
|
-
const { setBriefsConfig } = await import("../projection-
|
|
155
|
+
const { setBriefsConfig } = await import("../projection-CoeMNxJ4.js").then((n) => n.$n);
|
|
156
156
|
setBriefsConfig({ enabled: true });
|
|
157
|
-
const { runLocalAgentTurn } = await import("../runner-
|
|
158
|
-
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-
|
|
157
|
+
const { runLocalAgentTurn } = await import("../runner-Cr67a8TB.js");
|
|
158
|
+
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-DCAFIUQr.js");
|
|
159
159
|
const { createLocalOAuthState } = await import("../oauth-relay-D6xxVywK.js").then((n) => n.t);
|
|
160
|
-
const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-
|
|
161
|
-
const { bindSpawnAgent } = await import("../spawn-
|
|
162
|
-
const { bindMessageAgent } = await import("../message-
|
|
163
|
-
const { createChildConversationWorker } = await import("../result-
|
|
164
|
-
const {
|
|
160
|
+
const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-DLOazy5W.js");
|
|
161
|
+
const { bindSpawnAgent } = await import("../spawn-C8F_iXWO.js").then((n) => n.n);
|
|
162
|
+
const { bindMessageAgent } = await import("../message-D1xLljUF.js").then((n) => n.n);
|
|
163
|
+
const { createChildConversationWorker } = await import("../result-CescSwAw.js").then((n) => n.i);
|
|
164
|
+
const { skipInputAfterConversationStop } = await import("../session-stop-CGz5DByb.js").then((n) => n.a);
|
|
165
165
|
const { createLocalConversationWork } = await import("../conversation-work-BaT_T6EB.js");
|
|
166
|
-
const { processConversationWork } = await import("../worker-
|
|
166
|
+
const { processConversationWork } = await import("../worker-Dl47I729.js").then((n) => n.n);
|
|
167
167
|
let agentRunner;
|
|
168
168
|
const localConversationWork = createLocalConversationWork(async (message) => {
|
|
169
169
|
if (!agentRunner) throw new Error("Local agent runner is not ready");
|
|
170
170
|
const childWorker = createChildConversationWorker(agentRunner, { queue: localConversationWork.queue });
|
|
171
171
|
await processConversationWork(message, {
|
|
172
172
|
queue: localConversationWork.queue,
|
|
173
|
-
run: async (context) =>
|
|
173
|
+
run: async (context) => {
|
|
174
|
+
const stopped = await skipInputAfterConversationStop(context);
|
|
175
|
+
return "skipped" in stopped ? stopped.skipped : await childWorker(stopped.context);
|
|
176
|
+
}
|
|
174
177
|
});
|
|
175
178
|
});
|
|
176
179
|
agentRunner = createAgentRunner(executeAgentRun, {
|
|
177
|
-
bindMessageAgent: (request) => request.
|
|
180
|
+
bindMessageAgent: (request) => request.agentInvocationId ? void 0 : bindMessageAgent(request, { queue: localConversationWork.queue }),
|
|
178
181
|
bindSpawnAgent: (request) => bindSpawnAgent(request, { queue: localConversationWork.queue })
|
|
179
182
|
});
|
|
180
183
|
const oauthCallback = await startLocalOAuthCallbackServer();
|
package/dist/cli/check.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, L as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, M as JUNIOR_HEARTBEAT_ROUTE } from "../logging-
|
|
2
|
-
import { v as parseInlinePluginManifest, y as parsePluginManifest } from "../registry-
|
|
3
|
-
import { i as parseSkillFile } from "../skills-
|
|
1
|
+
import { A as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, L as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, M as JUNIOR_HEARTBEAT_ROUTE } from "../logging-CMFhLLj4.js";
|
|
2
|
+
import { v as parseInlinePluginManifest, y as parsePluginManifest } from "../registry-u-sFYtx_.js";
|
|
3
|
+
import { i as parseSkillFile } from "../skills-COCqf61f.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import fs from "node:fs/promises";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
package/dist/cli/init.js
CHANGED
|
@@ -96,7 +96,10 @@ jobs:
|
|
|
96
96
|
cache: pnpm
|
|
97
97
|
- run: pnpm install
|
|
98
98
|
- run: pnpm check
|
|
99
|
+
# Snapshot warmup needs Vercel OIDC, so the Vercel deploy build runs it.
|
|
99
100
|
- run: pnpm build
|
|
101
|
+
env:
|
|
102
|
+
JUNIOR_SKIP_SNAPSHOT: "1"
|
|
100
103
|
`);
|
|
101
104
|
}
|
|
102
105
|
async function runInit(dir, log = console.log) {
|
package/dist/cli/main.js
CHANGED
|
@@ -25,13 +25,13 @@ async function runChat(argv, pluginSet) {
|
|
|
25
25
|
return await (await import("./chat.js")).runChat(argv, void 0, { pluginSet });
|
|
26
26
|
}
|
|
27
27
|
async function runAdmin(argv) {
|
|
28
|
-
return await (await import("../admin-
|
|
28
|
+
return await (await import("../admin-Dm2bimJ-.js")).runAdmin(argv);
|
|
29
29
|
}
|
|
30
30
|
async function runServiceAccount(argv) {
|
|
31
|
-
return await (await import("../service-account-
|
|
31
|
+
return await (await import("../service-account-CsKxktLk.js")).runServiceAccount(argv);
|
|
32
32
|
}
|
|
33
33
|
async function runBriefs(argv) {
|
|
34
|
-
return await (await import("../briefs-
|
|
34
|
+
return await (await import("../briefs-UMeYehUe.js")).runBriefs(argv);
|
|
35
35
|
}
|
|
36
36
|
function topLevelCommand(argv) {
|
|
37
37
|
return (argv[0] === "--" ? argv.slice(1) : argv)[0];
|
package/dist/cli/plugins.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { S as getDb } from "../viewer-
|
|
3
|
-
import { n as pluginCatalogRuntime } from "../catalog-runtime-
|
|
4
|
-
import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-
|
|
1
|
+
import { Xn as setPlugins, Za as createPluginLogger, Zn as validatePlugins } from "../projection-CoeMNxJ4.js";
|
|
2
|
+
import { S as getDb } from "../viewer-CH-ASQzh.js";
|
|
3
|
+
import { n as pluginCatalogRuntime } from "../catalog-runtime-Bym8GVdh.js";
|
|
4
|
+
import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-DZDKorGz.js";
|
|
5
5
|
import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-HYh_JOdw.js";
|
|
6
6
|
import { t as loadAppPluginSet } from "../plugin-module-Cf5gVPWP.js";
|
|
7
7
|
import { stderr, stdout } from "node:process";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as pluginCatalogRuntime } from "../catalog-runtime-
|
|
3
|
-
import { t as disconnectStateAdapter } from "../adapter-
|
|
4
|
-
import { n as resolve } from "../resolve-
|
|
1
|
+
import { Di as create, Ma as SANDBOX_RUNTIME } from "../projection-CoeMNxJ4.js";
|
|
2
|
+
import { n as pluginCatalogRuntime } from "../catalog-runtime-Bym8GVdh.js";
|
|
3
|
+
import { t as disconnectStateAdapter } from "../adapter-JQZaJ-B_.js";
|
|
4
|
+
import { n as resolve } from "../resolve-DYqgL3Eo.js";
|
|
5
5
|
// src/cli/snapshot-create.ts
|
|
6
|
-
const DEFAULT_RUNTIME = "node22";
|
|
7
6
|
const DEFAULT_TIMEOUT_MS = 6e5;
|
|
8
7
|
function progressMessage(phase) {
|
|
9
8
|
if (phase === "resolve_start") return "Resolving sandbox snapshot profile...";
|
|
@@ -49,7 +48,7 @@ async function runSnapshotCreate(log = console.log) {
|
|
|
49
48
|
log("Skipping sandbox snapshot create (JUNIOR_SKIP_SNAPSHOT=1)");
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
52
|
-
const runtime =
|
|
51
|
+
const runtime = SANDBOX_RUNTIME;
|
|
53
52
|
const timeoutMs = DEFAULT_TIMEOUT_MS;
|
|
54
53
|
try {
|
|
55
54
|
logSnapshotProfile(runtime, log);
|
package/dist/cli/upgrade.d.ts
CHANGED
package/dist/cli/upgrade.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as getChatConfig } from "../config-
|
|
2
|
-
import { t as createJuniorSqlExecutor } from "../executor-
|
|
3
|
-
import { t as createPluginCatalogRuntime } from "../registry-
|
|
1
|
+
import { i as getChatConfig } from "../config-B9f9Lqo5.js";
|
|
2
|
+
import { t as createJuniorSqlExecutor } from "../executor-Dipi2Ixl.js";
|
|
3
|
+
import { t as createPluginCatalogRuntime } from "../registry-u-sFYtx_.js";
|
|
4
4
|
import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-HYh_JOdw.js";
|
|
5
5
|
import { t as loadAppPluginSet } from "../plugin-module-Cf5gVPWP.js";
|
|
6
6
|
import { basename, dirname, join, resolve } from "node:path";
|
|
@@ -158,17 +158,16 @@ const NEON_POOLER_SUFFIX = "-pooler";
|
|
|
158
158
|
* The migration lock is a session advisory lock. A transaction-mode pooler,
|
|
159
159
|
* such as Neon's `-pooler` endpoint, keeps that lock on its server session
|
|
160
160
|
* after the client leaves. The next upgrade on another session then waits,
|
|
161
|
-
* and one on the same session takes the lock again. For Neon, use
|
|
162
|
-
*
|
|
163
|
-
*
|
|
161
|
+
* and one on the same session takes the lock again. For Neon, use the
|
|
162
|
+
* `DATABASE_URL` host without the `-pooler` suffix. The direct endpoint takes
|
|
163
|
+
* the same user, password, database, and parameters, so upgrade always
|
|
164
|
+
* migrates the database that `DATABASE_URL` names.
|
|
164
165
|
*/
|
|
165
|
-
function readMigrationDatabaseUrl(
|
|
166
|
-
if (
|
|
167
|
-
const
|
|
168
|
-
if (unpooledUrl) return unpooledUrl;
|
|
169
|
-
const url = new URL(args.databaseUrl);
|
|
166
|
+
function readMigrationDatabaseUrl(databaseUrl) {
|
|
167
|
+
if (!URL.canParse(databaseUrl)) return databaseUrl;
|
|
168
|
+
const url = new URL(databaseUrl);
|
|
170
169
|
const [endpoint, ...domain] = url.hostname.split(".");
|
|
171
|
-
if (!endpoint?.endsWith(NEON_POOLER_SUFFIX) || !url.hostname.endsWith(".neon.tech")) return
|
|
170
|
+
if (!endpoint?.endsWith(NEON_POOLER_SUFFIX) || !url.hostname.endsWith(".neon.tech")) return databaseUrl;
|
|
172
171
|
url.hostname = [endpoint.slice(0, -7), ...domain].join(".");
|
|
173
172
|
return url.toString();
|
|
174
173
|
}
|
|
@@ -380,11 +379,7 @@ async function runDatabaseMigrations(context, io) {
|
|
|
380
379
|
async function runUpgrade(io = DEFAULT_IO, options = {}) {
|
|
381
380
|
const { sql } = getChatConfig();
|
|
382
381
|
const sqlExecutor = createJuniorSqlExecutor({
|
|
383
|
-
connectionString: readMigrationDatabaseUrl(
|
|
384
|
-
databaseUrl: sql.databaseUrl,
|
|
385
|
-
driver: sql.driver,
|
|
386
|
-
env: process.env
|
|
387
|
-
}),
|
|
382
|
+
connectionString: readMigrationDatabaseUrl(sql.databaseUrl),
|
|
388
383
|
driver: sql.driver,
|
|
389
384
|
statementTimeoutMs: false
|
|
390
385
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-
|
|
2
|
-
import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-
|
|
1
|
+
import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-CMFhLLj4.js";
|
|
2
|
+
import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-Cd_nZZBM.js";
|
|
3
3
|
import { calculateCost, completeSimple, getEnvApiKey, getModels, registerApiProvider } from "@earendil-works/pi-ai/compat";
|
|
4
4
|
import { stream as streamAnthropic, streamSimple as streamSimpleAnthropic } from "@earendil-works/pi-ai/api/anthropic-messages";
|
|
5
5
|
import { createGatewayProvider } from "@ai-sdk/gateway";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { c as resolveGatewayModel, w as toOptionalTrimmed } from "./client-
|
|
2
|
+
import { c as resolveGatewayModel, w as toOptionalTrimmed } from "./client-B0aAs7wC.js";
|
|
3
3
|
import { AwsClient } from "aws4fetch";
|
|
4
4
|
import { del, get, put } from "@vercel/blob";
|
|
5
5
|
import * as z from "zod";
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as botConfig } from "./config-
|
|
3
|
-
import { C as getSqlExecutor,
|
|
4
|
-
import { u as hasRequiredOAuthScope } from "./registry-
|
|
5
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
6
|
-
import { c as deleteMcpAuthSessionsForUserProvider, l as deleteMcpServerSessionId, u as deleteMcpStoredOAuthCredentials } from "./agent-runner-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { randomBytes, randomUUID } from "node:crypto";
|
|
1
|
+
import { Ri as startOAuthFlow, Z as loadTurnCheckpoint, it as getTurnRecord, rt as failTurnRecord } from "./projection-CoeMNxJ4.js";
|
|
2
|
+
import { n as botConfig } from "./config-B9f9Lqo5.js";
|
|
3
|
+
import { C as getSqlExecutor, G as deleteProviderIdentityForUser, W as deleteProviderIdentityForSlackUser, x as getConversationStore, y as getConversationEventStore } from "./viewer-CH-ASQzh.js";
|
|
4
|
+
import { u as hasRequiredOAuthScope } from "./registry-u-sFYtx_.js";
|
|
5
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-Bym8GVdh.js";
|
|
6
|
+
import { c as deleteMcpAuthSessionsForUserProvider, l as deleteMcpServerSessionId, u as deleteMcpStoredOAuthCredentials } from "./agent-runner-DGCwOEyL.js";
|
|
7
|
+
import { _ as getVercelConversationWorkQueue } from "./background-compaction-queue-Btu2oab_.js";
|
|
8
|
+
import { T as requestConversationWork, h as ensureConversationWake } from "./store-D0-8plWp.js";
|
|
9
|
+
import { mt as resolveTurnSessionRouting } from "./task-runner-xPuQmEot.js";
|
|
10
|
+
import { randomBytes } from "node:crypto";
|
|
12
11
|
import * as z from "zod";
|
|
13
12
|
// src/chat/task-execution/authorized-turn.ts
|
|
14
13
|
/**
|
|
@@ -25,7 +24,7 @@ const authorizationSchema = z.object({
|
|
|
25
24
|
configuration: z.record(z.string(), z.unknown()).optional(),
|
|
26
25
|
toolChannelId: z.string().optional()
|
|
27
26
|
});
|
|
28
|
-
function authorizationKey
|
|
27
|
+
function authorizationKey(turn) {
|
|
29
28
|
return `turn:${turn.turnId}:authorization:${turn.version}`;
|
|
30
29
|
}
|
|
31
30
|
/** Save authorization for this parked boundary without changing model history. */
|
|
@@ -33,7 +32,7 @@ async function recordTurnAuthorization(args) {
|
|
|
33
32
|
const turn = await getTurnRecord(args.conversationId, args.turnId);
|
|
34
33
|
if (!turn || turn.state !== "paused" || turn.resumeReason !== "auth") return;
|
|
35
34
|
await getConversationEventStore().append(args.conversationId, [{
|
|
36
|
-
idempotencyKey: authorizationKey
|
|
35
|
+
idempotencyKey: authorizationKey(turn),
|
|
37
36
|
createdAtMs: Date.now(),
|
|
38
37
|
data: {
|
|
39
38
|
type: "structured_event",
|
|
@@ -53,7 +52,7 @@ async function recordTurnAuthorization(args) {
|
|
|
53
52
|
}
|
|
54
53
|
/** Read authorization for the exact pause; a later auth pause needs its own callback. */
|
|
55
54
|
async function getTurnAuthorization(turn) {
|
|
56
|
-
const event = await getConversationEventStore().loadByIdempotencyKey(turn.conversationId, authorizationKey
|
|
55
|
+
const event = await getConversationEventStore().loadByIdempotencyKey(turn.conversationId, authorizationKey(turn));
|
|
57
56
|
if (event?.data.type !== "structured_event") return void 0;
|
|
58
57
|
return authorizationSchema.parse(event.data.content);
|
|
59
58
|
}
|
|
@@ -91,9 +90,10 @@ async function getPausedTurnRequest(args) {
|
|
|
91
90
|
/** Wake the conversation worker for a paused turn. */
|
|
92
91
|
async function wakePausedTurn(request, options = {}) {
|
|
93
92
|
const nowMs = options.nowMs ?? Date.now();
|
|
93
|
+
const conversation = await (options.conversationStore ?? getConversationStore()).get({ conversationId: request.conversationId });
|
|
94
94
|
await requestConversationWork({
|
|
95
95
|
conversationId: request.conversationId,
|
|
96
|
-
destination: request.destination,
|
|
96
|
+
destination: conversation && conversation.kind !== "root" ? void 0 : request.destination,
|
|
97
97
|
nowMs,
|
|
98
98
|
state: options.state
|
|
99
99
|
});
|
|
@@ -290,40 +290,6 @@ function htmlCallbackResponse(title, message, status, options = {}) {
|
|
|
290
290
|
}
|
|
291
291
|
});
|
|
292
292
|
}
|
|
293
|
-
// src/chat/conversations/web-authorization.ts
|
|
294
|
-
const WEB_AUTHORIZATION_PREFIX = "junior:web_authorization:v1";
|
|
295
|
-
const WEB_AUTHORIZATION_TTL_MS = 864e5;
|
|
296
|
-
function authorizationKey(conversationId, actorId) {
|
|
297
|
-
return `${WEB_AUTHORIZATION_PREFIX}:${conversationId}:${actorId}`;
|
|
298
|
-
}
|
|
299
|
-
/** Build authorization delivery for one web turn. */
|
|
300
|
-
function createWebAuthorization(args) {
|
|
301
|
-
return {
|
|
302
|
-
createState: async () => randomUUID(),
|
|
303
|
-
deliver: async (request) => {
|
|
304
|
-
await getStateAdapter().set(authorizationKey(args.conversationId, args.actorId), JSON.stringify({
|
|
305
|
-
...request,
|
|
306
|
-
...args
|
|
307
|
-
}), WEB_AUTHORIZATION_TTL_MS);
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
/** Read the pending authorization request for one web actor. */
|
|
312
|
-
async function getWebAuthorization(args) {
|
|
313
|
-
const value = await getStateAdapter().get(authorizationKey(args.conversationId, args.actorId));
|
|
314
|
-
if (typeof value !== "string") return void 0;
|
|
315
|
-
try {
|
|
316
|
-
const parsed = JSON.parse(value);
|
|
317
|
-
if (parsed.actorId !== args.actorId || parsed.conversationId !== args.conversationId || typeof parsed.authorizationUrl !== "string" || typeof parsed.label !== "string" || typeof parsed.completionText !== "string") return;
|
|
318
|
-
return parsed;
|
|
319
|
-
} catch {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
/** Remove a web authorization request after the parked turn continues. */
|
|
324
|
-
async function deleteWebAuthorization(args) {
|
|
325
|
-
await getStateAdapter().delete(authorizationKey(args.conversationId, args.actorId));
|
|
326
|
-
}
|
|
327
293
|
// src/chat/credentials/unlink-provider.ts
|
|
328
294
|
/** Remove one provider connection and its exact stored account identity. */
|
|
329
295
|
async function unlinkProvider(userId, provider, userTokenStore, slackTeamId) {
|
|
@@ -401,4 +367,4 @@ async function disconnectConnection(userId, provider, userTokenStore) {
|
|
|
401
367
|
if (tokens?.account) await deleteProviderIdentityForUser(getSqlExecutor(), userId, provider, tokens.account.id);
|
|
402
368
|
await unlinkProvider(userId, provider, userTokenStore);
|
|
403
369
|
}
|
|
404
|
-
export { startConnection as a,
|
|
370
|
+
export { startConnection as a, createPausedTurns as c, wakePausedTurn as d, getTurnAuthorization as f, readConnectedOAuthTokens as i, getPausedTurnRequest as l, isConnectableProvider as n, unlinkProvider as o, listConnections as r, htmlCallbackResponse as s, disconnectConnection as t, wakeAuthorizedTurn as u };
|