@sentry/junior 0.286.0 → 0.287.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-JQZaJ-B_.js → adapter-CL-HUKgd.js} +1 -1
- package/dist/{admin-Dm2bimJ-.js → admin-C9urXVfi.js} +2 -1
- package/dist/{agent-runner-DGCwOEyL.js → agent-runner-Bfnw551N.js} +644 -312
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +7 -7
- package/dist/api.d.ts +1 -1
- package/dist/api.js +36 -53
- package/dist/{app-BKq0JzWx.d.ts → app-DBY5TnfY.d.ts} +2 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +62 -29
- package/dist/{assistant-reply-CAPafcUY.js → assistant-reply-u_PRYzuz.js} +1 -1
- package/dist/{automation-B-jJN_gM.js → automation-DksGNDRO.js} +3 -6
- package/dist/{background-compaction-queue-Btu2oab_.js → background-compaction-queue-CYI909P5.js} +3 -3
- package/dist/{briefs-UMeYehUe.js → briefs-DaXiMWzT.js} +6 -5
- package/dist/{catalog-runtime-Bym8GVdh.js → catalog-runtime-BCIuBe4d.js} +1 -1
- package/dist/cli/chat.js +14 -14
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -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-B0aAs7wC.js → config-CkHcUMN7.js} +580 -3
- package/dist/{connections-CQ7p0aNJ.js → connections-BnIj0wtx.js} +9 -9
- package/dist/{conversation-BusI2uzj.js → conversation-E7ZPJx2H.js} +8 -1
- package/dist/{conversation-pending-messages-DwehU0Fd.js → conversation-pending-messages-DVch6YQw.js} +2 -5
- package/dist/{conversation-privacy-Cd_nZZBM.js → conversation-privacy-DF1hW0ja.js} +1 -1
- package/dist/{credential-sync-DmiJi_At.js → credential-sync-CzMar9hq.js} +13 -13
- package/dist/{viewer-CH-ASQzh.js → db-DJ11eZqq.js} +37 -343
- package/dist/{db-C5zi4ecs.d.ts → db-YDKKDxlh.d.ts} +1 -1
- package/dist/{executor-Dipi2Ixl.js → executor-BY9TB31g.js} +11 -4
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-CMFhLLj4.js → logging-BO5zU6Mt.js} +1 -1
- package/dist/{media-B-BpXo41.js → media-Cz1ZiV1U.js} +2 -2
- package/dist/{message-D1xLljUF.js → message-CsUbuEc8.js} +10 -10
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-DCAFIUQr.js → oauth-callback-server-hiDKK0_n.js} +2 -2
- package/dist/{projection-CoeMNxJ4.js → projection-CL_YWeGf.js} +82 -160
- package/dist/{prompt-C9OQEfan.js → prompt-BHOEQSmf.js} +182 -2
- package/dist/{registry-u-sFYtx_.js → registry-BriFLnaJ.js} +1 -1
- package/dist/{reporting-window-B4TwyuJo.js → reporting-window-B3Ze-Qnt.js} +4 -1
- package/dist/{resolve-DYqgL3Eo.js → resolve-Bt6GgAiA.js} +3 -3
- package/dist/{result-CescSwAw.js → result-Bo1TZu0Q.js} +8 -8
- package/dist/{runner-Cr67a8TB.js → runner-D3YeCQgt.js} +8 -8
- package/dist/{sandbox-egress-signals-DLOazy5W.js → sandbox-egress-signals-CcnSPP4S.js} +1 -1
- package/dist/{schema-BUSi3sgv.js → schema-BWE3RJEB.js} +17 -5
- package/dist/{schema-Ih60j59-.d.ts → schema-C6fsEwjo.d.ts} +46 -1
- package/dist/{service-account-CGEqz9wG.js → service-account-DiQQuuw7.js} +3 -3
- package/dist/{service-account-CsKxktLk.js → service-account-r6fl0b-9.js} +3 -3
- package/dist/{session-stop-CGz5DByb.js → session-stop-B2Nut40V.js} +18 -18
- package/dist/{skills-COCqf61f.js → skills-CD5aJdzg.js} +2 -2
- package/dist/spawn-CalgZQiu.js +79 -0
- package/dist/{stop-GyFZkHuQ.js → stop-kujZLbi0.js} +56 -240
- package/dist/{store-D0-8plWp.js → store-DdIEUL1q.js} +3 -3
- package/dist/{task-runner-xPuQmEot.js → task-runner-D_RDr2Hu.js} +12 -11
- package/dist/{turn-failure-response-BOviBdT-.js → turn-failure-response-B5nV1Er-.js} +16 -11
- package/dist/{validation-DZDKorGz.js → validation-K4pqwoVZ.js} +1 -1
- package/dist/{version-BTIz7fGi.js → version-DBvhk1X9.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/viewer-DrMmFUul.js +337 -0
- package/dist/{work-C75_IM5e.js → work-ljRoODGu.js} +30 -19
- package/dist/{worker-Dl47I729.js → worker-CYO1Q0Js.js} +5 -6
- package/migrations/0088_conversation_unsubscribe.sql +1 -0
- package/migrations/meta/0088_snapshot.json +4372 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +4 -4
- package/dist/config-B9f9Lqo5.js +0 -579
- package/dist/spawn-C8F_iXWO.js +0 -42
|
@@ -617,6 +617,13 @@
|
|
|
617
617
|
"when": 1794088255456,
|
|
618
618
|
"tag": "0087_child_location",
|
|
619
619
|
"breakpoints": true
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
"idx": 88,
|
|
623
|
+
"version": "7",
|
|
624
|
+
"when": 1794165567814,
|
|
625
|
+
"tag": "0088_conversation_unsubscribe",
|
|
626
|
+
"breakpoints": true
|
|
620
627
|
}
|
|
621
628
|
]
|
|
622
629
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.287.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"web-push": "^3.6.7",
|
|
94
94
|
"yaml": "^2.9.0",
|
|
95
95
|
"zod": "^4.5.4",
|
|
96
|
-
"@sentry/junior-plugin-api": "0.
|
|
96
|
+
"@sentry/junior-plugin-api": "0.287.0"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"bullmq": "^6.5.0",
|
|
@@ -129,8 +129,8 @@
|
|
|
129
129
|
"typescript": "^7.0.2",
|
|
130
130
|
"vercel": "^54.4.0",
|
|
131
131
|
"vitest": "^4.1.12",
|
|
132
|
-
"@sentry/junior-
|
|
133
|
-
"@sentry/junior-
|
|
132
|
+
"@sentry/junior-memory": "0.287.0",
|
|
133
|
+
"@sentry/junior-github": "0.287.0",
|
|
134
134
|
"@sentry/junior-testing": "0.0.0"
|
|
135
135
|
},
|
|
136
136
|
"scripts": {
|
package/dist/config-B9f9Lqo5.js
DELETED
|
@@ -1,579 +0,0 @@
|
|
|
1
|
-
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { c as resolveGatewayModel, w as toOptionalTrimmed } from "./client-B0aAs7wC.js";
|
|
3
|
-
import { AwsClient } from "aws4fetch";
|
|
4
|
-
import { del, get, put } from "@vercel/blob";
|
|
5
|
-
import * as z from "zod";
|
|
6
|
-
// src/chat/attachments/memory.ts
|
|
7
|
-
/**
|
|
8
|
-
* Store attachments in process memory, for tests.
|
|
9
|
-
*
|
|
10
|
-
* Objects are lost when the process stops, and each process has its own
|
|
11
|
-
* copy. Do not use this provider for deployed apps.
|
|
12
|
-
*/
|
|
13
|
-
function createMemoryAttachmentStorage() {
|
|
14
|
-
const objects = /* @__PURE__ */ new Map();
|
|
15
|
-
return {
|
|
16
|
-
objects,
|
|
17
|
-
provider: "memory",
|
|
18
|
-
async put(input) {
|
|
19
|
-
objects.set(input.key, Buffer.from(input.body));
|
|
20
|
-
},
|
|
21
|
-
async get(key, range) {
|
|
22
|
-
const body = objects.get(key);
|
|
23
|
-
if (!body) return null;
|
|
24
|
-
const bytes = range ? body.subarray(range.start, range.end + 1) : body;
|
|
25
|
-
return new ReadableStream({ start(controller) {
|
|
26
|
-
controller.enqueue(new Uint8Array(bytes));
|
|
27
|
-
controller.close();
|
|
28
|
-
} });
|
|
29
|
-
},
|
|
30
|
-
async delete(keys) {
|
|
31
|
-
for (const key of keys) objects.delete(key);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
// src/chat/attachments/vercel.ts
|
|
36
|
-
/** Store private conversation attachments in Vercel Blob. */
|
|
37
|
-
function createVercelAttachmentStorage() {
|
|
38
|
-
return {
|
|
39
|
-
provider: "vercel-blob",
|
|
40
|
-
async put(input) {
|
|
41
|
-
await put(input.key, input.body, {
|
|
42
|
-
access: "private",
|
|
43
|
-
addRandomSuffix: false,
|
|
44
|
-
allowOverwrite: true,
|
|
45
|
-
contentType: input.contentType
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
async get(key, range) {
|
|
49
|
-
const result = await get(key, {
|
|
50
|
-
access: "private",
|
|
51
|
-
useCache: false,
|
|
52
|
-
...range ? { headers: { range: rangeHeader(range) } } : void 0
|
|
53
|
-
});
|
|
54
|
-
if (result?.statusCode !== 200) return null;
|
|
55
|
-
if (range && !result.headers.get("content-range")) {
|
|
56
|
-
await result.stream.cancel();
|
|
57
|
-
throw new Error("Vercel Blob get ignored the byte range");
|
|
58
|
-
}
|
|
59
|
-
return result.stream;
|
|
60
|
-
},
|
|
61
|
-
async delete(keys) {
|
|
62
|
-
if (keys.length === 0) return;
|
|
63
|
-
await del(keys);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
// src/chat/attachments/storage.ts
|
|
68
|
-
/** Build the HTTP `Range` request header value for one byte range. */
|
|
69
|
-
function rangeHeader(range) {
|
|
70
|
-
return `bytes=${range.start}-${range.end}`;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Return attachment storage for the configured provider.
|
|
74
|
-
*
|
|
75
|
-
* Callers do not choose a provider. Chat config decides it.
|
|
76
|
-
*/
|
|
77
|
-
function getAttachmentStorage() {
|
|
78
|
-
return createAttachmentStorage(getChatConfig().attachmentStorage);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Create attachment storage for one provider config.
|
|
82
|
-
*
|
|
83
|
-
* Runtime code uses `getAttachmentStorage()`. Call this only to test a
|
|
84
|
-
* provider adapter with its own config.
|
|
85
|
-
*/
|
|
86
|
-
function createAttachmentStorage(config) {
|
|
87
|
-
switch (config.provider) {
|
|
88
|
-
case "vercel-blob": return createVercelAttachmentStorage();
|
|
89
|
-
case "s3": return createS3AttachmentStorage(config.s3);
|
|
90
|
-
case "memory": return createMemoryAttachmentStorage();
|
|
91
|
-
default: throw new Error(`Unsupported attachment storage provider: ${String(config.provider)}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// src/chat/attachments/s3.ts
|
|
95
|
-
function readRequiredSetting(env, name) {
|
|
96
|
-
const value = toOptionalTrimmed(env[name]);
|
|
97
|
-
if (value === void 0) throw new Error(`${name} is required when JUNIOR_ATTACHMENT_STORAGE_PROVIDER is s3`);
|
|
98
|
-
return value;
|
|
99
|
-
}
|
|
100
|
-
/** Read S3 settings from `JUNIOR_S3_*` environment variables. */
|
|
101
|
-
function readS3StorageConfig(env) {
|
|
102
|
-
return {
|
|
103
|
-
accessKeyId: readRequiredSetting(env, "JUNIOR_S3_ACCESS_KEY_ID"),
|
|
104
|
-
bucket: readRequiredSetting(env, "JUNIOR_S3_BUCKET"),
|
|
105
|
-
endpoint: readRequiredSetting(env, "JUNIOR_S3_ENDPOINT"),
|
|
106
|
-
region: toOptionalTrimmed(env.JUNIOR_S3_REGION) ?? "us-east-1",
|
|
107
|
-
secretAccessKey: readRequiredSetting(env, "JUNIOR_S3_SECRET_ACCESS_KEY")
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Path-style object URL. Local S3 servers and AWS S3 both accept it.
|
|
112
|
-
*
|
|
113
|
-
* URL parsing removes `.` and `..` segments, also in `%2e` form. A key with
|
|
114
|
-
* such a segment would address a different object, so reject it.
|
|
115
|
-
*/
|
|
116
|
-
function objectUrl(config, key) {
|
|
117
|
-
const endpoint = config.endpoint.replace(/\/+$/, "");
|
|
118
|
-
const segments = key.split("/");
|
|
119
|
-
if (segments.some((segment) => segment === "." || segment === "..")) throw new Error("S3 object keys cannot contain . or .. path segments");
|
|
120
|
-
const path = segments.map(encodeURIComponent).join("/");
|
|
121
|
-
return `${endpoint}/${encodeURIComponent(config.bucket)}/${path}`;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Read a small S3 response body to the end so the connection is released.
|
|
125
|
-
*
|
|
126
|
-
* Error and empty bodies are small. `body.cancel()` can hang under the test
|
|
127
|
-
* HTTP interceptor, so read the body instead.
|
|
128
|
-
*/
|
|
129
|
-
async function drain(response) {
|
|
130
|
-
await response.arrayBuffer();
|
|
131
|
-
}
|
|
132
|
-
/** Throw on a failed S3 response, and release the response body. */
|
|
133
|
-
async function expectOk(response, operation) {
|
|
134
|
-
await drain(response);
|
|
135
|
-
if (!response.ok) throw new Error(`S3 ${operation} failed with status ${response.status}`);
|
|
136
|
-
}
|
|
137
|
-
/** Store private conversation attachments in an S3-compatible bucket. */
|
|
138
|
-
function createS3AttachmentStorage(config) {
|
|
139
|
-
const client = new AwsClient({
|
|
140
|
-
accessKeyId: config.accessKeyId,
|
|
141
|
-
region: config.region,
|
|
142
|
-
secretAccessKey: config.secretAccessKey,
|
|
143
|
-
service: "s3"
|
|
144
|
-
});
|
|
145
|
-
return {
|
|
146
|
-
provider: "s3",
|
|
147
|
-
async put(input) {
|
|
148
|
-
await expectOk(await client.fetch(objectUrl(config, input.key), {
|
|
149
|
-
body: new Uint8Array(input.body),
|
|
150
|
-
headers: { "content-type": input.contentType },
|
|
151
|
-
method: "PUT"
|
|
152
|
-
}), "put");
|
|
153
|
-
},
|
|
154
|
-
async get(key, range) {
|
|
155
|
-
const response = await client.fetch(objectUrl(config, key), range ? { headers: { range: rangeHeader(range) } } : void 0);
|
|
156
|
-
if (response.status === 404) {
|
|
157
|
-
await drain(response);
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
if (!response.ok) await expectOk(response, "get");
|
|
161
|
-
if (range && response.status !== 206) {
|
|
162
|
-
await drain(response);
|
|
163
|
-
throw new Error(`S3 get ignored the byte range with status ${response.status}`);
|
|
164
|
-
}
|
|
165
|
-
return response.body;
|
|
166
|
-
},
|
|
167
|
-
async delete(keys) {
|
|
168
|
-
await Promise.all(keys.map(async (key) => {
|
|
169
|
-
const response = await client.fetch(objectUrl(config, key), { method: "DELETE" });
|
|
170
|
-
if (response.status === 404) {
|
|
171
|
-
await drain(response);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
await expectOk(response, "delete");
|
|
175
|
-
}));
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
// src/chat/attachments/config.ts
|
|
180
|
-
/** Read attachment storage settings from environment variables. */
|
|
181
|
-
function readAttachmentStorageConfig(env) {
|
|
182
|
-
const provider = toOptionalTrimmed(env.JUNIOR_ATTACHMENT_STORAGE_PROVIDER) ?? "vercel-blob";
|
|
183
|
-
switch (provider) {
|
|
184
|
-
case "vercel-blob":
|
|
185
|
-
case "memory": return { provider };
|
|
186
|
-
case "s3": return {
|
|
187
|
-
provider,
|
|
188
|
-
s3: readS3StorageConfig(env)
|
|
189
|
-
};
|
|
190
|
-
default: throw new Error("JUNIOR_ATTACHMENT_STORAGE_PROVIDER must be vercel-blob, s3, or memory");
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
// src/chat/queue/config.ts
|
|
194
|
-
/** Jobs that one BullMQ worker runs at the same time, for each queue topic. */
|
|
195
|
-
const DEFAULT_BULLMQ_WORKER_CONCURRENCY = 4;
|
|
196
|
-
function readWorkerConcurrency(value) {
|
|
197
|
-
const raw = toOptionalTrimmed(value);
|
|
198
|
-
if (raw === void 0) return DEFAULT_BULLMQ_WORKER_CONCURRENCY;
|
|
199
|
-
const concurrency = Number(raw);
|
|
200
|
-
if (!/^\d+$/.test(raw) || !Number.isSafeInteger(concurrency) || concurrency < 1) throw new Error("JUNIOR_QUEUE_WORKER_CONCURRENCY must be a positive integer");
|
|
201
|
-
return concurrency;
|
|
202
|
-
}
|
|
203
|
-
/** Read queue settings from environment variables. */
|
|
204
|
-
function readQueueConfig(env) {
|
|
205
|
-
const provider = toOptionalTrimmed(env.JUNIOR_QUEUE_PROVIDER) ?? "vercel";
|
|
206
|
-
switch (provider) {
|
|
207
|
-
case "vercel": return { provider };
|
|
208
|
-
case "bullmq": {
|
|
209
|
-
const redisUrl = toOptionalTrimmed(env.JUNIOR_QUEUE_REDIS_URL);
|
|
210
|
-
if (!redisUrl) throw new Error("JUNIOR_QUEUE_REDIS_URL is required when JUNIOR_QUEUE_PROVIDER is bullmq");
|
|
211
|
-
return {
|
|
212
|
-
provider,
|
|
213
|
-
redisUrl,
|
|
214
|
-
workerConcurrency: readWorkerConcurrency(env.JUNIOR_QUEUE_WORKER_CONCURRENCY)
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
default: throw new Error("JUNIOR_QUEUE_PROVIDER must be vercel or bullmq");
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
// src/chat/slack/emoji.ts
|
|
221
|
-
const SLACK_EMOJI_NAME_RE = /^(?:[a-z0-9_+-]+)(?:::(?:skin-tone-[2-6]))?$/;
|
|
222
|
-
function normalizeSlackEmojiName(value) {
|
|
223
|
-
const trimmed = value.trim().toLowerCase();
|
|
224
|
-
if (!trimmed) return null;
|
|
225
|
-
const normalized = trimmed.startsWith(":") && trimmed.endsWith(":") ? trimmed.slice(1, -1) : trimmed;
|
|
226
|
-
return SLACK_EMOJI_NAME_RE.test(normalized) ? normalized : null;
|
|
227
|
-
}
|
|
228
|
-
// src/chat/reasoning-level.ts
|
|
229
|
-
const TURN_REASONING_LEVELS = [
|
|
230
|
-
"none",
|
|
231
|
-
"low",
|
|
232
|
-
"medium",
|
|
233
|
-
"high",
|
|
234
|
-
"xhigh"
|
|
235
|
-
];
|
|
236
|
-
/** Validate a configured main-agent reasoning level. */
|
|
237
|
-
function parseTurnReasoningLevel(value) {
|
|
238
|
-
return z.enum(TURN_REASONING_LEVELS).parse(value);
|
|
239
|
-
}
|
|
240
|
-
/** Convert a reasoning level into the Pi Agent setting for a main Turn. */
|
|
241
|
-
function toPiReasoningLevel(level) {
|
|
242
|
-
return level === "none" ? "off" : level;
|
|
243
|
-
}
|
|
244
|
-
// src/chat/config.ts
|
|
245
|
-
var config_exports = /* @__PURE__ */ __exportAll({
|
|
246
|
-
CONVERSATION_WORK_SOFT_YIELD_BUFFER_SECONDS: () => 40,
|
|
247
|
-
DEFAULT_SQL_STATEMENT_TIMEOUT_MS: () => DEFAULT_SQL_STATEMENT_TIMEOUT_MS,
|
|
248
|
-
FUNCTION_TIMEOUT_BUFFER_SECONDS: () => 20,
|
|
249
|
-
botConfig: () => botConfig,
|
|
250
|
-
getChatConfig: () => getChatConfig,
|
|
251
|
-
getRuntimeMetadata: () => getRuntimeMetadata,
|
|
252
|
-
getSlackBotToken: () => getSlackBotToken,
|
|
253
|
-
getSlackClientId: () => getSlackClientId,
|
|
254
|
-
getSlackClientSecret: () => getSlackClientSecret,
|
|
255
|
-
getSlackSigningSecret: () => getSlackSigningSecret,
|
|
256
|
-
readChatConfig: () => readChatConfig,
|
|
257
|
-
resetRuntimeConfig: () => resetRuntimeConfig,
|
|
258
|
-
restoreRuntimeConfig: () => restoreRuntimeConfig,
|
|
259
|
-
setBotModelConfig: () => setBotModelConfig,
|
|
260
|
-
setRuntimeLimits: () => setRuntimeLimits,
|
|
261
|
-
setSlackReactionConfig: () => setSlackReactionConfig,
|
|
262
|
-
snapshotRuntimeConfig: () => snapshotRuntimeConfig
|
|
263
|
-
});
|
|
264
|
-
const MIN_AGENT_TURN_TIMEOUT_MS = 1e4;
|
|
265
|
-
const DEFAULT_AGENT_TURN_TIMEOUT_MS = 72e4;
|
|
266
|
-
const MAX_SLICES_PER_TURN = 100;
|
|
267
|
-
/**
|
|
268
|
-
* Max model spend in USD for one turn, including later execution slices of
|
|
269
|
-
* that turn. Sentry span estimates put a child agent that made 250 tool calls
|
|
270
|
-
* of real work at about $50.
|
|
271
|
-
*/
|
|
272
|
-
const MAX_TURN_COST_USD = 100;
|
|
273
|
-
/**
|
|
274
|
-
* Max tool calls for one turn, including later execution slices of that turn.
|
|
275
|
-
* A backstop for models without cost data. The spend limit should stop a turn
|
|
276
|
-
* first. 250 calls stopped child agents that were still doing real work.
|
|
277
|
-
*/
|
|
278
|
-
const MAX_TOOL_CALLS_PER_TURN = 1e3;
|
|
279
|
-
/**
|
|
280
|
-
* Max consecutive automated turns before event wakes stop until a user message.
|
|
281
|
-
* Resource-event CI watches and event-automation loops are the common runaway paths.
|
|
282
|
-
* Sentry telemetry has no direct instrumentation for how long real automated
|
|
283
|
-
* chains run (only failure paths on the notice are logged, and those show zero
|
|
284
|
-
* hits in the last 30d), so this is sized qualitatively: it stays well under
|
|
285
|
-
* the runaway CI-watch-loop range (hundreds of tool calls) while giving
|
|
286
|
-
* multi-phase event-automation/scheduled-automation work enough headroom to
|
|
287
|
-
* avoid pausing on legitimate longer-running automation.
|
|
288
|
-
*/
|
|
289
|
-
const MAX_CONSECUTIVE_AUTOMATED_TURNS = 25;
|
|
290
|
-
/**
|
|
291
|
-
* Max runs one Event automation can start in one rolling run window. Each run
|
|
292
|
-
* is a full agent turn, and Event automations skip the consecutive
|
|
293
|
-
* automated-turn limit. Kept low so a broad trigger, such as every message in
|
|
294
|
-
* a channel, blocks quickly instead of starting a turn for each Event.
|
|
295
|
-
*/
|
|
296
|
-
const MAX_EVENT_AUTOMATION_RUNS = 10;
|
|
297
|
-
/** Length of the rolling window for the Event automation run limit. */
|
|
298
|
-
const EVENT_AUTOMATION_RUN_WINDOW_MS = 6e4;
|
|
299
|
-
const DEFAULT_FUNCTION_MAX_DURATION_SECONDS = 300;
|
|
300
|
-
const DEFAULT_PROCESSING_REACTION_EMOJI = "eyes";
|
|
301
|
-
const DEFAULT_COMPLETED_REACTION_EMOJI = "white_check_mark";
|
|
302
|
-
const DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS = 4e5;
|
|
303
|
-
const DEFAULT_SQL_STATEMENT_TIMEOUT_MS = 3e4;
|
|
304
|
-
const DEFAULT_ASSISTANT_LOADING_MESSAGES = [
|
|
305
|
-
"Consulting the orb",
|
|
306
|
-
"Bribing the gremlins",
|
|
307
|
-
"Shuffling the papers dramatically",
|
|
308
|
-
"Summoning the right stack trace",
|
|
309
|
-
"Negotiating with the mutex",
|
|
310
|
-
"Poking the internet with a stick",
|
|
311
|
-
"Asking the docs nicely",
|
|
312
|
-
"Searching for the least cursed path",
|
|
313
|
-
"Pretending this was obvious",
|
|
314
|
-
"Waking up the test suite",
|
|
315
|
-
"Untangling the spaghetti carefully",
|
|
316
|
-
"Rattling the command line"
|
|
317
|
-
];
|
|
318
|
-
function parseAgentTurnTimeoutMs(rawValue, maxTimeoutMs) {
|
|
319
|
-
const value = Number.parseInt(rawValue ?? "", 10);
|
|
320
|
-
if (Number.isNaN(value)) return Math.max(MIN_AGENT_TURN_TIMEOUT_MS, Math.min(DEFAULT_AGENT_TURN_TIMEOUT_MS, maxTimeoutMs));
|
|
321
|
-
return Math.max(MIN_AGENT_TURN_TIMEOUT_MS, Math.min(value, maxTimeoutMs));
|
|
322
|
-
}
|
|
323
|
-
function resolveFunctionMaxDurationSeconds(functionMaxDurationSeconds) {
|
|
324
|
-
return functionMaxDurationSeconds ?? DEFAULT_FUNCTION_MAX_DURATION_SECONDS;
|
|
325
|
-
}
|
|
326
|
-
function resolveConversationWorkSoftYieldAfterMs(functionMaxDurationSeconds) {
|
|
327
|
-
return Math.max(MIN_AGENT_TURN_TIMEOUT_MS, (functionMaxDurationSeconds - 40) * 1e3);
|
|
328
|
-
}
|
|
329
|
-
function resolveMaxTurnTimeoutMs(functionMaxDurationSeconds) {
|
|
330
|
-
const budgetSeconds = functionMaxDurationSeconds - 20;
|
|
331
|
-
return Math.max(MIN_AGENT_TURN_TIMEOUT_MS, budgetSeconds * 1e3);
|
|
332
|
-
}
|
|
333
|
-
function parseLoadingMessages(rawValue) {
|
|
334
|
-
const trimmed = rawValue?.trim();
|
|
335
|
-
if (!trimmed) return [...DEFAULT_ASSISTANT_LOADING_MESSAGES];
|
|
336
|
-
let parsed;
|
|
337
|
-
try {
|
|
338
|
-
parsed = JSON.parse(trimmed);
|
|
339
|
-
} catch {
|
|
340
|
-
throw new Error("JUNIOR_LOADING_MESSAGES must be a JSON array of strings");
|
|
341
|
-
}
|
|
342
|
-
if (!Array.isArray(parsed)) throw new Error("JUNIOR_LOADING_MESSAGES must be a JSON array of strings");
|
|
343
|
-
return parsed.map((value, index) => {
|
|
344
|
-
if (typeof value !== "string") throw new Error(`JUNIOR_LOADING_MESSAGES[${index}] must be a string`);
|
|
345
|
-
return value.trim();
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
function parseOptionalPositiveInteger(envName, rawValue) {
|
|
349
|
-
const trimmed = toOptionalTrimmed(rawValue);
|
|
350
|
-
if (trimmed === void 0) return;
|
|
351
|
-
const value = Number.parseInt(trimmed, 10);
|
|
352
|
-
if (!Number.isSafeInteger(value) || value <= 0 || String(value) !== trimmed) throw new Error(`${envName} must be a positive integer`);
|
|
353
|
-
return value;
|
|
354
|
-
}
|
|
355
|
-
function parseConversationWorkEnabled(rawValue) {
|
|
356
|
-
const value = toOptionalTrimmed(rawValue)?.toLowerCase();
|
|
357
|
-
if (value === void 0 || value === "true") return true;
|
|
358
|
-
if (value === "false") return false;
|
|
359
|
-
throw new Error("JUNIOR_CONVERSATION_WORK_ENABLED must be true or false");
|
|
360
|
-
}
|
|
361
|
-
const DEFAULT_MODEL_ID = resolveGatewayModel("anthropic/claude-opus-5.5").id;
|
|
362
|
-
const DEFAULT_REASONING_LEVEL = "high";
|
|
363
|
-
const DEFAULT_FAST_MODEL_ID = resolveGatewayModel("openai/gpt-6-luna").id;
|
|
364
|
-
const DEFAULT_GUARDIAN_MODEL_ID = resolveGatewayModel("openai/gpt-6-luna").id;
|
|
365
|
-
const DEFAULT_WEB_SEARCH_MODEL_ID = resolveGatewayModel("openai/gpt-6-luna").id;
|
|
366
|
-
const DEFAULT_DECISION_MODEL_ID = "typesafe-ai/jev";
|
|
367
|
-
const DEFAULT_EMBEDDING_MODEL_ID = "openai/text-embedding-3-small";
|
|
368
|
-
const DEFAULT_RERANKING_MODEL_ID = "voyage/rerank-2.5-lite";
|
|
369
|
-
const DEFAULT_IMAGE_GENERATION_MODEL_ID = "openai/gpt-image-2";
|
|
370
|
-
const DEFAULT_VISION_MODEL_ID = resolveGatewayModel("openai/gpt-5.6-sol").id;
|
|
371
|
-
function validateGatewayModelId(raw) {
|
|
372
|
-
const trimmed = toOptionalTrimmed(raw);
|
|
373
|
-
if (trimmed === void 0) return void 0;
|
|
374
|
-
resolveGatewayModel(trimmed);
|
|
375
|
-
return trimmed;
|
|
376
|
-
}
|
|
377
|
-
function validateEmbeddingModelId(raw) {
|
|
378
|
-
return toOptionalTrimmed(raw);
|
|
379
|
-
}
|
|
380
|
-
function requireModelId(configName, raw, validate) {
|
|
381
|
-
const modelId = validate(raw);
|
|
382
|
-
if (!modelId) throw new Error(`${configName} must not be empty`);
|
|
383
|
-
return modelId;
|
|
384
|
-
}
|
|
385
|
-
function parseReactionEmoji(envName, rawValue, defaultEmoji) {
|
|
386
|
-
const trimmed = toOptionalTrimmed(rawValue);
|
|
387
|
-
if (trimmed === void 0) return defaultEmoji;
|
|
388
|
-
const normalized = normalizeSlackEmojiName(trimmed);
|
|
389
|
-
if (!normalized) throw new Error(`${envName} must be a valid Slack emoji name (for example "eyes" or ":white_check_mark:")`);
|
|
390
|
-
return normalized;
|
|
391
|
-
}
|
|
392
|
-
function readBotConfig(env, functionMaxDurationSeconds) {
|
|
393
|
-
const maxTurnTimeoutMs = resolveMaxTurnTimeoutMs(functionMaxDurationSeconds);
|
|
394
|
-
const modelId = validateGatewayModelId(env.AI_MODEL) ?? DEFAULT_MODEL_ID;
|
|
395
|
-
const reasoningLevel = toOptionalTrimmed(env.AI_REASONING_LEVEL);
|
|
396
|
-
const fastModelId = validateGatewayModelId(env.AI_FAST_MODEL ?? env.AI_MODEL) ?? DEFAULT_FAST_MODEL_ID;
|
|
397
|
-
const guardianModelId = validateGatewayModelId(env.AI_GUARDIAN_MODEL) ?? DEFAULT_GUARDIAN_MODEL_ID;
|
|
398
|
-
return {
|
|
399
|
-
userName: toOptionalTrimmed(env.JUNIOR_BOT_NAME) ?? "junior",
|
|
400
|
-
modelId,
|
|
401
|
-
contextWindowTokens: parseOptionalPositiveInteger("AI_MODEL_CONTEXT_WINDOW_TOKENS", env.AI_MODEL_CONTEXT_WINDOW_TOKENS) ?? DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS,
|
|
402
|
-
reasoningLevel: reasoningLevel === void 0 ? DEFAULT_REASONING_LEVEL : parseTurnReasoningLevel(reasoningLevel),
|
|
403
|
-
decisionModelId: toOptionalTrimmed(env.AI_DECISION_MODEL) ?? DEFAULT_DECISION_MODEL_ID,
|
|
404
|
-
fastModelId,
|
|
405
|
-
guardianModelId,
|
|
406
|
-
imageGenerationModelId: toOptionalTrimmed(env.AI_IMAGE_MODEL) ?? DEFAULT_IMAGE_GENERATION_MODEL_ID,
|
|
407
|
-
embeddingModelId: validateEmbeddingModelId(env.AI_EMBEDDING_MODEL) ?? DEFAULT_EMBEDDING_MODEL_ID,
|
|
408
|
-
rerankingModelId: toOptionalTrimmed(env.AI_RERANKING_MODEL) ?? DEFAULT_RERANKING_MODEL_ID,
|
|
409
|
-
loadingMessages: parseLoadingMessages(env.JUNIOR_LOADING_MESSAGES),
|
|
410
|
-
visionModelId: env.AI_VISION_MODEL === void 0 ? DEFAULT_VISION_MODEL_ID : validateGatewayModelId(env.AI_VISION_MODEL),
|
|
411
|
-
maxAgentDepth: 0,
|
|
412
|
-
maxSlicesPerTurn: MAX_SLICES_PER_TURN,
|
|
413
|
-
maxToolCallsPerTurn: MAX_TOOL_CALLS_PER_TURN,
|
|
414
|
-
maxTurnCostUsd: MAX_TURN_COST_USD,
|
|
415
|
-
maxConsecutiveAutomatedTurns: MAX_CONSECUTIVE_AUTOMATED_TURNS,
|
|
416
|
-
maxEventAutomationRuns: MAX_EVENT_AUTOMATION_RUNS,
|
|
417
|
-
eventAutomationRunWindowMs: EVENT_AUTOMATION_RUN_WINDOW_MS,
|
|
418
|
-
turnTimeoutMs: parseAgentTurnTimeoutMs(env.AGENT_TURN_TIMEOUT_MS, maxTurnTimeoutMs),
|
|
419
|
-
webSearchModelId: validateGatewayModelId(env.AI_WEB_SEARCH_MODEL) ?? DEFAULT_WEB_SEARCH_MODEL_ID
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
function readDatabaseUrl(env) {
|
|
423
|
-
const databaseUrl = toOptionalTrimmed(env.DATABASE_URL);
|
|
424
|
-
if (!databaseUrl) throw new Error("DATABASE_URL is required");
|
|
425
|
-
return databaseUrl;
|
|
426
|
-
}
|
|
427
|
-
function isLocalDatabaseUrl(databaseUrl) {
|
|
428
|
-
try {
|
|
429
|
-
const { hostname } = new URL(databaseUrl);
|
|
430
|
-
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
|
|
431
|
-
} catch {
|
|
432
|
-
return false;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
function readSqlDriver(env, databaseUrl) {
|
|
436
|
-
const value = toOptionalTrimmed(env.JUNIOR_DATABASE_DRIVER);
|
|
437
|
-
if (value === void 0) {
|
|
438
|
-
if (isLocalDatabaseUrl(databaseUrl)) return "postgres";
|
|
439
|
-
return "neon";
|
|
440
|
-
}
|
|
441
|
-
if (value === "neon" || value === "postgres") return value;
|
|
442
|
-
throw new Error("JUNIOR_DATABASE_DRIVER must be postgres or neon");
|
|
443
|
-
}
|
|
444
|
-
function readSqlStatementTimeoutMs(env) {
|
|
445
|
-
const rawValue = toOptionalTrimmed(env.JUNIOR_SQL_STATEMENT_TIMEOUT_MS);
|
|
446
|
-
if (rawValue === void 0) return DEFAULT_SQL_STATEMENT_TIMEOUT_MS;
|
|
447
|
-
const value = Number.parseInt(rawValue, 10);
|
|
448
|
-
if (!Number.isSafeInteger(value) || value < 0 || String(value) !== rawValue) throw new Error("JUNIOR_SQL_STATEMENT_TIMEOUT_MS must be a non-negative integer");
|
|
449
|
-
return value === 0 ? false : value;
|
|
450
|
-
}
|
|
451
|
-
/** Parse all chat configuration from environment variables. */
|
|
452
|
-
function readChatConfig(env = process.env, functionMaxDurationSeconds = DEFAULT_FUNCTION_MAX_DURATION_SECONDS) {
|
|
453
|
-
const databaseUrl = readDatabaseUrl(env);
|
|
454
|
-
const resolvedFunctionMaxDurationSeconds = resolveFunctionMaxDurationSeconds(functionMaxDurationSeconds);
|
|
455
|
-
return {
|
|
456
|
-
attachmentStorage: readAttachmentStorageConfig(env),
|
|
457
|
-
bot: readBotConfig(env, resolvedFunctionMaxDurationSeconds),
|
|
458
|
-
queue: readQueueConfig(env),
|
|
459
|
-
functionMaxDurationSeconds: resolvedFunctionMaxDurationSeconds,
|
|
460
|
-
conversationWorkEnabled: parseConversationWorkEnabled(env.JUNIOR_CONVERSATION_WORK_ENABLED),
|
|
461
|
-
conversationWorkSoftYieldAfterMs: resolveConversationWorkSoftYieldAfterMs(resolvedFunctionMaxDurationSeconds),
|
|
462
|
-
sql: {
|
|
463
|
-
databaseUrl,
|
|
464
|
-
driver: readSqlDriver(env, databaseUrl),
|
|
465
|
-
statementTimeoutMs: readSqlStatementTimeoutMs(env)
|
|
466
|
-
},
|
|
467
|
-
slack: {
|
|
468
|
-
botToken: toOptionalTrimmed(env.SLACK_BOT_TOKEN) ?? toOptionalTrimmed(env.SLACK_BOT_USER_TOKEN),
|
|
469
|
-
clientId: toOptionalTrimmed(env.SLACK_CLIENT_ID),
|
|
470
|
-
clientSecret: toOptionalTrimmed(env.SLACK_CLIENT_SECRET),
|
|
471
|
-
completedReactionEmoji: DEFAULT_COMPLETED_REACTION_EMOJI,
|
|
472
|
-
processingReactionEmoji: DEFAULT_PROCESSING_REACTION_EMOJI,
|
|
473
|
-
signingSecret: toOptionalTrimmed(env.SLACK_SIGNING_SECRET)
|
|
474
|
-
},
|
|
475
|
-
sandbox: { provider: env.JUNIOR_SANDBOX_PROVIDER?.trim().toLowerCase() === "docker" ? "docker" : "vercel" },
|
|
476
|
-
state: {
|
|
477
|
-
adapter: env.JUNIOR_STATE_ADAPTER?.trim().toLowerCase() === "memory" ? "memory" : "redis",
|
|
478
|
-
keyPrefix: toOptionalTrimmed(env.JUNIOR_STATE_KEY_PREFIX),
|
|
479
|
-
redisUrl: toOptionalTrimmed(env.REDIS_URL)
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
/** Chat configuration parsed once at module load from the process environment. */
|
|
484
|
-
const chatConfig = readChatConfig(process.env);
|
|
485
|
-
/** Copy the runtime config so a failed app setup can restore it. */
|
|
486
|
-
function snapshotRuntimeConfig() {
|
|
487
|
-
return {
|
|
488
|
-
bot: { ...chatConfig.bot },
|
|
489
|
-
completedReactionEmoji: chatConfig.slack.completedReactionEmoji,
|
|
490
|
-
conversationWorkSoftYieldAfterMs: chatConfig.conversationWorkSoftYieldAfterMs,
|
|
491
|
-
functionMaxDurationSeconds: chatConfig.functionMaxDurationSeconds,
|
|
492
|
-
processingReactionEmoji: chatConfig.slack.processingReactionEmoji
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
/** Replace the runtime config with a snapshot. */
|
|
496
|
-
function restoreRuntimeConfig(snapshot) {
|
|
497
|
-
replaceBotConfig(snapshot.bot);
|
|
498
|
-
chatConfig.functionMaxDurationSeconds = snapshot.functionMaxDurationSeconds;
|
|
499
|
-
chatConfig.conversationWorkSoftYieldAfterMs = snapshot.conversationWorkSoftYieldAfterMs;
|
|
500
|
-
chatConfig.slack.completedReactionEmoji = snapshot.completedReactionEmoji;
|
|
501
|
-
chatConfig.slack.processingReactionEmoji = snapshot.processingReactionEmoji;
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Reset bot, limit, and Slack settings to the environment defaults and apply
|
|
505
|
-
* the host execution budget. Each app calls this before it applies options.
|
|
506
|
-
*/
|
|
507
|
-
function resetRuntimeConfig(functionMaxDurationSeconds) {
|
|
508
|
-
const resolved = resolveFunctionMaxDurationSeconds(functionMaxDurationSeconds);
|
|
509
|
-
chatConfig.functionMaxDurationSeconds = resolved;
|
|
510
|
-
chatConfig.conversationWorkSoftYieldAfterMs = resolveConversationWorkSoftYieldAfterMs(resolved);
|
|
511
|
-
replaceBotConfig(readBotConfig(process.env, resolved));
|
|
512
|
-
chatConfig.slack.completedReactionEmoji = DEFAULT_COMPLETED_REACTION_EMOJI;
|
|
513
|
-
chatConfig.slack.processingReactionEmoji = DEFAULT_PROCESSING_REACTION_EMOJI;
|
|
514
|
-
}
|
|
515
|
-
function replaceBotConfig(next) {
|
|
516
|
-
for (const key of Object.keys(chatConfig.bot)) delete chatConfig.bot[key];
|
|
517
|
-
Object.assign(chatConfig.bot, next);
|
|
518
|
-
}
|
|
519
|
-
function requirePositiveLimit(name, value) {
|
|
520
|
-
if (!Number.isSafeInteger(value) || value <= 0) throw new Error(`limits.${name} must be a positive integer`);
|
|
521
|
-
return value;
|
|
522
|
-
}
|
|
523
|
-
/** Apply limits from createApp(). Unset limits keep their defaults. */
|
|
524
|
-
function setRuntimeLimits(limits) {
|
|
525
|
-
const bot = chatConfig.bot;
|
|
526
|
-
if (limits?.contextWindowTokens !== void 0) bot.contextWindowTokens = requirePositiveLimit("contextWindowTokens", limits.contextWindowTokens);
|
|
527
|
-
if (limits?.maxAgentDepth !== void 0) {
|
|
528
|
-
if (!Number.isSafeInteger(limits.maxAgentDepth) || limits.maxAgentDepth < 0) throw new Error("limits.maxAgentDepth must be a non-negative integer");
|
|
529
|
-
bot.maxAgentDepth = limits.maxAgentDepth;
|
|
530
|
-
}
|
|
531
|
-
if (limits?.maxConsecutiveAutomatedTurns !== void 0) bot.maxConsecutiveAutomatedTurns = requirePositiveLimit("maxConsecutiveAutomatedTurns", limits.maxConsecutiveAutomatedTurns);
|
|
532
|
-
const runLimit = limits?.eventAutomationRunLimit;
|
|
533
|
-
if (runLimit?.maxRuns !== void 0) bot.maxEventAutomationRuns = requirePositiveLimit("eventAutomationRunLimit.maxRuns", runLimit.maxRuns);
|
|
534
|
-
if (runLimit?.windowMs !== void 0) bot.eventAutomationRunWindowMs = requirePositiveLimit("eventAutomationRunLimit.windowMs", runLimit.windowMs);
|
|
535
|
-
if (limits?.maxSlicesPerTurn !== void 0) bot.maxSlicesPerTurn = requirePositiveLimit("maxSlicesPerTurn", limits.maxSlicesPerTurn);
|
|
536
|
-
if (limits?.maxToolCallsPerTurn !== void 0) bot.maxToolCallsPerTurn = requirePositiveLimit("maxToolCallsPerTurn", limits.maxToolCallsPerTurn);
|
|
537
|
-
if (limits?.maxTurnCostUsd !== void 0) bot.maxTurnCostUsd = requirePositiveLimit("maxTurnCostUsd", limits.maxTurnCostUsd);
|
|
538
|
-
if (limits?.turnTimeoutMs !== void 0) bot.turnTimeoutMs = Math.min(requirePositiveLimit("turnTimeoutMs", limits.turnTimeoutMs), resolveMaxTurnTimeoutMs(chatConfig.functionMaxDurationSeconds));
|
|
539
|
-
}
|
|
540
|
-
/** Return the chat configuration (parsed once at startup). */
|
|
541
|
-
function getChatConfig() {
|
|
542
|
-
return chatConfig;
|
|
543
|
-
}
|
|
544
|
-
/** Bot configuration derived from environment at module load. */
|
|
545
|
-
const botConfig = chatConfig.bot;
|
|
546
|
-
function getSlackBotToken() {
|
|
547
|
-
return chatConfig.slack.botToken;
|
|
548
|
-
}
|
|
549
|
-
function getSlackSigningSecret() {
|
|
550
|
-
return chatConfig.slack.signingSecret;
|
|
551
|
-
}
|
|
552
|
-
function getSlackClientId() {
|
|
553
|
-
return chatConfig.slack.clientId;
|
|
554
|
-
}
|
|
555
|
-
function getSlackClientSecret() {
|
|
556
|
-
return chatConfig.slack.clientSecret;
|
|
557
|
-
}
|
|
558
|
-
/** Return runtime metadata (version from deploy environment). */
|
|
559
|
-
function getRuntimeMetadata() {
|
|
560
|
-
return { version: toOptionalTrimmed(process.env.VERCEL_GIT_COMMIT_SHA) };
|
|
561
|
-
}
|
|
562
|
-
/** Apply model overrides from createApp(). */
|
|
563
|
-
function setBotModelConfig(config) {
|
|
564
|
-
if (config.modelId !== void 0) botConfig.modelId = requireModelId("modelId", config.modelId, validateGatewayModelId);
|
|
565
|
-
if (config.decisionModelId !== void 0) botConfig.decisionModelId = requireModelId("decisionModelId", config.decisionModelId, toOptionalTrimmed);
|
|
566
|
-
if (config.embeddingModelId !== void 0) botConfig.embeddingModelId = requireModelId("embeddingModelId", config.embeddingModelId, validateEmbeddingModelId);
|
|
567
|
-
if (config.fastModelId !== void 0) botConfig.fastModelId = requireModelId("fastModelId", config.fastModelId, validateGatewayModelId);
|
|
568
|
-
if (config.guardianModelId !== void 0) botConfig.guardianModelId = requireModelId("guardianModelId", config.guardianModelId, validateGatewayModelId);
|
|
569
|
-
if (config.rerankingModelId !== void 0) botConfig.rerankingModelId = requireModelId("rerankingModelId", config.rerankingModelId, toOptionalTrimmed);
|
|
570
|
-
if (config.imageGenerationModelId !== void 0) botConfig.imageGenerationModelId = requireModelId("imageGenerationModelId", config.imageGenerationModelId, validateEmbeddingModelId);
|
|
571
|
-
if (config.visionModelId !== void 0) botConfig.visionModelId = requireModelId("visionModelId", config.visionModelId, validateGatewayModelId);
|
|
572
|
-
if (config.webSearchModelId !== void 0) botConfig.webSearchModelId = requireModelId("webSearchModelId", config.webSearchModelId, validateGatewayModelId);
|
|
573
|
-
}
|
|
574
|
-
/** Apply Slack reaction emoji overrides from createApp() options, validating names. */
|
|
575
|
-
function setSlackReactionConfig(overrides) {
|
|
576
|
-
if (overrides.processingReactionEmoji !== void 0) chatConfig.slack.processingReactionEmoji = parseReactionEmoji("processingReactionEmoji", overrides.processingReactionEmoji, chatConfig.slack.processingReactionEmoji);
|
|
577
|
-
if (overrides.completedReactionEmoji !== void 0) chatConfig.slack.completedReactionEmoji = parseReactionEmoji("completedReactionEmoji", overrides.completedReactionEmoji, chatConfig.slack.completedReactionEmoji);
|
|
578
|
-
}
|
|
579
|
-
export { toPiReasoningLevel as _, getRuntimeMetadata as a, getSlackClientSecret as c, restoreRuntimeConfig as d, setBotModelConfig as f, TURN_REASONING_LEVELS as g, snapshotRuntimeConfig as h, getChatConfig as i, getSlackSigningSecret as l, setSlackReactionConfig as m, botConfig as n, getSlackBotToken as o, setRuntimeLimits as p, config_exports as r, getSlackClientId as s, DEFAULT_SQL_STATEMENT_TIMEOUT_MS as t, resetRuntimeConfig as u, normalizeSlackEmojiName as v, getAttachmentStorage as y };
|
package/dist/spawn-C8F_iXWO.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { n as botConfig } from "./config-B9f9Lqo5.js";
|
|
3
|
-
import { Gt as actorFromRun, Kt as toolInvocationDestination, Pt as AgentDepthLimitError, i as readConversationLineage } from "./agent-runner-DGCwOEyL.js";
|
|
4
|
-
import { n as createAndEnqueueAgentInvocation } from "./work-C75_IM5e.js";
|
|
5
|
-
// src/chat/agent-invocations/spawn.ts
|
|
6
|
-
var spawn_exports = /* @__PURE__ */ __exportAll({ bindSpawnAgent: () => bindSpawnAgent });
|
|
7
|
-
/**
|
|
8
|
-
* Count the parents of the Conversation that starts a child agent. A chain
|
|
9
|
-
* that does not end at a root, such as a cycle, cannot start one.
|
|
10
|
-
*/
|
|
11
|
-
async function assertCanStartChildAgent(conversationId, maxAgentDepth) {
|
|
12
|
-
const lineage = await readConversationLineage(conversationId);
|
|
13
|
-
const root = lineage[0];
|
|
14
|
-
if (!root || root.parentConversationId || lineage.length - 1 > maxAgentDepth) throw new AgentDepthLimitError(maxAgentDepth);
|
|
15
|
-
}
|
|
16
|
-
/** Bind a Run's Actor and credentials to new Agent invocations. */
|
|
17
|
-
function bindSpawnAgent(run, options) {
|
|
18
|
-
const actor = actorFromRun(run);
|
|
19
|
-
if (!actor) return;
|
|
20
|
-
return async (input, call) => {
|
|
21
|
-
call.signal?.throwIfAborted();
|
|
22
|
-
await assertCanStartChildAgent(run.conversationId, options.maxAgentDepth ?? botConfig.maxAgentDepth);
|
|
23
|
-
const queue = typeof options.queue === "function" ? options.queue() : options.queue;
|
|
24
|
-
return { childConversationId: (await createAndEnqueueAgentInvocation({
|
|
25
|
-
actor,
|
|
26
|
-
...input.name ? { agentName: input.name } : void 0,
|
|
27
|
-
...input.agentType ? { agentType: input.agentType } : void 0,
|
|
28
|
-
...run.credentialContext ? { credentialContext: run.credentialContext } : void 0,
|
|
29
|
-
destination: toolInvocationDestination(run),
|
|
30
|
-
idempotencyKey: `${run.turnId}:${call.toolCallId}`,
|
|
31
|
-
input: input.task,
|
|
32
|
-
parentConversationId: run.conversationId,
|
|
33
|
-
parentToolCallId: call.toolCallId,
|
|
34
|
-
...input.reasoningLevel ? { reasoningLevel: input.reasoningLevel } : void 0,
|
|
35
|
-
...input.title ? { title: input.title } : void 0
|
|
36
|
-
}, {
|
|
37
|
-
...options,
|
|
38
|
-
queue
|
|
39
|
-
})).childConversationId };
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export { spawn_exports as n, bindSpawnAgent as t };
|