@sentry/junior 0.267.0 → 0.269.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/README.md +2 -9
- package/dist/{actor-DZSokpwj.js → actor-CP9K2Idu.js} +2 -1
- package/dist/{adapter-BybMEezj.js → adapter-2-CG25be.js} +3 -51
- package/dist/{admin-DOs1_EiW.js → admin-DSs8S5Uy.js} +1 -1
- package/dist/{agent-invocations-CxKldAeB.js → agent-invocations-C1RNOCs8.js} +2 -0
- package/dist/{agent-runner-DgNATN4D.js → agent-runner-CrDrPUtY.js} +3411 -1640
- package/dist/api/schema.d.ts +2 -5630
- package/dist/api/schema.js +7 -7
- package/dist/api.d.ts +3 -1
- package/dist/api.js +268 -287
- package/dist/{app-DAB3fzyp.d.ts → app-BrMMzjYm.d.ts} +10 -3
- package/dist/app.d.ts +1 -1
- package/dist/app.js +371 -223
- package/dist/{automation-CmeFBSEh.js → automation-p87hg_AV.js} +74 -74
- package/dist/{briefs-CWKjka7v.js → briefs-PtODdLNu.js} +4 -4
- package/dist/{catalog-runtime-cMlAI5LY.js → catalog-runtime-BsoSmTM0.js} +1 -1
- package/dist/cli/chat.js +16 -26
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +5 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-BjgbMawj.js → client-Cqf4TboL.js} +20 -15
- package/dist/{config-CdB6yJj5.js → config-CPsE4T5L.js} +2 -2
- package/dist/{connections-RE_65jzK.js → connections-upFXLmhG.js} +10 -11
- package/dist/{conversation-DSo310Ps.js → conversation-CTpD_PGk.js} +7 -84
- package/dist/{conversation-privacy-BzgJC5k0.js → conversation-privacy-D6zJc8ff.js} +1 -1
- package/dist/{credential-sync-DhEGEpgq.js → credential-sync-CS_6IC-f.js} +30 -34
- package/dist/{credentialed-CIGwoLU2.js → credentialed-BU-OW7HP.js} +577 -74
- package/dist/{store-B8CABbmR.d.ts → db-BzOCzVb1.d.ts} +17 -7
- package/dist/{executor-VYrx_K4w.js → executor-CNS7ONt-.js} +78 -4
- package/dist/instrumentation.js +2 -2
- package/dist/{assistant-reply-CT7VcXQe.js → interruption-marker-g6Xup3Fk.js} +8 -2
- package/dist/{job-queue-C0BZSa7r.js → job-queue-DI-k-Bbk.js} +2 -2
- package/dist/{list-1XQP-o6K.js → list-CGoQdXTp.js} +429 -1401
- package/dist/locks-D-0h111u.js +48 -0
- package/dist/{logging-DuZ1A4ab.js → logging-n7knse-O.js} +1 -1
- package/dist/{history-C84mlAwO.js → media-85PDJxO_.js} +83 -1
- package/dist/{message-NKSbbnA6.js → message-BpaWd8TT.js} +4 -4
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-qAHLPtml.js → oauth-callback-server-CpGmEw_i.js} +2 -2
- package/dist/{prompt-BW9jFsqZ.js → prompt-BlQB0QQt.js} +1 -1
- package/dist/{registry-FQutO926.js → registry-By36_xsm.js} +2 -2
- package/dist/reporting-schema-CZREhYc-.js +104 -0
- package/dist/reporting-window-CVarfId9.js +255 -0
- package/dist/{resolve-Bk4yeuHy.js → resolve-CUIBcdPd.js} +3 -3
- package/dist/{result-B9e9ATOU.js → result-BemsOMOO.js} +31 -12
- package/dist/{runner-C3S2ObH-.js → runner-BVok7PAA.js} +12 -11
- package/dist/{sandbox-egress-signals-DqpGzzMB.js → sandbox-egress-signals-BSUWQI95.js} +1 -1
- package/dist/{schema-X7Fj4fv1.js → schema-ChnFo5f2.js} +98 -6
- package/dist/schema-jK4-1u_H.d.ts +5927 -0
- package/dist/{service-account-Do30HUNv.js → service-account-DHvlLnZw.js} +4 -3
- package/dist/{service-account-BQasl-qq.js → service-account-hMmESDcr.js} +3 -3
- package/dist/{session-stop-DkOjt46_.js → session-stop-BQW_iFcd.js} +499 -23
- package/dist/{skills-CQHrwfOa.js → skills-DmJJIuLF.js} +2 -2
- package/dist/{spawn-BHuqN14f.js → spawn-ChCm46i-.js} +2 -2
- package/dist/{store-6EetVP-m.js → store-1DVhoKOL.js} +4 -4
- package/dist/{store-DvNZIsCr.js → store-DCo2n5iJ.js} +3 -3
- package/dist/{task-queue-B0DLgd2P.js → task-queue-HMC4QjFm.js} +3 -3
- package/dist/task-runner-cA6yjn_E.js +269 -0
- package/dist/{thread-state-DRmdJ2QN.js → thread-state-CHy8LS0C.js} +8 -18
- package/dist/{turn-failure-response-G11cs2gE.js → turn-failure-response-Dr7erLWs.js} +11 -16
- package/dist/{turn-lifecycle-OzLIwvi1.js → turn-lifecycle-bf2fIYi_.js} +1 -1
- package/dist/{tasks-0ilmuCux.js → turn-session-routing-BqO0qXLk.js} +959 -44
- package/dist/{validation-CxEmt1id.js → validation-DHR1ivfh.js} +1 -1
- package/dist/{version-Bapedn4A.js → version-CXCHLgWm.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-DrN3oC2X.js → viewer-DSbD6DF6.js} +503 -241
- package/dist/{work-DUQoNcqP.js → work-BE_qTYGi.js} +17 -36
- package/dist/{worker-D1l4Ugk0.js → worker-Cm9_sWXg.js} +15 -7
- package/migrations/0065_user_customization.sql +1 -0
- package/migrations/0066_review_items.sql +53 -0
- package/migrations/0067_review_item_dedupe_tenant.sql +2 -0
- package/migrations/0068_review_item_slack_cards.sql +10 -0
- package/migrations/0069_system_identity.sql +25 -0
- package/migrations/0070_review_item_foreign_keys.sql +5 -0
- package/migrations/AGENTS.md +17 -0
- package/migrations/meta/0065_snapshot.json +3511 -0
- package/migrations/meta/0066_snapshot.json +4099 -0
- package/migrations/meta/0067_snapshot.json +3921 -0
- package/migrations/meta/0068_snapshot.json +4176 -0
- package/migrations/meta/0069_snapshot.json +3979 -0
- package/migrations/meta/0070_snapshot.json +3997 -0
- package/migrations/meta/_journal.json +42 -0
- package/package.json +5 -5
- package/dist/db-Bg-zC3r5.d.ts +0 -5
- package/dist/history-BgI33Kie.d.ts +0 -78
- package/dist/images-CecjXAAz.js +0 -64
- package/dist/task-runner-B-PD_JOj.js +0 -1074
- package/dist/turn-session-routing-Dyut9l7Y.js +0 -76
- package/dist/user-input-request-BDFBdF8r.js +0 -116
- package/dist/web-message-id-CJSUiksE.js +0 -236
- package/migrations/README.md +0 -30
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { setTimeout } from "node:timers/promises";
|
|
2
|
+
// src/chat/state/locks.ts
|
|
3
|
+
const ACTIVE_LOCK_TTL_MS = 9e4;
|
|
4
|
+
const MUTATION_LOCK_TTL_MS = 1e4;
|
|
5
|
+
/**
|
|
6
|
+
* Acquire a lock for long-running work that the queued state adapter should
|
|
7
|
+
* keep alive while the owning invocation is still making progress.
|
|
8
|
+
*/
|
|
9
|
+
async function acquireActiveLock(state, threadId) {
|
|
10
|
+
return await state.acquireLock(threadId, ACTIVE_LOCK_TTL_MS);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Run work under one lock, optionally waiting for the current owner.
|
|
14
|
+
* `keepAlive` is for multi-store mutations that must retain ownership until all
|
|
15
|
+
* side effects finish; callers should still fence each blind write.
|
|
16
|
+
*/
|
|
17
|
+
async function withLock(state, key, run, options = {}) {
|
|
18
|
+
const ttlMs = options.ttlMs ?? 9e4;
|
|
19
|
+
const startedAtMs = Date.now();
|
|
20
|
+
let lock;
|
|
21
|
+
while (true) {
|
|
22
|
+
lock = await state.acquireLock(key, ttlMs);
|
|
23
|
+
if (lock) break;
|
|
24
|
+
if (Date.now() - startedAtMs >= (options.waitMs ?? 0)) return { acquired: false };
|
|
25
|
+
await setTimeout(options.retryMs ?? 25, void 0, { ref: false });
|
|
26
|
+
}
|
|
27
|
+
const heartbeat = options.keepAlive ? setInterval(() => void state.extendLock(lock, ttlMs).catch(() => void 0), Math.max(1, Math.floor(ttlMs / 3))) : void 0;
|
|
28
|
+
heartbeat?.unref();
|
|
29
|
+
try {
|
|
30
|
+
return {
|
|
31
|
+
acquired: true,
|
|
32
|
+
value: await run(lock)
|
|
33
|
+
};
|
|
34
|
+
} finally {
|
|
35
|
+
if (heartbeat) clearInterval(heartbeat);
|
|
36
|
+
await state.releaseLock(lock);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Prove lock ownership immediately before a blind write.
|
|
41
|
+
*
|
|
42
|
+
* Whole-record mutations must stop if their lock expired rather than overwrite
|
|
43
|
+
* state committed by a newer owner.
|
|
44
|
+
*/
|
|
45
|
+
async function fenceLock(state, lock, ttlMs = MUTATION_LOCK_TTL_MS) {
|
|
46
|
+
if (!await state.extendLock(lock, ttlMs)) throw new Error(`Lock ownership was lost before write for ${lock.threadId}`);
|
|
47
|
+
}
|
|
48
|
+
export { withLock as a, fenceLock as i, MUTATION_LOCK_TTL_MS as n, acquireActiveLock as r, ACTIVE_LOCK_TTL_MS as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as withScope, d as setTag, f as setUser, h as startSpan, i as getActiveSpan, l as logger, n as captureMessage, p as spanToJSON, s as getTraceData, t as captureException } from "./sentry-MDkYAVPV.js";
|
|
2
|
-
import { t as JUNIOR_VERSION } from "./version-
|
|
2
|
+
import { t as JUNIOR_VERSION } from "./version-CXCHLgWm.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
import { ConfigError, configureSync, getConfig, getLogger } from "@logtape/logtape";
|
|
@@ -522,4 +522,86 @@ const newConversationEventSchema = z.object({
|
|
|
522
522
|
idempotencyKey: z.string().min(1).optional(),
|
|
523
523
|
createdAtMs: z.number().finite()
|
|
524
524
|
}).strict();
|
|
525
|
-
|
|
525
|
+
// src/chat/attachments/media.ts
|
|
526
|
+
const INPUT_IMAGE_TYPES = [
|
|
527
|
+
"image/png",
|
|
528
|
+
"image/jpeg",
|
|
529
|
+
"image/gif",
|
|
530
|
+
"image/webp"
|
|
531
|
+
];
|
|
532
|
+
/** Leading bytes of each accepted image type. `null` matches any byte. */
|
|
533
|
+
const IMAGE_SIGNATURES = [
|
|
534
|
+
{
|
|
535
|
+
mediaType: "image/png",
|
|
536
|
+
bytes: [
|
|
537
|
+
137,
|
|
538
|
+
80,
|
|
539
|
+
78,
|
|
540
|
+
71,
|
|
541
|
+
13,
|
|
542
|
+
10,
|
|
543
|
+
26,
|
|
544
|
+
10
|
|
545
|
+
]
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
mediaType: "image/jpeg",
|
|
549
|
+
bytes: [
|
|
550
|
+
255,
|
|
551
|
+
216,
|
|
552
|
+
255
|
|
553
|
+
]
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
mediaType: "image/gif",
|
|
557
|
+
bytes: [
|
|
558
|
+
71,
|
|
559
|
+
73,
|
|
560
|
+
70,
|
|
561
|
+
56,
|
|
562
|
+
55,
|
|
563
|
+
97
|
|
564
|
+
]
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
mediaType: "image/gif",
|
|
568
|
+
bytes: [
|
|
569
|
+
71,
|
|
570
|
+
73,
|
|
571
|
+
70,
|
|
572
|
+
56,
|
|
573
|
+
57,
|
|
574
|
+
97
|
|
575
|
+
]
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
mediaType: "image/webp",
|
|
579
|
+
bytes: [
|
|
580
|
+
82,
|
|
581
|
+
73,
|
|
582
|
+
70,
|
|
583
|
+
70,
|
|
584
|
+
null,
|
|
585
|
+
null,
|
|
586
|
+
null,
|
|
587
|
+
null,
|
|
588
|
+
87,
|
|
589
|
+
69,
|
|
590
|
+
66,
|
|
591
|
+
80
|
|
592
|
+
]
|
|
593
|
+
}
|
|
594
|
+
];
|
|
595
|
+
/**
|
|
596
|
+
* Detect an accepted image type from file bytes. Use this instead of a file
|
|
597
|
+
* name or declared content type, which can be wrong.
|
|
598
|
+
*/
|
|
599
|
+
function detectImageMediaType(data) {
|
|
600
|
+
return IMAGE_SIGNATURES.find(({ bytes }) => data.length >= bytes.length && bytes.every((byte, index) => byte === null || data[index] === byte))?.mediaType;
|
|
601
|
+
}
|
|
602
|
+
/** Report whether a media type is a raster image accepted by vision models. */
|
|
603
|
+
function isVisionImageMediaType(mediaType) {
|
|
604
|
+
const normalized = mediaType.split(";", 1)[0]?.trim().toLowerCase();
|
|
605
|
+
return normalized ? INPUT_IMAGE_TYPES.some((type) => type === normalized) : false;
|
|
606
|
+
}
|
|
607
|
+
export { sameActorIdentity as _, agentHistoryItemSchema as a, conversationTurnFailureReasonSchema as c, newConversationEventSchema as d, encodeHistoryPayload as f, instructionProvenanceFor as g, instructionActors as h, KNOWN_CONVERSATION_EVENT_TYPES as i, decodeStoredConversationEvent as l, contextProvenance as m, detectImageMediaType as n, conversationEventDataSchema as o, agentInstructionProvenance as p, isVisionImageMediaType as r, conversationTurnFailureCodeSchema as s, INPUT_IMAGE_TYPES as t, historyReplacementSchema as u, usageSchema as v };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import {
|
|
3
|
-
import { P as PARENT_AGENT_TARGET, i as createAgentInvocationForMessage, j as AgentMessageTargetError, o as findChildAgentConversationId, s as getActiveAgentInvocationForConversation } from "./store-
|
|
4
|
-
import {
|
|
5
|
-
import { r as enqueueAgentInvocation } from "./work-
|
|
2
|
+
import { At as actorFromRun, jt as toolInvocationDestination } from "./agent-runner-CrDrPUtY.js";
|
|
3
|
+
import { P as PARENT_AGENT_TARGET, i as createAgentInvocationForMessage, j as AgentMessageTargetError, o as findChildAgentConversationId, s as getActiveAgentInvocationForConversation } from "./store-1DVhoKOL.js";
|
|
4
|
+
import { r as enqueueAgentMessageToParent } from "./result-BemsOMOO.js";
|
|
5
|
+
import { r as enqueueAgentInvocation } from "./work-BE_qTYGi.js";
|
|
6
6
|
// src/chat/agent-invocations/message.ts
|
|
7
7
|
var message_exports = /* @__PURE__ */ __exportAll({ bindMessageAgent: () => bindMessageAgent });
|
|
8
8
|
/**
|
package/dist/nitro.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as JuniorDashboardOptions } from "./app-
|
|
1
|
+
import { i as JuniorDashboardOptions } from "./app-BrMMzjYm.js";
|
|
2
2
|
import { n as JuniorPluginSet } from "./plugins-B_0Cr0MO.js";
|
|
3
3
|
import { withSentryConfig as withSentryConfig$1 } from "@sentry/nitro";
|
|
4
4
|
type SentryNitroConfig = Parameters<typeof withSentryConfig$1>[0];
|
package/dist/nitro.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { A as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, D as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, F as getDeploymentServiceVersion, M as JUNIOR_RETENTION_ROUTE, N as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, O as JUNIOR_HEARTBEAT_CRON_SCHEDULE, j as JUNIOR_RETENTION_CRON_SCHEDULE, k as JUNIOR_HEARTBEAT_ROUTE } from "./logging-
|
|
1
|
+
import { A as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, D as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, F as getDeploymentServiceVersion, M as JUNIOR_RETENTION_ROUTE, N as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, O as JUNIOR_HEARTBEAT_CRON_SCHEDULE, j as JUNIOR_RETENTION_CRON_SCHEDULE, k as JUNIOR_HEARTBEAT_ROUTE } from "./logging-n7knse-O.js";
|
|
2
2
|
import { d as resolvePackageDir, t as discoverInstalledPluginPackageContent, u as isValidPackageName } from "./package-discovery-DJBompdd.js";
|
|
3
|
-
import { o as resolveConversationWorkQueueTopic, t as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./job-queue-
|
|
3
|
+
import { o as resolveConversationWorkQueueTopic, t as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./job-queue-DI-k-Bbk.js";
|
|
4
4
|
import { a as pluginRuntimeRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "./plugins-DOm9Y6qI.js";
|
|
5
|
-
import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-
|
|
5
|
+
import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-HMC4QjFm.js";
|
|
6
6
|
import { n as loadPluginSetFromModule, r as resolvePluginModule } from "./plugin-module-Cf5gVPWP.js";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { cpSync, existsSync, mkdirSync, readdirSync, statSync } from "node:fs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as createUserTokenStore } from "./credentialed-
|
|
2
|
-
import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-
|
|
1
|
+
import { n as createUserTokenStore } from "./credentialed-BU-OW7HP.js";
|
|
2
|
+
import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-CS_6IC-f.js";
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
4
|
// src/chat/local/oauth-callback-server.ts
|
|
5
5
|
const LOCAL_OAUTH_TIMEOUT_MS = 6e5;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { J as conversationBriefSchema, Y as parseBriefInput, q as briefOutcomeStatusSchema } from "./conversation-CTpD_PGk.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
// src/chat/briefs/generate.ts
|
|
4
4
|
const MAX_INPUT_CHARS = 6e4;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as setSpanAttributes, h as logWarn, m as logInfo } from "./logging-
|
|
2
|
-
import {
|
|
1
|
+
import { b as setSpanAttributes, h as logWarn, m as logInfo } from "./logging-n7knse-O.js";
|
|
2
|
+
import { o as isUserActor, s as parseActorUserId } from "./actor-CP9K2Idu.js";
|
|
3
3
|
import { n as normalizePluginPackageNames, o as pluginRoots, t as discoverInstalledPluginPackageContent } from "./package-discovery-DJBompdd.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { z } from "zod";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// src/reporting-schema.ts
|
|
3
|
+
const healthReportSchema = z.object({
|
|
4
|
+
status: z.literal("ok"),
|
|
5
|
+
service: z.string(),
|
|
6
|
+
timestamp: z.string()
|
|
7
|
+
}).strict();
|
|
8
|
+
const pluginSchema = z.object({
|
|
9
|
+
configKeys: z.array(z.string()),
|
|
10
|
+
description: z.string(),
|
|
11
|
+
displayName: z.string(),
|
|
12
|
+
name: z.string()
|
|
13
|
+
}).strict();
|
|
14
|
+
const pluginsSchema = z.array(pluginSchema);
|
|
15
|
+
const skillReportSchema = z.object({
|
|
16
|
+
name: z.string(),
|
|
17
|
+
pluginProvider: z.string().optional()
|
|
18
|
+
}).strict();
|
|
19
|
+
const skillReportsSchema = z.array(skillReportSchema);
|
|
20
|
+
const pluginPackageContentItemReportSchema = z.object({
|
|
21
|
+
dir: z.string(),
|
|
22
|
+
hasMigrationsDir: z.boolean(),
|
|
23
|
+
hasSkillsDir: z.boolean(),
|
|
24
|
+
packageName: z.string()
|
|
25
|
+
}).strict();
|
|
26
|
+
const pluginPackageContentReportSchema = z.object({
|
|
27
|
+
packageNames: z.array(z.string()),
|
|
28
|
+
packages: z.array(pluginPackageContentItemReportSchema),
|
|
29
|
+
manifestRoots: z.array(z.string()),
|
|
30
|
+
skillRoots: z.array(z.string()),
|
|
31
|
+
tracingIncludes: z.array(z.string())
|
|
32
|
+
}).strict();
|
|
33
|
+
const runtimeInfoReportSchema = z.object({
|
|
34
|
+
cwd: z.string(),
|
|
35
|
+
homeDir: z.string(),
|
|
36
|
+
descriptionText: z.string().optional(),
|
|
37
|
+
providers: z.array(z.string()),
|
|
38
|
+
skills: z.array(skillReportSchema),
|
|
39
|
+
packagedContent: pluginPackageContentReportSchema
|
|
40
|
+
}).strict();
|
|
41
|
+
const pluginOperationalToneSchema = z.enum([
|
|
42
|
+
"danger",
|
|
43
|
+
"good",
|
|
44
|
+
"neutral",
|
|
45
|
+
"warning"
|
|
46
|
+
]);
|
|
47
|
+
const pluginOperationalMetricSchema = z.object({
|
|
48
|
+
label: z.string(),
|
|
49
|
+
tone: pluginOperationalToneSchema.optional(),
|
|
50
|
+
value: z.string()
|
|
51
|
+
}).strict();
|
|
52
|
+
const pluginOperationalFieldSchema = z.object({
|
|
53
|
+
key: z.string(),
|
|
54
|
+
label: z.string()
|
|
55
|
+
}).strict();
|
|
56
|
+
const pluginOperationalRecordSchema = z.object({
|
|
57
|
+
id: z.string(),
|
|
58
|
+
tone: pluginOperationalToneSchema.optional(),
|
|
59
|
+
values: z.record(z.string(), z.string())
|
|
60
|
+
}).strict();
|
|
61
|
+
const pluginOperationalRecordSetSchema = z.object({
|
|
62
|
+
fields: z.array(pluginOperationalFieldSchema).optional(),
|
|
63
|
+
emptyText: z.string().optional(),
|
|
64
|
+
records: z.array(pluginOperationalRecordSchema).optional(),
|
|
65
|
+
title: z.string()
|
|
66
|
+
}).strict();
|
|
67
|
+
const pluginOperationalBarChartWidgetSchema = z.object({
|
|
68
|
+
categories: z.array(z.object({
|
|
69
|
+
id: z.string().min(1),
|
|
70
|
+
label: z.string().min(1),
|
|
71
|
+
values: z.record(z.string(), z.number().finite())
|
|
72
|
+
}).strict()).max(100),
|
|
73
|
+
description: z.string().optional(),
|
|
74
|
+
emptyText: z.string().optional(),
|
|
75
|
+
id: z.string().min(1),
|
|
76
|
+
series: z.array(z.object({
|
|
77
|
+
format: z.literal("usd").optional(),
|
|
78
|
+
key: z.string().min(1),
|
|
79
|
+
label: z.string().min(1),
|
|
80
|
+
tone: pluginOperationalToneSchema.optional()
|
|
81
|
+
}).strict()).min(1).max(8),
|
|
82
|
+
timeRangeDays: z.array(z.union([
|
|
83
|
+
z.literal(1),
|
|
84
|
+
z.literal(7),
|
|
85
|
+
z.literal(30),
|
|
86
|
+
z.literal(90)
|
|
87
|
+
])).min(1).max(4).optional(),
|
|
88
|
+
title: z.string().min(1),
|
|
89
|
+
type: z.literal("bar_chart")
|
|
90
|
+
}).strict();
|
|
91
|
+
const pluginOperationalReportSchema = z.object({
|
|
92
|
+
generatedAt: z.string().optional(),
|
|
93
|
+
metrics: z.array(pluginOperationalMetricSchema).optional(),
|
|
94
|
+
recordSets: z.array(pluginOperationalRecordSetSchema).optional(),
|
|
95
|
+
title: z.string().optional(),
|
|
96
|
+
pluginName: z.string(),
|
|
97
|
+
widgets: z.array(pluginOperationalBarChartWidgetSchema).max(12).optional()
|
|
98
|
+
}).strict();
|
|
99
|
+
const pluginOperationalReportFeedSchema = z.object({
|
|
100
|
+
generatedAt: z.string(),
|
|
101
|
+
reports: z.array(pluginOperationalReportSchema),
|
|
102
|
+
source: z.literal("plugins")
|
|
103
|
+
}).strict();
|
|
104
|
+
export { pluginPackageContentReportSchema as a, runtimeInfoReportSchema as c, pluginPackageContentItemReportSchema as i, skillReportSchema as l, pluginOperationalReportFeedSchema as n, pluginSchema as o, pluginOperationalReportSchema as r, pluginsSchema as s, healthReportSchema as t, skillReportsSchema as u };
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// src/api/schema/user-customization.ts
|
|
3
|
+
/** Longest customization text one user can save. */
|
|
4
|
+
const USER_CUSTOMIZATION_MAX_CHARS = 1e3;
|
|
5
|
+
/** Saved customization text. An empty string means none. */
|
|
6
|
+
const userCustomizationTextSchema = z.string().trim().max(USER_CUSTOMIZATION_MAX_CHARS);
|
|
7
|
+
/** Request and response body for the viewer's customization. */
|
|
8
|
+
const userCustomizationSchema = z.object({ customization: userCustomizationTextSchema }).strict();
|
|
9
|
+
// src/chat/conversations/web-message-id.ts
|
|
10
|
+
/**
|
|
11
|
+
* Build the retry-stable Message id shared by web ingress and browser sends.
|
|
12
|
+
* Keep the existing hash and prefix so retries still address stored Messages.
|
|
13
|
+
*/
|
|
14
|
+
async function webMessageId(args) {
|
|
15
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${args.conversationId}\u0000${args.idempotencyKey}`));
|
|
16
|
+
return `api-msg:${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("").slice(0, 24)}`;
|
|
17
|
+
}
|
|
18
|
+
// src/chat/tools/runtime/user-input-request.ts
|
|
19
|
+
const USER_INPUT_LIMITS = {
|
|
20
|
+
maxButtonOptions: 5,
|
|
21
|
+
maxDescriptionChars: 200,
|
|
22
|
+
maxFields: 4,
|
|
23
|
+
maxLabelChars: 75,
|
|
24
|
+
maxOptions: 10,
|
|
25
|
+
maxTextChars: 3e3,
|
|
26
|
+
maxQuestionChars: 3e3,
|
|
27
|
+
minOptions: 2
|
|
28
|
+
};
|
|
29
|
+
const labelSchema = z.string().trim().min(1).max(USER_INPUT_LIMITS.maxLabelChars);
|
|
30
|
+
const descriptionSchema = z.string().trim().min(1).max(USER_INPUT_LIMITS.maxDescriptionChars).optional();
|
|
31
|
+
const optionSchema = z.object({
|
|
32
|
+
label: labelSchema.describe("Short choice text, such as `Accept` or `Decline`. The answer uses this exact text."),
|
|
33
|
+
description: descriptionSchema.describe("Optional short note about what this choice does.")
|
|
34
|
+
});
|
|
35
|
+
const fieldBase = {
|
|
36
|
+
id: z.string().regex(/^[a-z][a-z0-9_]{0,31}$/).describe("Stable key for this field, such as `approach`."),
|
|
37
|
+
label: labelSchema.describe("Short field name, such as `Approach`."),
|
|
38
|
+
description: descriptionSchema.describe("Optional short help text for this field.")
|
|
39
|
+
};
|
|
40
|
+
const optionsSchema = z.array(optionSchema).min(USER_INPUT_LIMITS.minOptions).max(USER_INPUT_LIMITS.maxOptions).describe("Choices in display order.");
|
|
41
|
+
const userInputFieldSchema = z.discriminatedUnion("kind", [
|
|
42
|
+
z.object({
|
|
43
|
+
...fieldBase,
|
|
44
|
+
kind: z.literal("choice").describe("The person picks one option."),
|
|
45
|
+
options: optionsSchema
|
|
46
|
+
}),
|
|
47
|
+
z.object({
|
|
48
|
+
...fieldBase,
|
|
49
|
+
kind: z.literal("multi_choice").describe("The person picks any number of options."),
|
|
50
|
+
options: optionsSchema
|
|
51
|
+
}),
|
|
52
|
+
z.object({
|
|
53
|
+
...fieldBase,
|
|
54
|
+
kind: z.literal("text").describe("The person types a short answer.")
|
|
55
|
+
})
|
|
56
|
+
]);
|
|
57
|
+
const userInputRequestSchema = z.object({
|
|
58
|
+
question: z.string().trim().min(1).max(USER_INPUT_LIMITS.maxQuestionChars).describe("The question, in markdown. Include the facts the person needs to decide."),
|
|
59
|
+
fields: z.array(userInputFieldSchema).min(1).max(USER_INPUT_LIMITS.maxFields).describe("What to ask, in display order. Use one `choice` field for a simple decision.")
|
|
60
|
+
}).superRefine((request, context) => {
|
|
61
|
+
const ids = /* @__PURE__ */ new Set();
|
|
62
|
+
for (const field of request.fields) {
|
|
63
|
+
if (ids.has(field.id)) context.addIssue({
|
|
64
|
+
code: "custom",
|
|
65
|
+
message: "Each field needs a different id."
|
|
66
|
+
});
|
|
67
|
+
ids.add(field.id);
|
|
68
|
+
if (field.kind === "text") continue;
|
|
69
|
+
const labels = field.options.map((option) => option.label.toLowerCase());
|
|
70
|
+
if (new Set(labels).size !== labels.length) context.addIssue({
|
|
71
|
+
code: "custom",
|
|
72
|
+
message: "Each choice of a field needs a different label."
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Return the single choice field of a request that a surface can show as
|
|
78
|
+
* one row of buttons, where one click is the whole answer.
|
|
79
|
+
*/
|
|
80
|
+
function buttonUserInputField(request) {
|
|
81
|
+
const [field, ...rest] = request.fields;
|
|
82
|
+
if (rest.length || field?.kind !== "choice") return void 0;
|
|
83
|
+
return field.options.length <= USER_INPUT_LIMITS.maxButtonOptions ? field : void 0;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Keep only answer values that match the request: known field ids, known
|
|
87
|
+
* option labels, one value for a `choice` field, and trimmed text.
|
|
88
|
+
*/
|
|
89
|
+
function normalizeUserInputAnswer(request, answer) {
|
|
90
|
+
const values = {};
|
|
91
|
+
for (const field of request.fields) {
|
|
92
|
+
const raw = (answer.values[field.id] ?? []).map((value) => value.trim()).filter(Boolean);
|
|
93
|
+
if (field.kind === "text") {
|
|
94
|
+
const text = raw.join("\n").slice(0, USER_INPUT_LIMITS.maxTextChars);
|
|
95
|
+
if (text) values[field.id] = [text];
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const picked = field.options.map((option) => option.label).filter((label) => raw.includes(label));
|
|
99
|
+
const kept = field.kind === "choice" ? picked.slice(0, 1) : picked;
|
|
100
|
+
if (kept.length) values[field.id] = kept;
|
|
101
|
+
}
|
|
102
|
+
const other = answer.other?.trim().slice(0, USER_INPUT_LIMITS.maxTextChars);
|
|
103
|
+
return {
|
|
104
|
+
requestId: answer.requestId,
|
|
105
|
+
values,
|
|
106
|
+
...other ? { other } : void 0
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** Return true when an answer has no value and no free text. */
|
|
110
|
+
function isEmptyUserInputAnswer(answer) {
|
|
111
|
+
return !answer.other && Object.keys(answer.values).length === 0;
|
|
112
|
+
}
|
|
113
|
+
function answerLine(text) {
|
|
114
|
+
return text.split("\n").map((line) => line.trim()).filter(Boolean).join("\n");
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Write an answer as the text of the person's message. Slack and the web
|
|
118
|
+
* dashboard both send this text, so the model reads one format. The first
|
|
119
|
+
* line names the request, and each field starts its own line.
|
|
120
|
+
*/
|
|
121
|
+
function formatUserInputAnswer(request, answer) {
|
|
122
|
+
const normalized = normalizeUserInputAnswer(request, answer);
|
|
123
|
+
const lines = [`Answer to request ${normalized.requestId}:`];
|
|
124
|
+
for (const field of request.fields) {
|
|
125
|
+
const values = normalized.values[field.id];
|
|
126
|
+
const value = values?.length ? values.join(", ") : "(no answer)";
|
|
127
|
+
lines.push(answerLine(`${field.label} (${field.id}): ${value}`));
|
|
128
|
+
}
|
|
129
|
+
if (normalized.other) lines.push(answerLine(`Other: ${normalized.other}`));
|
|
130
|
+
return lines.join("\n");
|
|
131
|
+
}
|
|
132
|
+
// src/api/reporting-window.ts
|
|
133
|
+
/** Shared UTC day/hour/six-hour windows for dashboard activity series. */
|
|
134
|
+
const HOUR_MS = 36e5;
|
|
135
|
+
const SIX_HOUR_MS = 6 * HOUR_MS;
|
|
136
|
+
const DAY_MS = 24 * HOUR_MS;
|
|
137
|
+
/** Start of the UTC calendar day containing `valueMs`. */
|
|
138
|
+
function startOfUtcDay(valueMs) {
|
|
139
|
+
const date = new Date(valueMs);
|
|
140
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
141
|
+
return date;
|
|
142
|
+
}
|
|
143
|
+
/** Start of the UTC hour containing `valueMs`. */
|
|
144
|
+
function startOfUtcHour(valueMs) {
|
|
145
|
+
const date = new Date(valueMs);
|
|
146
|
+
date.setUTCMinutes(0, 0, 0);
|
|
147
|
+
return date;
|
|
148
|
+
}
|
|
149
|
+
/** Start of the UTC 6-hour bucket containing `valueMs` (00/06/12/18). */
|
|
150
|
+
function startOfUtcSixHour(valueMs) {
|
|
151
|
+
const date = startOfUtcHour(valueMs);
|
|
152
|
+
date.setUTCHours(Math.floor(date.getUTCHours() / 6) * 6, 0, 0, 0);
|
|
153
|
+
return date;
|
|
154
|
+
}
|
|
155
|
+
/** UTC day key `YYYY-MM-DD`. */
|
|
156
|
+
function utcDayKey(value) {
|
|
157
|
+
return (typeof value === "number" ? new Date(value) : value).toISOString().slice(0, 10);
|
|
158
|
+
}
|
|
159
|
+
/** UTC hour key `YYYY-MM-DDTHH`. */
|
|
160
|
+
function utcHourKey(value) {
|
|
161
|
+
return (typeof value === "number" ? new Date(value) : value).toISOString().slice(0, 13);
|
|
162
|
+
}
|
|
163
|
+
/** UTC 6-hour bucket key `YYYY-MM-DDTHH` at 00/06/12/18. */
|
|
164
|
+
function utcSixHourKey(value) {
|
|
165
|
+
return utcHourKey(startOfUtcSixHour(typeof value === "number" ? value : value.getTime()));
|
|
166
|
+
}
|
|
167
|
+
/** Inclusive trailing UTC day window ending on today's UTC day. */
|
|
168
|
+
function trailingUtcDayWindow(nowMs, dayCount) {
|
|
169
|
+
const end = startOfUtcDay(nowMs);
|
|
170
|
+
const start = new Date(end);
|
|
171
|
+
start.setUTCDate(start.getUTCDate() - (dayCount - 1));
|
|
172
|
+
return {
|
|
173
|
+
end,
|
|
174
|
+
start
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/** Inclusive trailing UTC hour window ending on the current UTC hour. */
|
|
178
|
+
function trailingUtcHourWindow(nowMs, hourCount = 24) {
|
|
179
|
+
const end = startOfUtcHour(nowMs);
|
|
180
|
+
return {
|
|
181
|
+
end,
|
|
182
|
+
start: /* @__PURE__ */ new Date(end.getTime() - (hourCount - 1) * HOUR_MS)
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/** Inclusive trailing UTC 6-hour window ending on the current 6h bucket. */
|
|
186
|
+
function trailingUtcSixHourWindow(nowMs, bucketCount = 28) {
|
|
187
|
+
const end = startOfUtcSixHour(nowMs);
|
|
188
|
+
return {
|
|
189
|
+
end,
|
|
190
|
+
start: /* @__PURE__ */ new Date(end.getTime() - (bucketCount - 1) * SIX_HOUR_MS)
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/** Fill a fixed UTC day window from a sparse map. */
|
|
194
|
+
function fillUtcDays(args) {
|
|
195
|
+
const { end, start } = trailingUtcDayWindow(args.nowMs, args.count);
|
|
196
|
+
const items = [];
|
|
197
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
|
|
198
|
+
const date = utcDayKey(cursor);
|
|
199
|
+
items.push(args.rows.get(date) ?? args.empty(date));
|
|
200
|
+
}
|
|
201
|
+
return items;
|
|
202
|
+
}
|
|
203
|
+
/** Fill a fixed UTC hour window from a sparse map. */
|
|
204
|
+
function fillUtcHours(args) {
|
|
205
|
+
const hourCount = args.count ?? 24;
|
|
206
|
+
const { end, start } = trailingUtcHourWindow(args.nowMs, hourCount);
|
|
207
|
+
const items = [];
|
|
208
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setTime(cursor.getTime() + HOUR_MS)) {
|
|
209
|
+
const date = utcHourKey(cursor);
|
|
210
|
+
items.push(args.rows.get(date) ?? args.empty(date));
|
|
211
|
+
}
|
|
212
|
+
return items;
|
|
213
|
+
}
|
|
214
|
+
/** Fill a fixed UTC 6-hour window from a map of known rows. */
|
|
215
|
+
function fillUtcSixHours(args) {
|
|
216
|
+
const bucketCount = args.count ?? 28;
|
|
217
|
+
const { end, start } = trailingUtcSixHourWindow(args.nowMs, bucketCount);
|
|
218
|
+
const items = [];
|
|
219
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setTime(cursor.getTime() + SIX_HOUR_MS)) {
|
|
220
|
+
const date = utcSixHourKey(cursor);
|
|
221
|
+
items.push(args.rows.get(date) ?? args.empty(date));
|
|
222
|
+
}
|
|
223
|
+
return items;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Sum hour rows into trailing 6-hour buckets.
|
|
227
|
+
* Adds number fields. Keeps other fields from the first row in the bucket.
|
|
228
|
+
* Sets `date` to the 6-hour bucket key.
|
|
229
|
+
*/
|
|
230
|
+
function sumUtcHoursIntoSixHours(args) {
|
|
231
|
+
const bucketCount = args.count ?? 28;
|
|
232
|
+
const bySix = /* @__PURE__ */ new Map();
|
|
233
|
+
for (const hour of args.hours) {
|
|
234
|
+
const key = utcSixHourKey(Date.parse(`${hour.date}:00:00.000Z`));
|
|
235
|
+
const next = {
|
|
236
|
+
...bySix.get(key) ?? args.empty(key),
|
|
237
|
+
date: key
|
|
238
|
+
};
|
|
239
|
+
for (const [field, value] of Object.entries(hour)) {
|
|
240
|
+
if (field === "date") continue;
|
|
241
|
+
if (typeof value === "number") {
|
|
242
|
+
const prior = next[field];
|
|
243
|
+
next[field] = (typeof prior === "number" ? prior : 0) + value;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
bySix.set(key, next);
|
|
247
|
+
}
|
|
248
|
+
return fillUtcSixHours({
|
|
249
|
+
count: bucketCount,
|
|
250
|
+
empty: args.empty,
|
|
251
|
+
nowMs: args.nowMs,
|
|
252
|
+
rows: bySix
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
export { userCustomizationTextSchema as S, normalizeUserInputAnswer as _, fillUtcSixHours as a, USER_CUSTOMIZATION_MAX_CHARS as b, trailingUtcDayWindow as c, utcDayKey as d, utcHourKey as f, isEmptyUserInputAnswer as g, formatUserInputAnswer as h, fillUtcHours as i, trailingUtcHourWindow as l, buttonUserInputField as m, HOUR_MS as n, startOfUtcHour as o, USER_INPUT_LIMITS as p, fillUtcDays as r, sumUtcHoursIntoSixHours as s, DAY_MS as t, trailingUtcSixHourWindow as u, userInputRequestSchema as v, userCustomizationSchema as x, webMessageId as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E as withSpan, b as setSpanAttributes } from "./logging-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { E as withSpan, b as setSpanAttributes } from "./logging-n7knse-O.js";
|
|
2
|
+
import { Kn as runNonInteractiveCommand, Nn as sleep, Qn as SANDBOX_WORKSPACE_ROOT, it as isStale, nt as create, ot as getSandboxProvider, qn as SANDBOX_COMMAND_PATH } from "./credentialed-BU-OW7HP.js";
|
|
3
|
+
import { r as getStateAdapter } from "./adapter-2-CG25be.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
// src/chat/sandbox/resources.ts
|
|
6
6
|
let configuredResources;
|