@sentry/junior 0.317.0 → 0.319.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-8_S6Birm.js +1833 -0
- package/dist/{admin-CAugg87B.js → admin-EsbUON1j.js} +1 -1
- package/dist/{agent-runner-AjrEV6Qe.js → agent-CtzMl32d.js} +19953 -6727
- package/dist/{agent-status-BA5x3Xtp.js → agent-status-Bq_AIpyp.js} +105 -1
- package/dist/{agent-update-delivery-B_YIZcgf.js → agent-update-delivery-pAvsbuGL.js} +4 -5
- package/dist/api/schema.d.ts +85 -51
- package/dist/api/schema.js +4 -4
- package/dist/api.js +81 -94
- package/dist/{app-MoNAsVV5.d.ts → app-tACXxJPI.d.ts} +8 -13
- package/dist/app.d.ts +2 -2
- package/dist/app.js +246 -153
- package/dist/{change-record-BzJgLsv7.d.ts → change-record-K-KsqNhT.d.ts} +9 -5
- package/dist/{channel-access-j-YAVYK4.js → channel-access-DET5hzZM.js} +1 -1
- package/dist/{chat-core-engine-aH85nEHv.js → chat-core-engine-DpM3tMVi.js} +7 -7
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +38 -30
- package/dist/cli/check.js +5 -5
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.d.ts +1 -1
- package/dist/cli/plugins.js +8 -8
- package/dist/cli/snapshot-create.js +5 -6
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -4
- package/dist/{continue-in-slack-D-FZ8Fin.js → continue-in-slack-CFzDyxkH.js} +3 -2
- package/dist/{conversation-feed--9S0_PXL.js → conversation-feed-DEUdD7mb.js} +2 -106
- package/dist/{conversation-privacy-B1uXn5sf.js → conversation-privacy-C2vYK55O.js} +1 -1
- package/dist/{create-DoDIYgtZ.js → create-Ta3SEIB5.js} +124 -16
- package/dist/{credential-sync-BJOqGnjV.js → credential-sync-DyRqDmY4.js} +17 -20
- package/dist/{db-BFmyYZtJ.js → db-BCaNWl9p.js} +6536 -1920
- package/dist/{deployment-DXq9ZLU4.js → deployment-CfOew1Tm.js} +3 -3
- package/dist/{engine-context-CgQ7mlHt.js → engine-context-CiExoy1B.js} +181 -155
- package/dist/{html-B3VKTGbJ.js → html-Bb2Si1bR.js} +6 -8
- package/dist/instrumentation.js +7 -23
- package/dist/list-wwDcROh9.js +5007 -0
- package/dist/{logging--smS7XRK.js → logging-BRPTXAdf.js} +10 -81
- package/dist/{mailbox-turn-uSXhUFc9.js → markers-9QoqW5ov.js} +1875 -1458
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +7 -8
- package/dist/{oauth-callback-server-CE4soEIY.js → oauth-callback-server-vhL9b-PZ.js} +2 -2
- package/dist/{oauth-relay-C36gX1gH.js → oauth-relay-CH2v7WiB.js} +1 -1
- package/dist/{plugins-fBrz8PCV.d.ts → plugins-DhGXZjlu.d.ts} +1 -0
- package/dist/{profile-BQ-iBDsZ.js → profile-D9LdwmZi.js} +17 -19
- package/dist/{prompt-Dv7gkpD6.js → prompt-3TqxEOtc.js} +10 -10
- package/dist/{reports-WKHfGTsU.js → reports-K-tbtEyx.js} +2 -2
- package/dist/{resolve-tony4ibz.js → resolve-BBV2qf8A.js} +5 -5
- package/dist/{result-Bta_dlWa.js → result-5IdGJP4M.js} +24 -13
- package/dist/{runner-BstDRbD9.js → runner-BK_joPlM.js} +9 -18
- package/dist/{sandbox-egress-signals-oSJMJOnn.js → sandbox-egress-signals-DXgWXXmm.js} +1 -1
- package/dist/{schema-DfqrHACA.js → schema-zWGG6VC1.js} +13 -7
- package/dist/{service-account-CTV_jaNu.js → service-account-CateFyhw.js} +4 -5
- package/dist/{skills-BCEU41zM.js → skills-Ccjw8h2P.js} +10 -9
- package/dist/{slack-conversation-unfurl-DxVmhbGP.js → slack-conversation-unfurl-ZC_TSpc4.js} +7 -7
- package/dist/storage-C9U7R5rM.js +273 -0
- package/dist/{system-prompt-table-CiXy0eNR.js → system-prompt-table-YBTHIFlP.js} +26 -84
- package/dist/topic-B2EWKKBT.js +6 -0
- package/dist/{package-discovery-DD9vencX.js → topics-DxuKurCX.js} +21 -1
- package/dist/{types-C4iC-IMC.js → types-BNHkJrOP.js} +79 -59
- package/dist/{users-ByG5RCEJ.js → users-CCRAqYb_.js} +1 -1
- package/dist/{validation-8gjfR91V.js → validation-BCUpJa8K.js} +4 -4
- package/dist/{version-BeZhWWBE.js → version-BNm0JYj3.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{worker-BqMQQNRk.js → worker-BhgpZ7_b.js} +5 -5
- package/migrations/20261127002500_turn_discarded_usage/migration.sql +2 -0
- package/migrations/20261127002500_turn_discarded_usage/snapshot.json +73 -0
- package/migrations/20261127052408_space_name_nullable/migration.sql +5 -0
- package/migrations/20261127052408_space_name_nullable/snapshot.json +29 -0
- package/migrations/20261127060000_annotation_object_id_index/migration.sql +1 -0
- package/migrations/20261127060000_annotation_object_id_index/snapshot.json +69 -0
- package/migrations/20261127060001_annotation_subjects/migration.sql +78 -0
- package/migrations/20261127060001_annotation_subjects/snapshot.json +104 -0
- package/migrations/20261127060002_annotation_subject_index/migration.sql +1 -0
- package/migrations/20261127060002_annotation_subject_index/snapshot.json +70 -0
- package/migrations/20261127060003_annotation_title_url/migration.sql +84 -0
- package/migrations/20261127060003_annotation_title_url/snapshot.json +73 -0
- package/package.json +9 -7
- package/dist/catalog-runtime-DfSpJZdY.js +0 -6
- package/dist/child-message-DHjQLEd1.js +0 -19
- package/dist/config-CHQ8X251.js +0 -2422
- package/dist/conversation-turn-BUE_7xaN.js +0 -1157
- package/dist/job-runner-A1lCkybD.js +0 -1506
- package/dist/lineage-Bktb0UcV.js +0 -36
- package/dist/list-Bxvg5wXf.js +0 -12623
- package/dist/message-BNenhsmB.js +0 -154
- package/dist/model-input-BReSnwHp.js +0 -82
- package/dist/parent-result-Ck1rFYRQ.js +0 -310
- package/dist/registry-iXMT5Jmh.js +0 -3279
- package/dist/run-conversation-DL6ru7iW.js +0 -336
- package/dist/sender-actors-CPglLd5R.js +0 -83
- package/dist/spawn-frczVPIr.js +0 -48
- package/dist/task-runner-C9Yc2_ae.js +0 -1526
- package/dist/thread-context-CqZDKErp.js +0 -166
- package/dist/topic-CRYYBYp-.js +0 -7
- package/dist/topics-SRN7IVX-.js +0 -24
- package/dist/turn-membership-CENFf3kI.js +0 -856
- package/dist/turn-wake-BhloiI2h.js +0 -151
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { R as getChatConfig } from "./adapter-8_S6Birm.js";
|
|
2
|
+
import { G as mapBounded } from "./prompt-3TqxEOtc.js";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
import { AwsClient } from "aws4fetch";
|
|
5
|
+
import { del, get, issueSignedToken, presignUrl, put } from "@vercel/blob";
|
|
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(await new Response(input.body).arrayBuffer()));
|
|
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/s3.ts
|
|
36
|
+
const S3_DELETE_CONCURRENCY = 8;
|
|
37
|
+
/**
|
|
38
|
+
* Path-style object URL. Local S3 servers and AWS S3 both accept it.
|
|
39
|
+
*
|
|
40
|
+
* URL parsing removes `.` and `..` segments, also in `%2e` form. A key with
|
|
41
|
+
* such a segment would address a different object, so reject it.
|
|
42
|
+
*/
|
|
43
|
+
function objectUrl(config, key) {
|
|
44
|
+
const endpoint = config.endpoint.replace(/\/+$/, "");
|
|
45
|
+
const segments = key.split("/");
|
|
46
|
+
if (segments.some((segment) => segment === "." || segment === "..")) throw new Error("S3 object keys cannot contain . or .. path segments");
|
|
47
|
+
const path = segments.map(encodeURIComponent).join("/");
|
|
48
|
+
return `${endpoint}/${encodeURIComponent(config.bucket)}/${path}`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Read a small S3 response body to the end so the connection is released.
|
|
52
|
+
*
|
|
53
|
+
* Error and empty bodies are small. `body.cancel()` can hang under the test
|
|
54
|
+
* HTTP interceptor, so read the body instead.
|
|
55
|
+
*/
|
|
56
|
+
async function drain(response) {
|
|
57
|
+
await response.arrayBuffer();
|
|
58
|
+
}
|
|
59
|
+
/** Throw on a failed S3 response, and release the response body. */
|
|
60
|
+
async function expectOk(response, operation) {
|
|
61
|
+
await drain(response);
|
|
62
|
+
if (!response.ok) throw new Error(`S3 ${operation} failed with status ${response.status}`);
|
|
63
|
+
}
|
|
64
|
+
/** Presigned URL lifetime in whole seconds, at least one. */
|
|
65
|
+
function expiresInSeconds(expiresAtMs) {
|
|
66
|
+
return String(Math.max(1, Math.ceil((expiresAtMs - Date.now()) / 1e3)));
|
|
67
|
+
}
|
|
68
|
+
/** Store private conversation attachments in an S3-compatible bucket. */
|
|
69
|
+
function createS3AttachmentStorage(config) {
|
|
70
|
+
const client = new AwsClient({
|
|
71
|
+
accessKeyId: config.accessKeyId,
|
|
72
|
+
region: config.region,
|
|
73
|
+
secretAccessKey: config.secretAccessKey,
|
|
74
|
+
service: "s3"
|
|
75
|
+
});
|
|
76
|
+
const writeClient = new AwsClient({
|
|
77
|
+
accessKeyId: config.accessKeyId,
|
|
78
|
+
region: config.region,
|
|
79
|
+
retries: 0,
|
|
80
|
+
secretAccessKey: config.secretAccessKey,
|
|
81
|
+
service: "s3"
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
provider: "s3",
|
|
85
|
+
async put(input) {
|
|
86
|
+
await expectOk(await writeClient.fetch(objectUrl(config, input.key), {
|
|
87
|
+
body: input.body,
|
|
88
|
+
headers: {
|
|
89
|
+
"content-length": String(input.bytes),
|
|
90
|
+
"content-type": input.contentType,
|
|
91
|
+
"x-amz-content-sha256": "UNSIGNED-PAYLOAD"
|
|
92
|
+
},
|
|
93
|
+
method: "PUT"
|
|
94
|
+
}), "put");
|
|
95
|
+
},
|
|
96
|
+
async createUploadTarget(input) {
|
|
97
|
+
const url = new URL(objectUrl(config, input.key));
|
|
98
|
+
url.searchParams.set("X-Amz-Expires", expiresInSeconds(input.expiresAtMs));
|
|
99
|
+
const browserHeaders = {
|
|
100
|
+
"content-type": input.contentType,
|
|
101
|
+
"if-none-match": "*"
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
headers: browserHeaders,
|
|
105
|
+
method: "PUT",
|
|
106
|
+
url: (await client.sign(url.toString(), {
|
|
107
|
+
aws: {
|
|
108
|
+
allHeaders: true,
|
|
109
|
+
signQuery: true
|
|
110
|
+
},
|
|
111
|
+
headers: {
|
|
112
|
+
...browserHeaders,
|
|
113
|
+
"content-length": String(input.bytes)
|
|
114
|
+
},
|
|
115
|
+
method: "PUT"
|
|
116
|
+
})).url
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
async createDownloadUrl(input) {
|
|
120
|
+
const url = new URL(objectUrl(config, input.key));
|
|
121
|
+
url.searchParams.set("X-Amz-Expires", expiresInSeconds(input.expiresAtMs));
|
|
122
|
+
return (await client.sign(url.toString(), {
|
|
123
|
+
aws: { signQuery: true },
|
|
124
|
+
method: "GET"
|
|
125
|
+
})).url;
|
|
126
|
+
},
|
|
127
|
+
async get(key, range) {
|
|
128
|
+
const response = await client.fetch(objectUrl(config, key), range ? { headers: { range: rangeHeader(range) } } : void 0);
|
|
129
|
+
if (response.status === 404) {
|
|
130
|
+
await drain(response);
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
if (!response.ok) await expectOk(response, "get");
|
|
134
|
+
if (range && response.status !== 206) {
|
|
135
|
+
await drain(response);
|
|
136
|
+
throw new Error(`S3 get ignored the byte range with status ${response.status}`);
|
|
137
|
+
}
|
|
138
|
+
return response.body;
|
|
139
|
+
},
|
|
140
|
+
async delete(keys) {
|
|
141
|
+
await mapBounded(keys, async (key) => {
|
|
142
|
+
const response = await client.fetch(objectUrl(config, key), { method: "DELETE" });
|
|
143
|
+
if (response.status === 404) {
|
|
144
|
+
await drain(response);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
await expectOk(response, "delete");
|
|
148
|
+
}, S3_DELETE_CONCURRENCY);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
// src/chat/attachments/vercel.ts
|
|
153
|
+
const BLOB_API_VERSION = "12";
|
|
154
|
+
const delegationPayloadSchema = z.object({ storeId: z.string().min(1) });
|
|
155
|
+
/**
|
|
156
|
+
* Read the store id from a delegation token, as the SDK does for its own
|
|
157
|
+
* presigned requests. The token payload is base64url JSON before the dot.
|
|
158
|
+
*/
|
|
159
|
+
function delegationStoreId(delegationToken) {
|
|
160
|
+
const { storeId } = delegationPayloadSchema.parse(JSON.parse(Buffer.from(delegationToken.split(".")[0] ?? "", "base64url").toString()));
|
|
161
|
+
return storeId.replace(/^store_/, "");
|
|
162
|
+
}
|
|
163
|
+
/** Store private conversation attachments in Vercel Blob. */
|
|
164
|
+
function createVercelAttachmentStorage() {
|
|
165
|
+
return {
|
|
166
|
+
provider: "vercel-blob",
|
|
167
|
+
async put(input) {
|
|
168
|
+
await put(input.key, input.body, {
|
|
169
|
+
access: "private",
|
|
170
|
+
addRandomSuffix: false,
|
|
171
|
+
allowOverwrite: true,
|
|
172
|
+
contentType: input.contentType
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
async createUploadTarget(input) {
|
|
176
|
+
const limits = {
|
|
177
|
+
allowedContentTypes: [input.contentType],
|
|
178
|
+
maximumSizeInBytes: input.bytes,
|
|
179
|
+
validUntil: input.expiresAtMs
|
|
180
|
+
};
|
|
181
|
+
const token = await issueSignedToken({
|
|
182
|
+
...limits,
|
|
183
|
+
operations: ["put"],
|
|
184
|
+
pathname: input.key
|
|
185
|
+
});
|
|
186
|
+
const { presignedUrl } = await presignUrl(token, {
|
|
187
|
+
...limits,
|
|
188
|
+
access: "private",
|
|
189
|
+
addRandomSuffix: false,
|
|
190
|
+
allowOverwrite: false,
|
|
191
|
+
operation: "put",
|
|
192
|
+
pathname: input.key
|
|
193
|
+
});
|
|
194
|
+
return {
|
|
195
|
+
headers: {
|
|
196
|
+
"x-api-version": BLOB_API_VERSION,
|
|
197
|
+
"x-content-type": input.contentType,
|
|
198
|
+
"x-vercel-blob-access": "private",
|
|
199
|
+
"x-vercel-blob-store-id": delegationStoreId(token.delegationToken)
|
|
200
|
+
},
|
|
201
|
+
method: "PUT",
|
|
202
|
+
url: presignedUrl
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
async createDownloadUrl(input) {
|
|
206
|
+
const token = await issueSignedToken({
|
|
207
|
+
operations: ["get"],
|
|
208
|
+
pathname: input.key,
|
|
209
|
+
validUntil: input.expiresAtMs
|
|
210
|
+
});
|
|
211
|
+
const { presignedUrl } = await presignUrl(token, {
|
|
212
|
+
access: "private",
|
|
213
|
+
operation: "get",
|
|
214
|
+
pathname: input.key,
|
|
215
|
+
useCache: false,
|
|
216
|
+
validUntil: input.expiresAtMs
|
|
217
|
+
});
|
|
218
|
+
return presignedUrl;
|
|
219
|
+
},
|
|
220
|
+
async get(key, range) {
|
|
221
|
+
const result = await get(key, {
|
|
222
|
+
access: "private",
|
|
223
|
+
useCache: false,
|
|
224
|
+
...range ? { headers: { range: rangeHeader(range) } } : void 0
|
|
225
|
+
});
|
|
226
|
+
if (result?.statusCode !== 200) return null;
|
|
227
|
+
if (range && !result.headers.get("content-range")) {
|
|
228
|
+
await result.stream.cancel();
|
|
229
|
+
throw new Error("Vercel Blob get ignored the byte range");
|
|
230
|
+
}
|
|
231
|
+
return result.stream;
|
|
232
|
+
},
|
|
233
|
+
async delete(keys) {
|
|
234
|
+
if (keys.length === 0) return;
|
|
235
|
+
await del(keys);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
// src/chat/attachments/storage.ts
|
|
240
|
+
/** Stream bytes that are already in memory to `AttachmentStorage.put`. */
|
|
241
|
+
function bufferBody(data) {
|
|
242
|
+
return new ReadableStream({ start(controller) {
|
|
243
|
+
controller.enqueue(data);
|
|
244
|
+
controller.close();
|
|
245
|
+
} });
|
|
246
|
+
}
|
|
247
|
+
/** Build the HTTP `Range` request header value for one byte range. */
|
|
248
|
+
function rangeHeader(range) {
|
|
249
|
+
return `bytes=${range.start}-${range.end}`;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Return attachment storage for the configured provider.
|
|
253
|
+
*
|
|
254
|
+
* Callers do not choose a provider. Chat config decides it.
|
|
255
|
+
*/
|
|
256
|
+
function getAttachmentStorage() {
|
|
257
|
+
return createAttachmentStorage(getChatConfig().attachmentStorage);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Create attachment storage for one provider config.
|
|
261
|
+
*
|
|
262
|
+
* Runtime code uses `getAttachmentStorage()`. Call this only to test a
|
|
263
|
+
* provider adapter with its own config.
|
|
264
|
+
*/
|
|
265
|
+
function createAttachmentStorage(config) {
|
|
266
|
+
switch (config.provider) {
|
|
267
|
+
case "vercel-blob": return createVercelAttachmentStorage();
|
|
268
|
+
case "s3": return createS3AttachmentStorage(config.s3);
|
|
269
|
+
case "memory": return createMemoryAttachmentStorage();
|
|
270
|
+
default: throw new Error(`Unsupported attachment storage provider: ${String(config.provider)}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
export { getAttachmentStorage as n, bufferBody as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
-
import { D as isToolResultError, F as SESSION_CONTEXT_SECTION_TAG, I as TURN_CONTEXT_TAG, N as CAPABILITY_SECTION_TAG, O as isToolResultMessage, P as REQUEST_CONTEXT_SECTION_TAG, _ as extractAssistantText, d as SANDBOX_WORKSPACE_ROOT, f as sandboxSkillDir, h as createPluginLogger, k as normalizeToolNameFromResult, n as toPromptContributionContext, o as SANDBOX_DATA_ROOT, r as runPluginHooksAtOnce, t as PLUGIN_PROMPT_CONTRIBUTION_TOTAL_MAX_CHARS, w as isAssistantMessage } from "./prompt-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { D as isToolResultError, F as SESSION_CONTEXT_SECTION_TAG, I as TURN_CONTEXT_TAG, N as CAPABILITY_SECTION_TAG, O as isToolResultMessage, P as REQUEST_CONTEXT_SECTION_TAG, _ as extractAssistantText, d as SANDBOX_WORKSPACE_ROOT, f as sandboxSkillDir, h as createPluginLogger, k as normalizeToolNameFromResult, n as toPromptContributionContext, o as SANDBOX_DATA_ROOT, r as runPluginHooksAtOnce, t as PLUGIN_PROMPT_CONTRIBUTION_TOTAL_MAX_CHARS, w as isAssistantMessage } from "./prompt-3TqxEOtc.js";
|
|
3
|
+
import { m as worldPathCandidates, p as soulPathCandidates, u as listReferenceFiles } from "./topics-DxuKurCX.js";
|
|
4
|
+
import { m as logWarn, p as logInfo } from "./logging-BRPTXAdf.js";
|
|
5
5
|
import * as z from "zod";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { escapeClosingTag, escapeTagText, escapeTagTextAndQuotes, findTags, indentTagLines, markdownNodes, openingTag, parseMarkdown, promptMessageSchema, renderInlineTag, renderTag, unescapeTagText } from "@sentry/junior-plugin-api";
|
|
@@ -234,44 +234,11 @@ async function getPluginSystemPromptContributions(plugins, platform) {
|
|
|
234
234
|
}
|
|
235
235
|
// src/chat/system-prompt-rules.ts
|
|
236
236
|
/**
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* each rule has one block, so order and priority stay stable:
|
|
243
|
-
*
|
|
244
|
-
* 1. Identity: one header sentence with the role and the precedence rule,
|
|
245
|
-
* then the name and platform identity.
|
|
246
|
-
* 2. Working principles: `<task-execution>` (or `<automation-run>`,
|
|
247
|
-
* `<child-agent-run>`) says what the job is, when to continue, and when
|
|
248
|
-
* to ask. A Lead also gets `<lead>`, which says how it runs the Space's
|
|
249
|
-
* work. `<evidence>` says what to claim, how to mark
|
|
250
|
-
* inference, how to find a failure cause, and how to handle pushback.
|
|
251
|
-
* 3. Context and trust: `<context-trust>` holds generic rules for context
|
|
252
|
-
* inputs, with no tag table and no context data.
|
|
253
|
-
* 4. Actions and safety: `<safety>` holds action limits, approvals, and
|
|
254
|
-
* retries with side effects.
|
|
255
|
-
* 5. Tools and skills: `<tool-policy>` and `<skill-policy>` hold rules
|
|
256
|
-
* that span tools. A rule for one tool goes in its description.
|
|
257
|
-
* 6. Communication and output: `<tool-call-style>`, `<conversation>`,
|
|
258
|
-
* `<slack-actions>`, `<failure-reporting>`, `<output>`.
|
|
259
|
-
* 7. Personality: the consumer's `SOUL.md`, for voice and tone only.
|
|
260
|
-
* 8. World: the consumer's `WORLD.md`, for operator facts and workflow.
|
|
261
|
-
* 9. Plugin guidance: `<plugin-system-context>` from plugin `systemPrompt`
|
|
262
|
-
* hooks.
|
|
263
|
-
*
|
|
264
|
-
* Blocks 7 to 9 come last, and the identity header says that core rules win
|
|
265
|
-
* over them. A Prompt mode can replace the content of a block, but cannot add
|
|
266
|
-
* or move one. `<tool-call-style>`, `<conversation>`, and the conversation
|
|
267
|
-
* lines of `<context-trust>` are only for a person's input. `child_agent`
|
|
268
|
-
* also gets the Inbox item line of `<context-trust>`, because a child gets
|
|
269
|
-
* answers to its own items. `<slack-actions>` is only for a person's input on
|
|
270
|
-
* Slack. `thread` and `automation` hold two rule sets, with `for` set to the
|
|
271
|
-
* sender.
|
|
272
|
-
*
|
|
273
|
-
* Put a new rule in the block that owns it. If no block fits, change this map
|
|
274
|
-
* in the same change. The `build-tools` repo skill says how to write a rule.
|
|
237
|
+
* Block map: 1 and 7-9 (`SOUL.md`, `WORLD.md`, plugins) are in `prompt.ts`.
|
|
238
|
+
* 2 `<task-execution>` or `<automation-run>`/`<child-agent-run>`, `<lead>`,
|
|
239
|
+
* `<evidence>`; 3 `<context-trust>`; 4 `<safety>`; 5 `<tool-policy>`,
|
|
240
|
+
* `<skill-policy>`; 6 `<tool-call-style>`, `<conversation>`, `<slack-actions>`,
|
|
241
|
+
* `<failure-reporting>`, `<output>`. A mode never adds or moves a block.
|
|
275
242
|
*/
|
|
276
243
|
/**
|
|
277
244
|
* The rule sets of each Prompt mode, in prompt order. A rule set with a
|
|
@@ -316,9 +283,9 @@ function buildIdentityHeader(platform, mode) {
|
|
|
316
283
|
/**
|
|
317
284
|
* Block 2, `<task-execution>`: what the job is in a conversation, when to keep
|
|
318
285
|
* going, and when to ask. Junior acts as a colleague who owns the task, so it
|
|
319
|
-
* makes small decisions itself instead of asking.
|
|
320
|
-
* present an inferred fact as verified. The
|
|
321
|
-
* `
|
|
286
|
+
* makes small decisions itself instead of asking. It may infer intent, but it
|
|
287
|
+
* must not present an inferred fact as verified. The `automation` and
|
|
288
|
+
* `child_agent` modes replace this section with their own.
|
|
322
289
|
*/
|
|
323
290
|
const TASK_EXECUTION_RULES = [
|
|
324
291
|
"- Work as a trusted colleague who owns the task. Make the reasonable small decisions yourself and take the next appropriate step. Do not ask the user to confirm each step.",
|
|
@@ -353,12 +320,10 @@ const AUTOMATION_RUN_RULES = [
|
|
|
353
320
|
`- Use \`${NO_REPLY_TOOL_NAME}\` when the run worked and nothing should be posted, such as when a condition in the instruction is not met, or when a temporary failure stopped the work.`
|
|
354
321
|
];
|
|
355
322
|
/**
|
|
356
|
-
* Block 2, `<lead>`: how a Space's Lead runs the Space's work.
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
* holds the rules that it shares with other Conversations, such as how to
|
|
361
|
-
* ask a person.
|
|
323
|
+
* Block 2, `<lead>`: how a Space's Lead runs the Space's work. It plans,
|
|
324
|
+
* starts, reviews, and connects its child agents' work and never does it
|
|
325
|
+
* itself. Its tool list has no tools for the work, so the rules say where work
|
|
326
|
+
* goes. `<task-execution>` holds the rules it shares, such as how to ask.
|
|
362
327
|
*/
|
|
363
328
|
const LEAD_RULES = [
|
|
364
329
|
"- The members of the Space talk to you, and the person of a Turn is the member who sent its input. Your child agents are the Space's other Conversations.",
|
|
@@ -555,7 +520,7 @@ const TOOL_CALL_STYLE_RULES = [
|
|
|
555
520
|
];
|
|
556
521
|
/**
|
|
557
522
|
* Block 6, `<conversation>`: how replies fit the thread, including follow-ups
|
|
558
|
-
* and resumed Turns.
|
|
523
|
+
* and resumed Turns. It and `<slack-actions>` apply only to a person's input.
|
|
559
524
|
*/
|
|
560
525
|
const CONVERSATION_RULES = ["- In thread follow-ups, answer from prior thread context; do not repeat resolved clarifying questions.", "- Runtime owns continuation and authorization notices; on resumed turns, answer with the final requested content only."];
|
|
561
526
|
/**
|
|
@@ -694,28 +659,11 @@ function buildRuleBlocks(platform, mode) {
|
|
|
694
659
|
}
|
|
695
660
|
// src/chat/prompt.ts
|
|
696
661
|
/**
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
* context
|
|
701
|
-
*
|
|
702
|
-
* The system prompt is the same for every Turn of one deployment, platform,
|
|
703
|
-
* and Prompt mode, so it holds no request, actor, time, or Conversation data.
|
|
704
|
-
* Facts for one request go in the context message: a user-role message before
|
|
705
|
-
* the current instruction, with `<runtime-turn-context>`, `AGENTS.md` at Turn
|
|
706
|
-
* start, and `<thread-context>`, each in its own content part. The current
|
|
707
|
-
* instruction is a separate user-role message with only a person's words and
|
|
708
|
-
* attachments. Tool results, files, and fetched pages are tool result
|
|
709
|
-
* messages.
|
|
710
|
-
*
|
|
711
|
-
* A Turn adds `AGENTS.md` only when it differs from the latest copy in
|
|
712
|
-
* history. An `AGENTS.md` that the Turn finds or changes later is a new
|
|
713
|
-
* user-role message at the end of history, because earlier messages do not
|
|
714
|
-
* change. Only context compaction rewrites them.
|
|
715
|
-
*
|
|
716
|
-
* Runtime context is session-scoped bootstrap data; it must stay separate
|
|
717
|
-
* from durable conversation history so compaction does not retain runtime
|
|
718
|
-
* instructions as user text.
|
|
662
|
+
* Builds the static system prompt, with no request, actor, time, or
|
|
663
|
+
* Conversation data, and the per-Turn context message before the instruction:
|
|
664
|
+
* `<runtime-turn-context>`, `AGENTS.md`, and `<thread-context>`, a part each.
|
|
665
|
+
* Runtime context stays out of durable history. A Turn adds `AGENTS.md` only
|
|
666
|
+
* when it differs from history, and a later change as a new message at the end.
|
|
719
667
|
*/
|
|
720
668
|
const DEFAULT_SOUL = "You are a practical and concise assistant.";
|
|
721
669
|
function getLoggedMarkdownFiles() {
|
|
@@ -986,16 +934,10 @@ function buildContextSection(params) {
|
|
|
986
934
|
}
|
|
987
935
|
/**
|
|
988
936
|
* Capability sections: the skills, MCP catalogs, tool guidance, Workspaces,
|
|
989
|
-
* and
|
|
990
|
-
*
|
|
991
|
-
*
|
|
992
|
-
*
|
|
993
|
-
* At Turn start, one system message sets each section that differs from the
|
|
994
|
-
* section state of history, or removes an empty one. System messages before
|
|
995
|
-
* the first assistant message fold into the system prompt. Pi sends a later
|
|
996
|
-
* one before the next assistant message, or folds it into the system prompt
|
|
997
|
-
* for a model without mid-conversation system messages. Context compaction
|
|
998
|
-
* folds the section state into one system message.
|
|
937
|
+
* and script tools the model can use now, or null when empty. At Turn start,
|
|
938
|
+
* one system message sets or removes each section that differs from history,
|
|
939
|
+
* so the Turn context and history stay the same. Compaction folds the section
|
|
940
|
+
* state into one system message.
|
|
999
941
|
*/
|
|
1000
942
|
function buildCapabilitySections(params) {
|
|
1001
943
|
const contents = {
|
|
@@ -1110,7 +1052,7 @@ function buildCoreSystemPromptSections(platform, mode, botName, files = {
|
|
|
1110
1052
|
}] : []
|
|
1111
1053
|
];
|
|
1112
1054
|
}
|
|
1113
|
-
/** Build
|
|
1055
|
+
/** Build the per-Turn runtime context, which stays out of the system prompt. */
|
|
1114
1056
|
function buildTurnContextPrompt(params) {
|
|
1115
1057
|
const includeSessionContext = params.includeSessionContext ?? true;
|
|
1116
1058
|
const pluginPromptContributions = renderPluginContextSection(params.pluginPromptContributions);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// src/core/turn/topic.ts
|
|
2
|
+
/** Queue topic of Turn step messages. */
|
|
3
|
+
const TURN_STEP_TOPIC = "junior_turn_step";
|
|
4
|
+
/** Queue topic of the messages that say a Turn ended. */
|
|
5
|
+
const TURN_ENDED_TOPIC = "junior_turn_ended";
|
|
6
|
+
export { TURN_STEP_TOPIC as n, TURN_ENDED_TOPIC as t };
|
|
@@ -3,6 +3,16 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import fs, { statSync } from "node:fs";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
// src/chat/optional-string.ts
|
|
7
|
+
/**
|
|
8
|
+
* Normalize optional env-style strings so blank values do not masquerade as
|
|
9
|
+
* configured inputs.
|
|
10
|
+
*/
|
|
11
|
+
function toOptionalTrimmed(value) {
|
|
12
|
+
if (!value) return;
|
|
13
|
+
const trimmed = value.trim();
|
|
14
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
15
|
+
}
|
|
6
16
|
// src/package-resolution.ts
|
|
7
17
|
function isDirectory$1(targetPath) {
|
|
8
18
|
try {
|
|
@@ -447,4 +457,14 @@ function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
|
|
|
447
457
|
tracingIncludes: uniqueStringsInOrder(tracingIncludes)
|
|
448
458
|
};
|
|
449
459
|
}
|
|
450
|
-
|
|
460
|
+
// src/chat/queue/topics.ts
|
|
461
|
+
/**
|
|
462
|
+
* Queue topic names. Vercel queue wiring uses them at build, so keep them
|
|
463
|
+
* stable, and keep this module free of runtime configuration.
|
|
464
|
+
*/
|
|
465
|
+
const CACHE_WARMUP_QUEUE_TOPIC = "junior_cache_warmups";
|
|
466
|
+
const PLUGIN_TASK_QUEUE_TOPIC = "junior_plugin_tasks";
|
|
467
|
+
const WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC = "junior_workspace_snapshots";
|
|
468
|
+
const BACKGROUND_COMPACTION_QUEUE_TOPIC = "junior_context_compaction";
|
|
469
|
+
const DEFAULT_CONVERSATION_WORK_QUEUE_TOPIC = "junior_conversation_work";
|
|
470
|
+
export { toOptionalTrimmed as _, WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC as a, discovery_exports as c, pluginRoots as d, skillRoots as f, resolvePackageDir as g, isValidPackageName as h, PLUGIN_TASK_QUEUE_TOPIC as i, homeDir as l, worldPathCandidates as m, CACHE_WARMUP_QUEUE_TOPIC as n, discoverInstalledPluginPackageContent as o, soulPathCandidates as p, DEFAULT_CONVERSATION_WORK_QUEUE_TOPIC as r, normalizePluginPackageNames as s, BACKGROUND_COMPACTION_QUEUE_TOPIC as t, listReferenceFiles as u };
|