@sentry/junior 0.136.1 → 0.138.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/{agent-hooks-2KDSPPO4.js → agent-hooks-SCR74Q3E.js} +11 -9
- package/dist/api/conversations/projection.d.ts +1 -0
- package/dist/api/conversations/stats.d.ts +1 -0
- package/dist/api/schema/conversation.d.ts +2 -0
- package/dist/api/schema.js +1 -1
- package/dist/api.js +187 -46
- package/dist/app.d.ts +8 -1
- package/dist/app.js +519 -860
- package/dist/{catalog-runtime-WSZQGC4D.js → catalog-runtime-IU3QF4GG.js} +5 -5
- package/dist/chat/agent/request.d.ts +32 -2
- package/dist/chat/agent-dispatch/heartbeat.d.ts +5 -0
- package/dist/chat/agent-dispatch/types.d.ts +1 -1
- package/dist/chat/agent-invocations/errors.d.ts +8 -0
- package/dist/chat/agent-invocations/spawn.d.ts +12 -0
- package/dist/chat/agent-invocations/store.d.ts +44 -0
- package/dist/chat/agent-invocations/types.d.ts +449 -0
- package/dist/chat/agent-invocations/work.d.ts +31 -0
- package/dist/chat/config.d.ts +1 -0
- package/dist/chat/configuration/defaults.d.ts +1 -1
- package/dist/chat/conversations/sql/store.d.ts +8 -0
- package/dist/chat/conversations/store.d.ts +9 -1
- package/dist/chat/experimental.d.ts +16 -0
- package/dist/chat/pi/client.d.ts +1 -8
- package/dist/chat/pi/gateway-auth.d.ts +16 -0
- package/dist/chat/runtime/agent-runner.d.ts +2 -1
- package/dist/chat/sandbox/docker.d.ts +17 -0
- package/dist/chat/services/agent-continue.d.ts +2 -0
- package/dist/chat/services/auth-pause.d.ts +0 -1
- package/dist/chat/services/mcp-auth-orchestration.d.ts +3 -2
- package/dist/chat/services/plugin-auth-orchestration.d.ts +3 -2
- package/dist/chat/services/subscribed-reply-router-policy.d.ts +12 -0
- package/dist/chat/services/turn-session-routing.d.ts +17 -0
- package/dist/chat/slack/message.d.ts +6 -1
- package/dist/chat/slack/source-link.d.ts +8 -2
- package/dist/chat/slack/team-domain.d.ts +4 -0
- package/dist/chat/source.d.ts +5 -5
- package/dist/chat/state/turn-session.d.ts +0 -2
- package/dist/chat/task-execution/state.d.ts +23 -11
- package/dist/chat/task-execution/store.d.ts +20 -11
- package/dist/chat/task-execution/worker.d.ts +2 -2
- package/dist/chat/tools/runtime/spawn-agent.d.ts +31 -0
- package/dist/chat/tools/types.d.ts +2 -0
- package/dist/chunk-3Y47VMHV.js +6 -0
- package/dist/chunk-5IDFPCON.js +46 -0
- package/dist/chunk-5LTJ4ITU.js +1523 -0
- package/dist/{chunk-KLBYCSLJ.js → chunk-5MXWHTCK.js} +17 -434
- package/dist/{chunk-CZZDCH3Q.js → chunk-A7WCHXZV.js} +206 -78
- package/dist/{chunk-4YQ6I6VF.js → chunk-BOLJOV5T.js} +2 -56
- package/dist/{chunk-XCZ6COFO.js → chunk-BYW4B4PR.js} +90 -54
- package/dist/{chunk-JQRTXJHD.js → chunk-C7ZVPO4Z.js} +2 -1
- package/dist/{chunk-MW2QRPGW.js → chunk-DCLLQGS6.js} +119 -50
- package/dist/{chunk-CDVCCOMF.js → chunk-E5UYAIKJ.js} +75 -1475
- package/dist/{chunk-3SUK3UXX.js → chunk-ELKW5FIB.js} +5 -5
- package/dist/chunk-EM225ITJ.js +56 -0
- package/dist/{chunk-Y6JNHTRD.js → chunk-FEUNPTGV.js} +34 -70
- package/dist/{chunk-TYNMSQKA.js → chunk-FNLBTB4K.js} +1 -1
- package/dist/{chunk-TRZSM67C.js → chunk-HCIVH3JS.js} +1 -0
- package/dist/chunk-HIWJWWMT.js +668 -0
- package/dist/chunk-IUFM5JWV.js +24 -0
- package/dist/{chunk-XWPA5KZF.js → chunk-JNNJZURV.js} +1 -1
- package/dist/{chunk-6ZK6FZIV.js → chunk-KCBZSJRU.js} +6 -27
- package/dist/{chunk-BG3KWWDJ.js → chunk-KDCHVT25.js} +1 -1
- package/dist/{chunk-VH6MI4L7.js → chunk-KFRHRSCJ.js} +1 -1
- package/dist/chunk-LPVUNO2W.js +320 -0
- package/dist/{chunk-G66RYKRS.js → chunk-N7WARMC6.js} +16 -776
- package/dist/chunk-PB3CXNVL.js +41 -0
- package/dist/chunk-Q6QZTTLS.js +55 -0
- package/dist/{chunk-3QNJOHKG.js → chunk-QS527AV5.js} +1 -1
- package/dist/chunk-R776HKPK.js +81 -0
- package/dist/{chunk-OTJMQYVP.js → chunk-RZIBSCYC.js} +517 -608
- package/dist/chunk-SD3OFRWY.js +714 -0
- package/dist/{chunk-HIRIWTWD.js → chunk-SIPKWSXK.js} +58 -10
- package/dist/chunk-TCS76X5D.js +441 -0
- package/dist/{chunk-UX2TNH5D.js → chunk-TDJCLNDH.js} +3 -3
- package/dist/{chunk-NVVBEJUB.js → chunk-TUUDXEXU.js} +336 -300
- package/dist/{chunk-22Z6MGMK.js → chunk-VPZFVJND.js} +1 -1
- package/dist/{chunk-RFDD3Z2I.js → chunk-YU5QUF67.js} +1 -1
- package/dist/chunk-ZBSMCXKV.js +710 -0
- package/dist/{chunk-FSYXYBWU.js → chunk-ZXNTJJIE.js} +2 -2
- package/dist/cli/chat.js +65 -26
- package/dist/cli/check.js +7 -7
- package/dist/cli/plugins.js +14 -12
- package/dist/cli/snapshot-create.js +10 -9
- package/dist/cli/upgrade.js +7 -7
- package/dist/conversation-work-KATFHLG3.js +56 -0
- package/dist/db/schema/agent-invocations.d.ts +544 -0
- package/dist/db/schema.d.ts +543 -1
- package/dist/{db-Z2NNL2JC.js → db-UO2IWXGA.js} +7 -7
- package/dist/experimental-HH6OM6UH.js +13 -0
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +4 -3
- package/dist/{oauth-callback-server-PO3M5JMG.js → oauth-callback-server-MAQI43LX.js} +26 -18
- package/dist/{runner-QHQYZYJA.js → runner-PIUQEXKE.js} +26 -14
- package/dist/{skills-KXMT3DRA.js → skills-4ARJADHQ.js} +6 -6
- package/dist/spawn-G2AWPMCT.js +38 -0
- package/dist/{validation-Y42ULTT6.js → validation-S3EE3HWL.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/work-UARRUAW3.js +46 -0
- package/dist/worker-DOCIRVD3.js +24 -0
- package/migrations/0021_first_warhawk.sql +35 -0
- package/migrations/meta/0021_snapshot.json +2176 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +6 -5
|
@@ -1,42 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentInvocationBusyError,
|
|
3
|
+
AgentInvocationLimitError,
|
|
4
|
+
AuthPausePersistenceError,
|
|
5
|
+
AuthorizationFlowDisabledError,
|
|
6
|
+
AuthorizationPauseError,
|
|
7
|
+
PluginCredentialFailureError,
|
|
8
|
+
agentNameSchema,
|
|
9
|
+
createPluginAuthOrchestration
|
|
10
|
+
} from "./chunk-LPVUNO2W.js";
|
|
1
11
|
import {
|
|
2
12
|
authorizationId
|
|
3
13
|
} from "./chunk-DIB4GX3G.js";
|
|
4
14
|
import {
|
|
5
15
|
McpProviderError,
|
|
6
16
|
McpToolError,
|
|
7
|
-
RetryableDeliveryError,
|
|
8
|
-
actorFromRouting,
|
|
9
|
-
addReactionToMessage,
|
|
10
|
-
assertRunRoutingConsistency,
|
|
11
17
|
createMcpOAuthClientProvider,
|
|
12
18
|
createUserTokenStore,
|
|
13
19
|
deleteMcpAuthSession,
|
|
14
|
-
deliverOAuthAuthorization,
|
|
15
|
-
formatProviderLabel,
|
|
16
20
|
getMcpAuthSession,
|
|
17
21
|
getMcpAwareErrorType,
|
|
18
22
|
getMcpAwareTelemetryMessage,
|
|
19
23
|
getMcpProviderErrorAttributes,
|
|
20
|
-
getSlackMessagePermalink,
|
|
21
24
|
hasEgressCredentialHooks,
|
|
22
25
|
issuePluginCredential,
|
|
23
26
|
issueProviderCredentialLease,
|
|
24
27
|
onPluginEgressResponse,
|
|
25
28
|
patchMcpAuthSession,
|
|
26
|
-
resolveBaseUrl,
|
|
27
29
|
selectPluginGrant,
|
|
28
|
-
|
|
30
|
+
toMcpProviderError
|
|
31
|
+
} from "./chunk-N7WARMC6.js";
|
|
32
|
+
import {
|
|
33
|
+
RetryableDeliveryError,
|
|
34
|
+
actorFromRouting,
|
|
35
|
+
assertRunRoutingConsistency,
|
|
36
|
+
isAgentRunFeatureDisabled,
|
|
29
37
|
surfaceFromRouting,
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
toolInvocationDestination
|
|
39
|
+
} from "./chunk-R776HKPK.js";
|
|
40
|
+
import {
|
|
41
|
+
addReactionToMessage,
|
|
42
|
+
deliverOAuthAuthorization,
|
|
43
|
+
formatProviderLabel,
|
|
44
|
+
getSlackMessagePermalink,
|
|
45
|
+
resolveBaseUrl,
|
|
32
46
|
uploadFilesToConversation
|
|
33
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-SD3OFRWY.js";
|
|
34
48
|
import {
|
|
35
49
|
AGENTS_REMOVAL_NOTICE,
|
|
36
50
|
AGENTS_REPLACEMENT_NOTICE,
|
|
37
51
|
CooperativeTurnYieldError,
|
|
38
52
|
DEFAULT_SEARCH_COMMAND_TIMEOUT_MS,
|
|
39
|
-
JUNIOR_THREAD_STATE_TTL_MS,
|
|
40
53
|
MAX_TEXT_CHARS,
|
|
41
54
|
NO_REPLY_MARKER,
|
|
42
55
|
RIPGREP_EXCLUDED_GLOBS,
|
|
@@ -98,18 +111,25 @@ import {
|
|
|
98
111
|
trimTrailingAssistantMessages,
|
|
99
112
|
truncateText,
|
|
100
113
|
updateConversationStats
|
|
101
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-TUUDXEXU.js";
|
|
115
|
+
import {
|
|
116
|
+
JUNIOR_THREAD_STATE_TTL_MS
|
|
117
|
+
} from "./chunk-3Y47VMHV.js";
|
|
102
118
|
import {
|
|
103
119
|
parseSandboxEgressAuthRequiredSignal,
|
|
104
120
|
parseSandboxEgressPermissionDeniedSignal,
|
|
105
121
|
sandboxEgressCredentialContextSchema,
|
|
106
122
|
sandboxEgressCredentialLeaseSchema
|
|
107
123
|
} from "./chunk-EPBBYMNE.js";
|
|
124
|
+
import {
|
|
125
|
+
isExperimentalFeatureEnabled
|
|
126
|
+
} from "./chunk-5IDFPCON.js";
|
|
108
127
|
import {
|
|
109
128
|
bindSandboxFileSystem,
|
|
110
129
|
buildCommandScript,
|
|
111
130
|
buildNonInteractiveShellScript,
|
|
112
131
|
createSandboxSession,
|
|
132
|
+
ensureDockerDaemon,
|
|
113
133
|
getSandboxResources,
|
|
114
134
|
getVercelSandboxCredentials,
|
|
115
135
|
hash,
|
|
@@ -123,7 +143,7 @@ import {
|
|
|
123
143
|
runNonInteractiveCommand,
|
|
124
144
|
throwSandboxOperationError,
|
|
125
145
|
wrapSandboxSetupError
|
|
126
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-A7WCHXZV.js";
|
|
127
147
|
import {
|
|
128
148
|
SCHEDULED_TASK_SYSTEM_ACTOR,
|
|
129
149
|
compactEventTask,
|
|
@@ -154,10 +174,10 @@ import {
|
|
|
154
174
|
resolveLocalScheduleAtMs,
|
|
155
175
|
saveEventTask,
|
|
156
176
|
writableEventTask
|
|
157
|
-
} from "./chunk-
|
|
177
|
+
} from "./chunk-TDJCLNDH.js";
|
|
158
178
|
import {
|
|
159
179
|
parseSlackThreadId
|
|
160
|
-
} from "./chunk-
|
|
180
|
+
} from "./chunk-FNLBTB4K.js";
|
|
161
181
|
import {
|
|
162
182
|
ToolInputError,
|
|
163
183
|
addAgentTurnUsage,
|
|
@@ -167,21 +187,23 @@ import {
|
|
|
167
187
|
privateTraceResultAttributes
|
|
168
188
|
} from "./chunk-UIE3R5XU.js";
|
|
169
189
|
import {
|
|
170
|
-
SlackActionError,
|
|
171
190
|
createPluginHookRunner,
|
|
172
|
-
downloadPrivateSlackFile,
|
|
173
|
-
getFilePermalink,
|
|
174
191
|
getPluginSystemPromptContributions,
|
|
175
192
|
getPluginTools,
|
|
176
193
|
getPluginUserPromptContributions,
|
|
177
|
-
getSlackClient,
|
|
178
194
|
getSlackToolContext,
|
|
195
|
+
readActorIdentity,
|
|
196
|
+
resolveChannelCapabilities
|
|
197
|
+
} from "./chunk-5MXWHTCK.js";
|
|
198
|
+
import {
|
|
199
|
+
SlackActionError,
|
|
200
|
+
downloadPrivateSlackFile,
|
|
201
|
+
getFilePermalink,
|
|
202
|
+
getSlackClient,
|
|
179
203
|
isConversationScopedChannel,
|
|
180
204
|
normalizeSlackConversationId,
|
|
181
|
-
readActorIdentity,
|
|
182
|
-
resolveChannelCapabilities,
|
|
183
205
|
withSlackRetries
|
|
184
|
-
} from "./chunk-
|
|
206
|
+
} from "./chunk-TCS76X5D.js";
|
|
185
207
|
import {
|
|
186
208
|
KNOWN_CONVERSATION_EVENT_TYPES,
|
|
187
209
|
contextProvenance,
|
|
@@ -192,17 +214,19 @@ import {
|
|
|
192
214
|
instructionActors,
|
|
193
215
|
instructionProvenanceFor,
|
|
194
216
|
sameActorIdentity
|
|
195
|
-
} from "./chunk-
|
|
217
|
+
} from "./chunk-SIPKWSXK.js";
|
|
196
218
|
import {
|
|
197
219
|
SANDBOX_DATA_ROOT,
|
|
198
220
|
SANDBOX_SKILLS_ROOT,
|
|
199
221
|
SANDBOX_WORKSPACE_ROOT,
|
|
200
|
-
getStateAdapter,
|
|
201
222
|
sandboxSkillDir,
|
|
202
223
|
sandboxSkillFile,
|
|
203
224
|
sandboxSkillPathResolution,
|
|
204
225
|
sleep
|
|
205
|
-
} from "./chunk-
|
|
226
|
+
} from "./chunk-EM225ITJ.js";
|
|
227
|
+
import {
|
|
228
|
+
getStateAdapter
|
|
229
|
+
} from "./chunk-BOLJOV5T.js";
|
|
206
230
|
import {
|
|
207
231
|
ACTIVE_TURN_COMPACTION_SUMMARY_PREFIX,
|
|
208
232
|
COMPACTION_SUMMARY_PREFIX,
|
|
@@ -223,7 +247,6 @@ import {
|
|
|
223
247
|
escapeXml,
|
|
224
248
|
findProviderError,
|
|
225
249
|
getGatewayApiKey,
|
|
226
|
-
getPiGatewayApiKey,
|
|
227
250
|
getProviderErrorAttributes,
|
|
228
251
|
hasCompactedConversationContext,
|
|
229
252
|
isCompactionSummaryText,
|
|
@@ -234,9 +257,10 @@ import {
|
|
|
234
257
|
parseTurnReasoningLevel,
|
|
235
258
|
profileConfig,
|
|
236
259
|
renderCurrentInstruction,
|
|
260
|
+
resolveGatewayCredential,
|
|
237
261
|
resolveGatewayModel,
|
|
238
262
|
unwrapCurrentInstruction
|
|
239
|
-
} from "./chunk-
|
|
263
|
+
} from "./chunk-BYW4B4PR.js";
|
|
240
264
|
import {
|
|
241
265
|
canExposeConversationPayload,
|
|
242
266
|
resolveConversationPrivacy,
|
|
@@ -246,16 +270,16 @@ import {
|
|
|
246
270
|
toGenAiMessagesTraceAttributes,
|
|
247
271
|
toGenAiPayloadMetadata,
|
|
248
272
|
toGenAiPayloadTraceAttributes
|
|
249
|
-
} from "./chunk-
|
|
273
|
+
} from "./chunk-VPZFVJND.js";
|
|
250
274
|
import {
|
|
251
275
|
discoverSkills,
|
|
252
276
|
findSkillByName,
|
|
253
277
|
loadSkillsByName,
|
|
254
278
|
parseSkillInvocation
|
|
255
|
-
} from "./chunk-
|
|
279
|
+
} from "./chunk-ZXNTJJIE.js";
|
|
256
280
|
import {
|
|
257
281
|
pluginCatalogRuntime
|
|
258
|
-
} from "./chunk-
|
|
282
|
+
} from "./chunk-QS527AV5.js";
|
|
259
283
|
import {
|
|
260
284
|
CredentialUnavailableError,
|
|
261
285
|
OAuthProviderError,
|
|
@@ -263,7 +287,7 @@ import {
|
|
|
263
287
|
getOAuthProviderErrorAttributes,
|
|
264
288
|
resolveAuthTokenPlaceholder,
|
|
265
289
|
resolvePluginCommandEnv
|
|
266
|
-
} from "./chunk-
|
|
290
|
+
} from "./chunk-KFRHRSCJ.js";
|
|
267
291
|
import {
|
|
268
292
|
credentialUserSubjectId
|
|
269
293
|
} from "./chunk-77VDLF3Z.js";
|
|
@@ -292,7 +316,7 @@ import {
|
|
|
292
316
|
summarizeMessageText,
|
|
293
317
|
withLogContext,
|
|
294
318
|
withSpan
|
|
295
|
-
} from "./chunk-
|
|
319
|
+
} from "./chunk-JNNJZURV.js";
|
|
296
320
|
import {
|
|
297
321
|
startInactiveSpan,
|
|
298
322
|
withActiveSpan
|
|
@@ -321,13 +345,6 @@ function setConfigDefaults(defaults) {
|
|
|
321
345
|
"configDefaults must be an object keyed by plugin config key"
|
|
322
346
|
);
|
|
323
347
|
}
|
|
324
|
-
for (const key of Object.keys(defaults)) {
|
|
325
|
-
if (!pluginCatalogRuntime.isConfigKey(key)) {
|
|
326
|
-
throw new Error(
|
|
327
|
-
`configDefaults: "${key}" is not a registered plugin config key`
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
348
|
installDefaults = cloneDefaults(defaults);
|
|
332
349
|
}
|
|
333
350
|
function getConfigDefaults() {
|
|
@@ -1244,47 +1261,6 @@ function toPiReasoningLevel(level) {
|
|
|
1244
1261
|
}
|
|
1245
1262
|
}
|
|
1246
1263
|
|
|
1247
|
-
// src/chat/services/auth-pause.ts
|
|
1248
|
-
var AuthorizationPauseError = class extends Error {
|
|
1249
|
-
disposition;
|
|
1250
|
-
kind;
|
|
1251
|
-
provider;
|
|
1252
|
-
providerDisplayName;
|
|
1253
|
-
requestText;
|
|
1254
|
-
constructor(kind, provider, providerDisplayName, disposition, requestText) {
|
|
1255
|
-
super(
|
|
1256
|
-
kind === "mcp" ? `MCP authorization started for ${provider}` : `Plugin authorization started for ${provider}`
|
|
1257
|
-
);
|
|
1258
|
-
this.name = kind === "mcp" ? "McpAuthorizationPauseError" : "PluginAuthorizationPauseError";
|
|
1259
|
-
this.disposition = disposition;
|
|
1260
|
-
this.kind = kind;
|
|
1261
|
-
this.provider = provider;
|
|
1262
|
-
this.providerDisplayName = providerDisplayName;
|
|
1263
|
-
this.requestText = requestText;
|
|
1264
|
-
}
|
|
1265
|
-
};
|
|
1266
|
-
var AuthPausePersistenceError = class extends Error {
|
|
1267
|
-
constructor(conversationId, turnId, cause) {
|
|
1268
|
-
super(
|
|
1269
|
-
`Failed to persist auth pause for conversation=${conversationId} turn=${turnId}`,
|
|
1270
|
-
cause === void 0 ? void 0 : { cause }
|
|
1271
|
-
);
|
|
1272
|
-
this.name = "AuthPausePersistenceError";
|
|
1273
|
-
}
|
|
1274
|
-
};
|
|
1275
|
-
var AuthorizationFlowDisabledError = class extends Error {
|
|
1276
|
-
kind;
|
|
1277
|
-
provider;
|
|
1278
|
-
constructor(kind, provider) {
|
|
1279
|
-
super(
|
|
1280
|
-
`Authorization is required for ${provider}, but this turn cannot start an authorization flow.`
|
|
1281
|
-
);
|
|
1282
|
-
this.name = "AuthorizationFlowDisabledError";
|
|
1283
|
-
this.kind = kind;
|
|
1284
|
-
this.provider = provider;
|
|
1285
|
-
}
|
|
1286
|
-
};
|
|
1287
|
-
|
|
1288
1264
|
// src/chat/conversations/destination-visibility.ts
|
|
1289
1265
|
async function resolveDestinationVisibility(args) {
|
|
1290
1266
|
if (args.visibility) {
|
|
@@ -3424,6 +3400,7 @@ function createSandboxRuntime(options) {
|
|
|
3424
3400
|
};
|
|
3425
3401
|
const prepareSandbox = async (targetSandbox) => {
|
|
3426
3402
|
await syncSkills(targetSandbox);
|
|
3403
|
+
await ensureDockerDaemon(targetSandbox);
|
|
3427
3404
|
await options.onSandboxPrepare?.(targetSandbox);
|
|
3428
3405
|
};
|
|
3429
3406
|
const applyNetworkPolicy = async (targetSandbox, traceHeaders) => {
|
|
@@ -7003,7 +6980,7 @@ function createImageGenerateTool(hooks, options, deps = {}) {
|
|
|
7003
6980
|
outputSchema: imageGenerateOutputSchema,
|
|
7004
6981
|
execute: async ({ prompt }) => {
|
|
7005
6982
|
const fetchImpl = deps.fetch ?? fetch;
|
|
7006
|
-
const apiKey = getGatewayApiKey();
|
|
6983
|
+
const apiKey = await getGatewayApiKey();
|
|
7007
6984
|
if (!apiKey) {
|
|
7008
6985
|
throw new Error(MISSING_GATEWAY_CREDENTIALS_ERROR);
|
|
7009
6986
|
}
|
|
@@ -7565,6 +7542,67 @@ function createReportProgressTool() {
|
|
|
7565
7542
|
});
|
|
7566
7543
|
}
|
|
7567
7544
|
|
|
7545
|
+
// src/chat/tools/runtime/spawn-agent.ts
|
|
7546
|
+
import { z as z17 } from "zod";
|
|
7547
|
+
var spawnAgentOutputSchema = juniorToolOutputSchema.extend({
|
|
7548
|
+
invocation_id: z17.string().min(1)
|
|
7549
|
+
});
|
|
7550
|
+
function createSpawnAgentTool(spawnAgent) {
|
|
7551
|
+
return zodTool({
|
|
7552
|
+
description: "Start an asynchronous child agent on a delegated task. Give it a name to reuse the same child agent and its history on later calls; omit the name for a one-off agent. This call confirms durable scheduling, not task completion.",
|
|
7553
|
+
annotations: {
|
|
7554
|
+
destructiveHint: false,
|
|
7555
|
+
idempotentHint: true,
|
|
7556
|
+
openWorldHint: false,
|
|
7557
|
+
readOnlyHint: false
|
|
7558
|
+
},
|
|
7559
|
+
inputSchema: z17.object({
|
|
7560
|
+
task: z17.string().trim().min(1).describe("Task for the child agent"),
|
|
7561
|
+
name: agentNameSchema.nullable().optional().describe("Stable child-agent name, or omit for a one-off agent"),
|
|
7562
|
+
reasoning_level: z17.enum(TURN_REASONING_LEVELS).nullable().optional().describe(
|
|
7563
|
+
"Optional reasoning level for this delegated task only"
|
|
7564
|
+
)
|
|
7565
|
+
}).strict(),
|
|
7566
|
+
outputSchema: spawnAgentOutputSchema,
|
|
7567
|
+
execute: async (input, options) => {
|
|
7568
|
+
if (!options.toolCallId) {
|
|
7569
|
+
throw new ToolInputError("spawnAgent requires an active tool call ID");
|
|
7570
|
+
}
|
|
7571
|
+
let result;
|
|
7572
|
+
try {
|
|
7573
|
+
result = await spawnAgent(
|
|
7574
|
+
{
|
|
7575
|
+
task: input.task,
|
|
7576
|
+
...input.name ? { name: input.name } : {},
|
|
7577
|
+
...input.reasoning_level ? { reasoningLevel: input.reasoning_level } : {}
|
|
7578
|
+
},
|
|
7579
|
+
{
|
|
7580
|
+
...options.signal ? { signal: options.signal } : {},
|
|
7581
|
+
toolCallId: options.toolCallId
|
|
7582
|
+
}
|
|
7583
|
+
);
|
|
7584
|
+
} catch (error) {
|
|
7585
|
+
if (error instanceof AgentInvocationBusyError) {
|
|
7586
|
+
throw new ToolInputError(
|
|
7587
|
+
`${error.message}. Wait for it to finish or use a different name.`,
|
|
7588
|
+
{ cause: error }
|
|
7589
|
+
);
|
|
7590
|
+
}
|
|
7591
|
+
if (error instanceof AgentInvocationLimitError) {
|
|
7592
|
+
throw new ToolInputError(
|
|
7593
|
+
`${error.message}. Wait for active children to finish before spawning more.`,
|
|
7594
|
+
{ cause: error }
|
|
7595
|
+
);
|
|
7596
|
+
}
|
|
7597
|
+
throw error;
|
|
7598
|
+
}
|
|
7599
|
+
return {
|
|
7600
|
+
invocation_id: result.invocationId
|
|
7601
|
+
};
|
|
7602
|
+
}
|
|
7603
|
+
});
|
|
7604
|
+
}
|
|
7605
|
+
|
|
7568
7606
|
// src/chat/resource-events/tool-support.ts
|
|
7569
7607
|
var STOP_WATCHING_TOOL_NAME = "stopWatchingResources";
|
|
7570
7608
|
var RESOURCE_WATCH_TOOL_SOURCE = {
|
|
@@ -7600,7 +7638,7 @@ function isSlackThreadConversationId(conversationId) {
|
|
|
7600
7638
|
}
|
|
7601
7639
|
|
|
7602
7640
|
// src/chat/tools/list-resource-event-subscriptions.ts
|
|
7603
|
-
import { z as
|
|
7641
|
+
import { z as z19 } from "zod";
|
|
7604
7642
|
|
|
7605
7643
|
// src/chat/resource-events/store.ts
|
|
7606
7644
|
import { createHash } from "crypto";
|
|
@@ -7608,29 +7646,29 @@ import {
|
|
|
7608
7646
|
destinationSchema,
|
|
7609
7647
|
resourceEventTypeSchema
|
|
7610
7648
|
} from "@sentry/junior-plugin-api";
|
|
7611
|
-
import { z as
|
|
7649
|
+
import { z as z18 } from "zod";
|
|
7612
7650
|
var RESOURCE_EVENT_PREFIX = "junior:resource_event_subscription:v3";
|
|
7613
7651
|
var INDEX_LOCK_TTL_MS = 1e4;
|
|
7614
7652
|
var SUBSCRIPTION_LOCK_TTL_MS = 1e4;
|
|
7615
7653
|
var SUBSCRIPTION_LOCK_WAIT_MS = 1e4;
|
|
7616
7654
|
var SUBSCRIPTION_LOCK_RETRY_MS = 25;
|
|
7617
7655
|
var SUBSCRIPTION_LOCK_HEARTBEAT_MS = 3e3;
|
|
7618
|
-
var subscriptionStatusSchema =
|
|
7619
|
-
var subscriptionIdIndexSchema =
|
|
7620
|
-
var subscriptionSchema =
|
|
7621
|
-
conversationId:
|
|
7622
|
-
createdAtMs:
|
|
7656
|
+
var subscriptionStatusSchema = z18.enum(["active", "cancelled", "completed"]);
|
|
7657
|
+
var subscriptionIdIndexSchema = z18.array(z18.string().min(1));
|
|
7658
|
+
var subscriptionSchema = z18.object({
|
|
7659
|
+
conversationId: z18.string().min(1),
|
|
7660
|
+
createdAtMs: z18.number().finite(),
|
|
7623
7661
|
destination: destinationSchema,
|
|
7624
|
-
events:
|
|
7625
|
-
expiresAtMs:
|
|
7626
|
-
id:
|
|
7627
|
-
intent:
|
|
7628
|
-
label:
|
|
7629
|
-
namespace:
|
|
7630
|
-
identifier:
|
|
7631
|
-
resourceType:
|
|
7662
|
+
events: z18.array(resourceEventTypeSchema).min(1),
|
|
7663
|
+
expiresAtMs: z18.number().finite(),
|
|
7664
|
+
id: z18.string().min(1),
|
|
7665
|
+
intent: z18.string().min(1),
|
|
7666
|
+
label: z18.string().min(1),
|
|
7667
|
+
namespace: z18.string().min(1),
|
|
7668
|
+
identifier: z18.string().min(1),
|
|
7669
|
+
resourceType: z18.string().min(1),
|
|
7632
7670
|
status: subscriptionStatusSchema,
|
|
7633
|
-
updatedAtMs:
|
|
7671
|
+
updatedAtMs: z18.number().finite()
|
|
7634
7672
|
}).strict();
|
|
7635
7673
|
function digest(value) {
|
|
7636
7674
|
return createHash("sha256").update(value).digest("hex").slice(0, 32);
|
|
@@ -8000,17 +8038,17 @@ async function deliverResourceEventSubscription(input) {
|
|
|
8000
8038
|
}
|
|
8001
8039
|
|
|
8002
8040
|
// src/chat/tools/list-resource-event-subscriptions.ts
|
|
8003
|
-
var listedResourceWatchSchema =
|
|
8004
|
-
id:
|
|
8005
|
-
label:
|
|
8006
|
-
identifier:
|
|
8007
|
-
namespace:
|
|
8008
|
-
resourceType:
|
|
8009
|
-
events:
|
|
8010
|
-
intent:
|
|
8011
|
-
expiresAtMs:
|
|
8041
|
+
var listedResourceWatchSchema = z19.object({
|
|
8042
|
+
id: z19.string().min(1),
|
|
8043
|
+
label: z19.string().min(1),
|
|
8044
|
+
identifier: z19.string().min(1),
|
|
8045
|
+
namespace: z19.string().min(1),
|
|
8046
|
+
resourceType: z19.string().min(1),
|
|
8047
|
+
events: z19.array(z19.string().min(1)).min(1),
|
|
8048
|
+
intent: z19.string().min(1),
|
|
8049
|
+
expiresAtMs: z19.number().finite()
|
|
8012
8050
|
}).strict();
|
|
8013
|
-
var resultDataSchema =
|
|
8051
|
+
var resultDataSchema = z19.object({ subscriptions: z19.array(listedResourceWatchSchema) }).strict();
|
|
8014
8052
|
var outputSchema = juniorToolOutputSchema.extend({
|
|
8015
8053
|
...resultDataSchema.shape
|
|
8016
8054
|
}).strict();
|
|
@@ -8025,7 +8063,7 @@ function createListResourceEventSubscriptionsTool(context) {
|
|
|
8025
8063
|
description: "List active resource event subscriptions for the current conversation.",
|
|
8026
8064
|
exposure: "deferred",
|
|
8027
8065
|
source: RESOURCE_WATCH_TOOL_SOURCE,
|
|
8028
|
-
inputSchema:
|
|
8066
|
+
inputSchema: z19.object({}).strict(),
|
|
8029
8067
|
outputSchema,
|
|
8030
8068
|
async execute() {
|
|
8031
8069
|
const conversationId = requireResourceWatchConversation(context);
|
|
@@ -8052,20 +8090,20 @@ function createListResourceEventSubscriptionsTool(context) {
|
|
|
8052
8090
|
}
|
|
8053
8091
|
|
|
8054
8092
|
// src/chat/tools/search-resource-event-types.ts
|
|
8055
|
-
import { z as
|
|
8093
|
+
import { z as z20 } from "zod";
|
|
8056
8094
|
var DEFAULT_SEARCH_RESULTS = 10;
|
|
8057
8095
|
var MAX_SEARCH_RESULTS = 20;
|
|
8058
|
-
var searchedResourceTypeSchema =
|
|
8059
|
-
namespace:
|
|
8060
|
-
type:
|
|
8061
|
-
supportedEvents:
|
|
8062
|
-
suggestedEvents:
|
|
8096
|
+
var searchedResourceTypeSchema = z20.object({
|
|
8097
|
+
namespace: z20.string(),
|
|
8098
|
+
type: z20.string(),
|
|
8099
|
+
supportedEvents: z20.array(z20.string()),
|
|
8100
|
+
suggestedEvents: z20.array(z20.string()).optional()
|
|
8063
8101
|
}).strict();
|
|
8064
8102
|
var outputSchema2 = juniorToolOutputSchema.extend({
|
|
8065
|
-
query:
|
|
8066
|
-
namespace:
|
|
8067
|
-
totalMatches:
|
|
8068
|
-
resourceTypes:
|
|
8103
|
+
query: z20.string().nullable(),
|
|
8104
|
+
namespace: z20.string().nullable(),
|
|
8105
|
+
totalMatches: z20.number().int().nonnegative(),
|
|
8106
|
+
resourceTypes: z20.array(searchedResourceTypeSchema)
|
|
8069
8107
|
}).strict();
|
|
8070
8108
|
function normalizeSearchText(value) {
|
|
8071
8109
|
return value.toLowerCase().replace(/[^a-z0-9_.-]+/g, " ").trim();
|
|
@@ -8091,12 +8129,12 @@ function createSearchResourceEventTypesTool(catalog) {
|
|
|
8091
8129
|
readOnlyHint: true
|
|
8092
8130
|
},
|
|
8093
8131
|
description: "Search the resource event types currently enabled by plugins without creating anything. Use watchResourceEvents to receive temporary updates in the current Slack thread; use createEventTask to execute a durable instruction for matching events. When explaining results, preserve that distinction. This tool does not watch a resource, create a task, or enumerate concrete resources.",
|
|
8094
|
-
inputSchema:
|
|
8095
|
-
query:
|
|
8132
|
+
inputSchema: z20.object({
|
|
8133
|
+
query: z20.string().nullable().describe(
|
|
8096
8134
|
"Optional terms matching a namespace, resource type, or event name. Empty lists all enabled resource event types."
|
|
8097
8135
|
).optional(),
|
|
8098
8136
|
namespace: eventNamespaceSchema(catalog).nullable().describe("Optional enabled plugin namespace to search within.").optional(),
|
|
8099
|
-
maxResults:
|
|
8137
|
+
maxResults: z20.number().int().min(1).max(MAX_SEARCH_RESULTS).nullable().describe("Maximum matching resource types to return.").optional()
|
|
8100
8138
|
}).strict(),
|
|
8101
8139
|
outputSchema: outputSchema2,
|
|
8102
8140
|
async execute({ query, namespace, maxResults }) {
|
|
@@ -8134,10 +8172,10 @@ function createSearchResourceEventTypesTool(catalog) {
|
|
|
8134
8172
|
}
|
|
8135
8173
|
|
|
8136
8174
|
// src/chat/tools/stop-watching-resources.ts
|
|
8137
|
-
import { z as
|
|
8138
|
-
var resultDataSchema2 =
|
|
8139
|
-
watching_status:
|
|
8140
|
-
stoppedIds:
|
|
8175
|
+
import { z as z21 } from "zod";
|
|
8176
|
+
var resultDataSchema2 = z21.object({
|
|
8177
|
+
watching_status: z21.literal("stopped"),
|
|
8178
|
+
stoppedIds: z21.array(z21.string().min(1))
|
|
8141
8179
|
}).strict();
|
|
8142
8180
|
var outputSchema3 = juniorToolOutputSchema.extend({
|
|
8143
8181
|
...resultDataSchema2.shape
|
|
@@ -8153,7 +8191,7 @@ function createStopWatchingResourcesTool(context) {
|
|
|
8153
8191
|
description: "Stop one resource watch in the current Slack thread by id. Omit id only when the user explicitly asks to stop every watch in this thread. Infer terse stop requests from context, inspect active watches when the target is unclear, and call this tool before confirming that watching stopped.",
|
|
8154
8192
|
exposure: "deferred",
|
|
8155
8193
|
source: RESOURCE_WATCH_TOOL_SOURCE,
|
|
8156
|
-
inputSchema:
|
|
8194
|
+
inputSchema: z21.object({ id: z21.string().min(1).nullable().optional() }).strict(),
|
|
8157
8195
|
outputSchema: outputSchema3,
|
|
8158
8196
|
async execute({ id }) {
|
|
8159
8197
|
const conversationId = requireResourceWatchConversation(context);
|
|
@@ -8188,26 +8226,26 @@ function createStopWatchingResourcesTool(context) {
|
|
|
8188
8226
|
}
|
|
8189
8227
|
|
|
8190
8228
|
// src/chat/tools/watch-resource-events.ts
|
|
8191
|
-
import { z as
|
|
8229
|
+
import { z as z22 } from "zod";
|
|
8192
8230
|
var DEFAULT_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
8193
8231
|
var MAX_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
8194
8232
|
function inputSchema(catalog) {
|
|
8195
|
-
return
|
|
8196
|
-
identifier:
|
|
8233
|
+
return z22.object({
|
|
8234
|
+
identifier: z22.string().trim().min(1).describe("Plugin-defined resource identifier."),
|
|
8197
8235
|
namespace: eventNamespaceSchema(catalog).describe(
|
|
8198
8236
|
"Enabled plugin namespace for this resource."
|
|
8199
8237
|
),
|
|
8200
8238
|
resourceType: registeredResourceTypeSchema(catalog).describe(
|
|
8201
8239
|
"Plugin-defined resource type."
|
|
8202
8240
|
),
|
|
8203
|
-
label:
|
|
8204
|
-
events:
|
|
8241
|
+
label: z22.string().trim().min(1).max(500).describe("Human-readable resource label."),
|
|
8242
|
+
events: z22.array(registeredEventTypeSchema(catalog)).min(1).describe(
|
|
8205
8243
|
"High-signal event names to deliver to this conversation when they occur."
|
|
8206
8244
|
),
|
|
8207
|
-
intent:
|
|
8245
|
+
intent: z22.string().trim().min(1).max(4e3).describe(
|
|
8208
8246
|
"Concise reason this conversation wants these events, used when an event arrives."
|
|
8209
8247
|
),
|
|
8210
|
-
ttlMs:
|
|
8248
|
+
ttlMs: z22.coerce.number().describe(
|
|
8211
8249
|
"How long to keep the subscription active. Defaults to 14 days and must not exceed 30 days."
|
|
8212
8250
|
).optional()
|
|
8213
8251
|
}).strict().superRefine((subscription, context) => {
|
|
@@ -8227,19 +8265,19 @@ function inputSchema(catalog) {
|
|
|
8227
8265
|
});
|
|
8228
8266
|
});
|
|
8229
8267
|
}
|
|
8230
|
-
var stopWatchingActionSchema =
|
|
8231
|
-
execution_tool:
|
|
8232
|
-
execution_example:
|
|
8233
|
-
tool_name:
|
|
8234
|
-
arguments:
|
|
8268
|
+
var stopWatchingActionSchema = z22.object({
|
|
8269
|
+
execution_tool: z22.literal("executeTool"),
|
|
8270
|
+
execution_example: z22.object({
|
|
8271
|
+
tool_name: z22.literal(STOP_WATCHING_TOOL_NAME),
|
|
8272
|
+
arguments: z22.object({ id: z22.string().min(1) }).strict()
|
|
8235
8273
|
}).strict()
|
|
8236
8274
|
}).strict();
|
|
8237
|
-
var resultDataSchema3 =
|
|
8238
|
-
id:
|
|
8239
|
-
subscription_status:
|
|
8240
|
-
identifier:
|
|
8241
|
-
events:
|
|
8242
|
-
expiresAtMs:
|
|
8275
|
+
var resultDataSchema3 = z22.object({
|
|
8276
|
+
id: z22.string().min(1),
|
|
8277
|
+
subscription_status: z22.enum(["active", "cancelled", "completed"]),
|
|
8278
|
+
identifier: z22.string().min(1),
|
|
8279
|
+
events: z22.array(z22.string().min(1)).min(1),
|
|
8280
|
+
expiresAtMs: z22.number().finite(),
|
|
8243
8281
|
stop_watching: stopWatchingActionSchema
|
|
8244
8282
|
}).strict();
|
|
8245
8283
|
var outputSchema4 = juniorToolOutputSchema.extend({
|
|
@@ -8344,7 +8382,7 @@ function createResourceEventTools(context, catalog) {
|
|
|
8344
8382
|
|
|
8345
8383
|
// src/chat/tools/create-event-task.ts
|
|
8346
8384
|
import { createHash as createHash2 } from "crypto";
|
|
8347
|
-
import { z as
|
|
8385
|
+
import { z as z23 } from "zod";
|
|
8348
8386
|
function buildEventTaskId(args) {
|
|
8349
8387
|
const toolCallId = args.toolCallId?.trim();
|
|
8350
8388
|
if (!toolCallId) {
|
|
@@ -8372,10 +8410,10 @@ function createEventTaskTool(context, catalog) {
|
|
|
8372
8410
|
},
|
|
8373
8411
|
executionMode: "sequential",
|
|
8374
8412
|
description: "Create a durable event task that executes the supplied instruction for every matching resource event. Use for whenever-this-happens-do-X automation; ordinary watch, notify, or tell-me-when requests use watchResourceEvents instead. The task remains configured for this Slack channel or DM until deleted and may use the creator's connected credentials. Prefer a subscribable tool result when available.",
|
|
8375
|
-
inputSchema:
|
|
8376
|
-
task:
|
|
8413
|
+
inputSchema: z23.object({
|
|
8414
|
+
task: z23.string().trim().min(1).max(4e3),
|
|
8377
8415
|
trigger,
|
|
8378
|
-
credentialMode:
|
|
8416
|
+
credentialMode: z23.enum(["creator", "system"]).nullable().describe(
|
|
8379
8417
|
"Use creator to make the task creator's connected credentials available, or system when the creator says not to use them. Omit or use null for the creator default."
|
|
8380
8418
|
).optional()
|
|
8381
8419
|
}).strict(),
|
|
@@ -8436,7 +8474,7 @@ function createEventTaskTool(context, catalog) {
|
|
|
8436
8474
|
}
|
|
8437
8475
|
|
|
8438
8476
|
// src/chat/tools/delete-event-task.ts
|
|
8439
|
-
import { z as
|
|
8477
|
+
import { z as z24 } from "zod";
|
|
8440
8478
|
function createDeleteEventTaskTool(context, catalog) {
|
|
8441
8479
|
return zodTool({
|
|
8442
8480
|
approvalMode: "review",
|
|
@@ -8448,7 +8486,7 @@ function createDeleteEventTaskTool(context, catalog) {
|
|
|
8448
8486
|
},
|
|
8449
8487
|
executionMode: "sequential",
|
|
8450
8488
|
description: "Delete an event task from this Slack channel or DM, including a task created from another thread in the same destination.",
|
|
8451
|
-
inputSchema:
|
|
8489
|
+
inputSchema: z24.object({ taskId: z24.string().min(1) }).strict(),
|
|
8452
8490
|
outputSchema: eventTaskToolResultSchema,
|
|
8453
8491
|
async execute({ taskId }) {
|
|
8454
8492
|
const current = await writableEventTask(context, taskId);
|
|
@@ -8464,7 +8502,7 @@ function createDeleteEventTaskTool(context, catalog) {
|
|
|
8464
8502
|
}
|
|
8465
8503
|
|
|
8466
8504
|
// src/chat/tools/list-event-tasks.ts
|
|
8467
|
-
import { z as
|
|
8505
|
+
import { z as z25 } from "zod";
|
|
8468
8506
|
var MAX_LISTED_EVENT_TASKS = 50;
|
|
8469
8507
|
function createListEventTasksTool(context, catalog) {
|
|
8470
8508
|
return zodTool({
|
|
@@ -8475,7 +8513,7 @@ function createListEventTasksTool(context, catalog) {
|
|
|
8475
8513
|
readOnlyHint: true
|
|
8476
8514
|
},
|
|
8477
8515
|
description: "List event tasks for this Slack channel or DM, including tasks created from other threads in the same destination. A false triggerAvailable value means the task remains stored but its plugin event is not currently enabled.",
|
|
8478
|
-
inputSchema:
|
|
8516
|
+
inputSchema: z25.object({}).strict(),
|
|
8479
8517
|
outputSchema: eventTaskListToolResultSchema,
|
|
8480
8518
|
async execute() {
|
|
8481
8519
|
const { destination } = requireEventTaskSlackContext(context);
|
|
@@ -8490,7 +8528,7 @@ function createListEventTasksTool(context, catalog) {
|
|
|
8490
8528
|
}
|
|
8491
8529
|
|
|
8492
8530
|
// src/chat/tools/update-event-task.ts
|
|
8493
|
-
import { z as
|
|
8531
|
+
import { z as z26 } from "zod";
|
|
8494
8532
|
function changesEventTaskTrigger(current, next) {
|
|
8495
8533
|
const currentEvents = [...current.events].sort();
|
|
8496
8534
|
const nextEvents = [...next.events].sort();
|
|
@@ -8507,11 +8545,11 @@ function createUpdateEventTaskTool(context, catalog) {
|
|
|
8507
8545
|
},
|
|
8508
8546
|
executionMode: "sequential",
|
|
8509
8547
|
description: "Update the instruction, registered trigger, or credential use for an event task in this Slack channel or DM. Event tasks created from other threads in the same destination are manageable here.",
|
|
8510
|
-
inputSchema:
|
|
8511
|
-
taskId:
|
|
8512
|
-
task:
|
|
8548
|
+
inputSchema: z26.object({
|
|
8549
|
+
taskId: z26.string().min(1),
|
|
8550
|
+
task: z26.string().trim().min(1).max(4e3).nullable().optional(),
|
|
8513
8551
|
trigger: registeredEventTaskTriggerSchema(catalog).nullable().optional(),
|
|
8514
|
-
credentialMode:
|
|
8552
|
+
credentialMode: z26.enum(["system", "creator"]).nullable().describe(
|
|
8515
8553
|
"Set creator to make the task's original creator credentials available, or system to disable them. Creator always means the task's createdBy actor, never the current requester. Only that original creator may enable creator mode. Omit or use null to leave unchanged."
|
|
8516
8554
|
).optional()
|
|
8517
8555
|
}).strict(),
|
|
@@ -8585,16 +8623,16 @@ function createEventTaskTools(context, catalog) {
|
|
|
8585
8623
|
}
|
|
8586
8624
|
|
|
8587
8625
|
// src/chat/scheduled-tasks/tools/create.ts
|
|
8588
|
-
import { z as
|
|
8626
|
+
import { z as z29 } from "zod";
|
|
8589
8627
|
|
|
8590
8628
|
// src/chat/scheduled-tasks/schedule-intent.ts
|
|
8591
|
-
import { z as
|
|
8592
|
-
var localDateSchema =
|
|
8593
|
-
var localTimeSchema =
|
|
8594
|
-
var timezoneSchema =
|
|
8629
|
+
import { z as z27 } from "zod";
|
|
8630
|
+
var localDateSchema = z27.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Use a local date in YYYY-MM-DD format.");
|
|
8631
|
+
var localTimeSchema = z27.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "Use local time in HH:MM format.");
|
|
8632
|
+
var timezoneSchema = z27.string().min(1).max(80).describe(
|
|
8595
8633
|
"IANA timezone, for example America/Los_Angeles. Omit or use null for the scheduler default."
|
|
8596
8634
|
).nullable().optional();
|
|
8597
|
-
var weekdaySchema =
|
|
8635
|
+
var weekdaySchema = z27.enum([
|
|
8598
8636
|
"sunday",
|
|
8599
8637
|
"monday",
|
|
8600
8638
|
"tuesday",
|
|
@@ -8603,17 +8641,17 @@ var weekdaySchema = z26.enum([
|
|
|
8603
8641
|
"friday",
|
|
8604
8642
|
"saturday"
|
|
8605
8643
|
]);
|
|
8606
|
-
var oneOffScheduleIntentSchema =
|
|
8607
|
-
kind:
|
|
8644
|
+
var oneOffScheduleIntentSchema = z27.object({
|
|
8645
|
+
kind: z27.literal("one_off").describe("A schedule that runs once."),
|
|
8608
8646
|
timezone: timezoneSchema,
|
|
8609
|
-
timing:
|
|
8610
|
-
|
|
8611
|
-
type:
|
|
8612
|
-
value:
|
|
8613
|
-
unit:
|
|
8647
|
+
timing: z27.discriminatedUnion("type", [
|
|
8648
|
+
z27.object({
|
|
8649
|
+
type: z27.literal("after").describe("Run after a relative delay from the server clock."),
|
|
8650
|
+
value: z27.number().int().positive().max(1e5),
|
|
8651
|
+
unit: z27.enum(["second", "minute", "hour", "day", "week"])
|
|
8614
8652
|
}).strict(),
|
|
8615
|
-
|
|
8616
|
-
type:
|
|
8653
|
+
z27.object({
|
|
8654
|
+
type: z27.literal("at").describe("Run at an explicit local calendar date and time."),
|
|
8617
8655
|
date: localDateSchema.describe(
|
|
8618
8656
|
"Requested local calendar date in YYYY-MM-DD format."
|
|
8619
8657
|
),
|
|
@@ -8623,16 +8661,16 @@ var oneOffScheduleIntentSchema = z26.object({
|
|
|
8623
8661
|
}).strict()
|
|
8624
8662
|
]).describe("Relative delay or explicit local time for the one-off run.")
|
|
8625
8663
|
}).strict();
|
|
8626
|
-
var recurringScheduleIntentSchema =
|
|
8627
|
-
kind:
|
|
8628
|
-
frequency:
|
|
8629
|
-
interval:
|
|
8664
|
+
var recurringScheduleIntentSchema = z27.object({
|
|
8665
|
+
kind: z27.literal("recurring").describe("A repeating calendar schedule."),
|
|
8666
|
+
frequency: z27.enum(["daily", "weekly", "monthly", "yearly"]).describe("Recurring tasks can run at most once per day."),
|
|
8667
|
+
interval: z27.number().int().positive().max(365).describe("Repeat every N frequency units. Defaults to 1.").nullable().optional(),
|
|
8630
8668
|
time: localTimeSchema.describe(
|
|
8631
8669
|
"Local wall-clock time for each occurrence in HH:MM format."
|
|
8632
8670
|
),
|
|
8633
|
-
weekdays:
|
|
8634
|
-
day_of_month:
|
|
8635
|
-
month:
|
|
8671
|
+
weekdays: z27.array(weekdaySchema).min(1).max(7).describe("Required for weekly schedules.").nullable().optional(),
|
|
8672
|
+
day_of_month: z27.number().int().min(1).max(31).describe("Required for monthly and yearly schedules.").nullable().optional(),
|
|
8673
|
+
month: z27.number().int().min(1).max(12).describe("Required for yearly schedules, where January is 1.").nullable().optional(),
|
|
8636
8674
|
start_date: localDateSchema.describe(
|
|
8637
8675
|
"Optional local calendar date that anchors the recurrence. Omit to start with the next matching occurrence."
|
|
8638
8676
|
).nullable().optional(),
|
|
@@ -8681,7 +8719,7 @@ var recurringScheduleIntentSchema = z26.object({
|
|
|
8681
8719
|
});
|
|
8682
8720
|
}
|
|
8683
8721
|
});
|
|
8684
|
-
var scheduleIntentSchema =
|
|
8722
|
+
var scheduleIntentSchema = z27.union([
|
|
8685
8723
|
oneOffScheduleIntentSchema,
|
|
8686
8724
|
recurringScheduleIntentSchema
|
|
8687
8725
|
]);
|
|
@@ -8841,7 +8879,7 @@ import { createHash as createHash3 } from "crypto";
|
|
|
8841
8879
|
import {
|
|
8842
8880
|
sourceSchema
|
|
8843
8881
|
} from "@sentry/junior-plugin-api";
|
|
8844
|
-
import { z as
|
|
8882
|
+
import { z as z28 } from "zod";
|
|
8845
8883
|
|
|
8846
8884
|
// src/chat/scheduled-tasks/identity.ts
|
|
8847
8885
|
var SLACK_USER_ID_PATTERN = /^[UW][A-Z0-9]{5,}$/;
|
|
@@ -8878,30 +8916,30 @@ function sanitizeScheduledTaskPrincipal(principal) {
|
|
|
8878
8916
|
var TASK_ID_PREFIX = "sched";
|
|
8879
8917
|
var MAX_LISTED_TASKS = 50;
|
|
8880
8918
|
var DEFAULT_SCHEDULE_TIMEZONE = "America/Los_Angeles";
|
|
8881
|
-
var compactTaskResultSchema =
|
|
8882
|
-
id:
|
|
8883
|
-
status:
|
|
8884
|
-
task:
|
|
8885
|
-
schedule:
|
|
8886
|
-
timezone:
|
|
8887
|
-
recurrence:
|
|
8888
|
-
next_run_at:
|
|
8889
|
-
conversation_access:
|
|
8890
|
-
audience:
|
|
8891
|
-
visibility:
|
|
8919
|
+
var compactTaskResultSchema = z28.object({
|
|
8920
|
+
id: z28.string(),
|
|
8921
|
+
status: z28.enum(["active", "blocked", "deleted"]),
|
|
8922
|
+
task: z28.string(),
|
|
8923
|
+
schedule: z28.string(),
|
|
8924
|
+
timezone: z28.string(),
|
|
8925
|
+
recurrence: z28.unknown().nullable(),
|
|
8926
|
+
next_run_at: z28.string().nullable(),
|
|
8927
|
+
conversation_access: z28.object({
|
|
8928
|
+
audience: z28.enum(["direct", "group", "channel"]),
|
|
8929
|
+
visibility: z28.enum(["private", "public"])
|
|
8892
8930
|
}).strict(),
|
|
8893
|
-
credential_mode:
|
|
8894
|
-
last_run_at:
|
|
8895
|
-
run_now_at:
|
|
8931
|
+
credential_mode: z28.enum(["system", "creator"]),
|
|
8932
|
+
last_run_at: z28.string().nullable(),
|
|
8933
|
+
run_now_at: z28.string().nullable()
|
|
8896
8934
|
}).strict();
|
|
8897
8935
|
var scheduleTaskToolResultSchema = juniorToolOutputSchema.extend({
|
|
8898
|
-
target:
|
|
8936
|
+
target: z28.string(),
|
|
8899
8937
|
task: compactTaskResultSchema
|
|
8900
8938
|
}).strict();
|
|
8901
8939
|
var scheduleListToolResultSchema = juniorToolOutputSchema.extend({
|
|
8902
|
-
target:
|
|
8903
|
-
tasks:
|
|
8904
|
-
truncated:
|
|
8940
|
+
target: z28.string(),
|
|
8941
|
+
tasks: z28.array(compactTaskResultSchema),
|
|
8942
|
+
truncated: z28.boolean()
|
|
8905
8943
|
}).strict();
|
|
8906
8944
|
function throwToolInputError(error) {
|
|
8907
8945
|
throw new ToolInputError(error);
|
|
@@ -9061,12 +9099,12 @@ function createSlackScheduleCreateTaskTool(context) {
|
|
|
9061
9099
|
},
|
|
9062
9100
|
description: "Create a one-time or recurring Junior task in the active Slack conversation when the user asks Junior to do work later or repeatedly.",
|
|
9063
9101
|
executionMode: "sequential",
|
|
9064
|
-
inputSchema:
|
|
9065
|
-
task:
|
|
9102
|
+
inputSchema: z29.object({
|
|
9103
|
+
task: z29.string().min(1).max(4e3),
|
|
9066
9104
|
schedule: scheduleIntentSchema.describe(
|
|
9067
9105
|
"When the task runs. The scheduler computes the exact next run from this intent and the server clock."
|
|
9068
9106
|
),
|
|
9069
|
-
credential_mode:
|
|
9107
|
+
credential_mode: z29.enum(["creator", "system"]).nullable().describe(
|
|
9070
9108
|
"Use creator to make the task creator's connected credentials available, or system when the creator says not to use them. Omit or use null for the creator default."
|
|
9071
9109
|
).optional()
|
|
9072
9110
|
}).strict(),
|
|
@@ -9153,7 +9191,7 @@ function createSlackScheduleCreateTaskTool(context) {
|
|
|
9153
9191
|
}
|
|
9154
9192
|
|
|
9155
9193
|
// src/chat/scheduled-tasks/tools/delete.ts
|
|
9156
|
-
import { z as
|
|
9194
|
+
import { z as z30 } from "zod";
|
|
9157
9195
|
function createSlackScheduleDeleteTaskTool(context) {
|
|
9158
9196
|
return zodTool({
|
|
9159
9197
|
annotations: {
|
|
@@ -9164,8 +9202,8 @@ function createSlackScheduleDeleteTaskTool(context) {
|
|
|
9164
9202
|
},
|
|
9165
9203
|
description: "Delete one scheduled Junior task from the active Slack conversation. Use only task IDs returned for this conversation. Do not delete schedules from threads, other channels, or another user's DM.",
|
|
9166
9204
|
executionMode: "sequential",
|
|
9167
|
-
inputSchema:
|
|
9168
|
-
task_id:
|
|
9205
|
+
inputSchema: z30.object({
|
|
9206
|
+
task_id: z30.string().min(1).describe(
|
|
9169
9207
|
"ID of the task to delete. Must be from this active Slack conversation."
|
|
9170
9208
|
)
|
|
9171
9209
|
}),
|
|
@@ -9189,7 +9227,7 @@ function createSlackScheduleDeleteTaskTool(context) {
|
|
|
9189
9227
|
}
|
|
9190
9228
|
|
|
9191
9229
|
// src/chat/scheduled-tasks/tools/list.ts
|
|
9192
|
-
import { z as
|
|
9230
|
+
import { z as z31 } from "zod";
|
|
9193
9231
|
function createSlackScheduleListTasksTool(context) {
|
|
9194
9232
|
return zodTool({
|
|
9195
9233
|
description: "List scheduled Junior tasks for the active Slack conversation. Use when the user asks what is scheduled here, or when task IDs are needed before editing, deleting, or running schedules. Only manages tasks for the active Slack DM or channel.",
|
|
@@ -9199,7 +9237,7 @@ function createSlackScheduleListTasksTool(context) {
|
|
|
9199
9237
|
openWorldHint: false,
|
|
9200
9238
|
readOnlyHint: true
|
|
9201
9239
|
},
|
|
9202
|
-
inputSchema:
|
|
9240
|
+
inputSchema: z31.object({}),
|
|
9203
9241
|
outputSchema: scheduleListToolResultSchema,
|
|
9204
9242
|
execute: async () => {
|
|
9205
9243
|
const destination = requireActiveConversation(context);
|
|
@@ -9220,7 +9258,7 @@ function createSlackScheduleListTasksTool(context) {
|
|
|
9220
9258
|
}
|
|
9221
9259
|
|
|
9222
9260
|
// src/chat/scheduled-tasks/tools/run-now.ts
|
|
9223
|
-
import { z as
|
|
9261
|
+
import { z as z32 } from "zod";
|
|
9224
9262
|
function createSlackScheduleRunTaskNowTool(context) {
|
|
9225
9263
|
return zodTool({
|
|
9226
9264
|
annotations: {
|
|
@@ -9231,8 +9269,8 @@ function createSlackScheduleRunTaskNowTool(context) {
|
|
|
9231
9269
|
},
|
|
9232
9270
|
description: "Queue an existing active scheduled Junior task to run as soon as possible, without changing its cadence. Use when the user asks to run an existing scheduled task now. Use only task IDs returned for this conversation.",
|
|
9233
9271
|
executionMode: "sequential",
|
|
9234
|
-
inputSchema:
|
|
9235
|
-
task_id:
|
|
9272
|
+
inputSchema: z32.object({
|
|
9273
|
+
task_id: z32.string().min(1).describe(
|
|
9236
9274
|
"ID of the active task to run now. Must be from this active Slack conversation."
|
|
9237
9275
|
)
|
|
9238
9276
|
}),
|
|
@@ -9260,7 +9298,7 @@ function createSlackScheduleRunTaskNowTool(context) {
|
|
|
9260
9298
|
}
|
|
9261
9299
|
|
|
9262
9300
|
// src/chat/scheduled-tasks/tools/update.ts
|
|
9263
|
-
import { z as
|
|
9301
|
+
import { z as z33 } from "zod";
|
|
9264
9302
|
function createSlackScheduleUpdateTaskTool(context) {
|
|
9265
9303
|
return zodTool({
|
|
9266
9304
|
approvalMode: "review",
|
|
@@ -9272,18 +9310,18 @@ function createSlackScheduleUpdateTaskTool(context) {
|
|
|
9272
9310
|
},
|
|
9273
9311
|
description: "Edit, reschedule, unblock, or change credential use for an existing Junior scheduled task in the active Slack conversation.",
|
|
9274
9312
|
executionMode: "sequential",
|
|
9275
|
-
inputSchema:
|
|
9276
|
-
task_id:
|
|
9313
|
+
inputSchema: z33.object({
|
|
9314
|
+
task_id: z33.string().min(1).describe(
|
|
9277
9315
|
"ID of the task to update. Must be from this active Slack conversation."
|
|
9278
9316
|
),
|
|
9279
|
-
task:
|
|
9317
|
+
task: z33.string().min(1).max(4e3).optional(),
|
|
9280
9318
|
schedule: scheduleIntentSchema.describe(
|
|
9281
9319
|
"Complete replacement schedule when rescheduling. Omit for task, status, or credential-only changes; the scheduler computes the next run."
|
|
9282
9320
|
).nullable().optional(),
|
|
9283
|
-
status:
|
|
9321
|
+
status: z33.enum(["active", "blocked"]).describe(
|
|
9284
9322
|
"Set to active to clear a blocked task, or blocked when dispatch cannot continue."
|
|
9285
9323
|
).optional(),
|
|
9286
|
-
credential_mode:
|
|
9324
|
+
credential_mode: z33.enum(["system", "creator"]).nullable().describe(
|
|
9287
9325
|
"Set creator to make the task's original creator credentials available, or system to disable them. Creator always means the task's created_by actor, never the current requester. Only that original creator may enable creator mode. Omit or use null to leave unchanged."
|
|
9288
9326
|
).optional()
|
|
9289
9327
|
}).strict(),
|
|
@@ -9452,11 +9490,11 @@ async function listThreadReplies(input) {
|
|
|
9452
9490
|
}
|
|
9453
9491
|
|
|
9454
9492
|
// src/chat/slack/timestamp-param.ts
|
|
9455
|
-
import { z as
|
|
9493
|
+
import { z as z34 } from "zod";
|
|
9456
9494
|
function slackTimestampParam(description) {
|
|
9457
|
-
return
|
|
9495
|
+
return z34.preprocess(
|
|
9458
9496
|
(value) => typeof value === "number" && Number.isFinite(value) ? String(value) : value,
|
|
9459
|
-
|
|
9497
|
+
z34.string().min(1)
|
|
9460
9498
|
).describe(description);
|
|
9461
9499
|
}
|
|
9462
9500
|
function optionalSlackTimestampParam(description) {
|
|
@@ -9487,10 +9525,10 @@ function parseRequiredSlackTimestampParam(field, value) {
|
|
|
9487
9525
|
}
|
|
9488
9526
|
|
|
9489
9527
|
// src/chat/slack/tools/channel-list-messages.ts
|
|
9490
|
-
import { z as
|
|
9491
|
-
var booleanInput2 = (description) =>
|
|
9528
|
+
import { z as z35 } from "zod";
|
|
9529
|
+
var booleanInput2 = (description) => z35.preprocess(
|
|
9492
9530
|
(value) => value === "true" ? true : value === "false" ? false : value,
|
|
9493
|
-
|
|
9531
|
+
z35.boolean()
|
|
9494
9532
|
).describe(description);
|
|
9495
9533
|
function normalizeRangeTimestamp(field, value, targetChannelId) {
|
|
9496
9534
|
if (value === void 0) {
|
|
@@ -9522,9 +9560,9 @@ function createSlackChannelListMessagesTool(context) {
|
|
|
9522
9560
|
openWorldHint: true,
|
|
9523
9561
|
readOnlyHint: true
|
|
9524
9562
|
},
|
|
9525
|
-
inputSchema:
|
|
9526
|
-
limit:
|
|
9527
|
-
cursor:
|
|
9563
|
+
inputSchema: z35.object({
|
|
9564
|
+
limit: z35.coerce.number().int().min(1).max(1e3).describe("Maximum number of messages to return across pages.").optional(),
|
|
9565
|
+
cursor: z35.string().min(1).describe("Optional cursor to continue from a prior call.").optional(),
|
|
9528
9566
|
oldest: optionalSlackTimestampParam(
|
|
9529
9567
|
"Optional oldest message timestamp (Slack ts) for range filtering."
|
|
9530
9568
|
),
|
|
@@ -9534,7 +9572,7 @@ function createSlackChannelListMessagesTool(context) {
|
|
|
9534
9572
|
inclusive: booleanInput2(
|
|
9535
9573
|
"Whether oldest/latest bounds should be inclusive."
|
|
9536
9574
|
).optional(),
|
|
9537
|
-
max_pages:
|
|
9575
|
+
max_pages: z35.coerce.number().int().min(1).max(10).describe("Maximum number of API pages to traverse in a single call.").optional()
|
|
9538
9576
|
}),
|
|
9539
9577
|
outputSchema: juniorToolOutputSchema,
|
|
9540
9578
|
execute: async ({
|
|
@@ -9597,20 +9635,20 @@ function createSlackChannelListMessagesTool(context) {
|
|
|
9597
9635
|
}
|
|
9598
9636
|
|
|
9599
9637
|
// src/chat/slack/tools/conversation-search.ts
|
|
9600
|
-
import { z as
|
|
9638
|
+
import { z as z36 } from "zod";
|
|
9601
9639
|
var DEFAULT_LIMIT = 5;
|
|
9602
9640
|
var conversationSearchOutputSchema = juniorToolOutputSchema.extend({
|
|
9603
|
-
query:
|
|
9604
|
-
count:
|
|
9605
|
-
threads:
|
|
9606
|
-
|
|
9607
|
-
conversation_id:
|
|
9608
|
-
thread_ts:
|
|
9609
|
-
message_id:
|
|
9610
|
-
message_role:
|
|
9611
|
-
message_timestamp:
|
|
9612
|
-
excerpt:
|
|
9613
|
-
permalink:
|
|
9641
|
+
query: z36.string(),
|
|
9642
|
+
count: z36.number().int().nonnegative(),
|
|
9643
|
+
threads: z36.array(
|
|
9644
|
+
z36.object({
|
|
9645
|
+
conversation_id: z36.string().min(1),
|
|
9646
|
+
thread_ts: z36.string().min(1),
|
|
9647
|
+
message_id: z36.string().min(1),
|
|
9648
|
+
message_role: z36.enum(["assistant", "user"]),
|
|
9649
|
+
message_timestamp: z36.string().datetime(),
|
|
9650
|
+
excerpt: z36.string(),
|
|
9651
|
+
permalink: z36.string().url().optional()
|
|
9614
9652
|
}).strict()
|
|
9615
9653
|
)
|
|
9616
9654
|
});
|
|
@@ -9628,9 +9666,9 @@ function createSlackConversationSearchTool(scope, currentConversationId, deps =
|
|
|
9628
9666
|
openWorldHint: false,
|
|
9629
9667
|
readOnlyHint: true
|
|
9630
9668
|
},
|
|
9631
|
-
inputSchema:
|
|
9632
|
-
query:
|
|
9633
|
-
limit:
|
|
9669
|
+
inputSchema: z36.object({
|
|
9670
|
+
query: z36.string().trim().min(1).max(200).describe("Words or a short phrase to find in prior conversations."),
|
|
9671
|
+
limit: z36.number().int().min(1).max(10).describe("Maximum number of prior conversation threads to return.").nullable().optional()
|
|
9634
9672
|
}),
|
|
9635
9673
|
outputSchema: conversationSearchOutputSchema,
|
|
9636
9674
|
execute: async ({ query, limit }) => {
|
|
@@ -9675,27 +9713,27 @@ function createSlackConversationSearchTool(scope, currentConversationId, deps =
|
|
|
9675
9713
|
}
|
|
9676
9714
|
|
|
9677
9715
|
// src/chat/slack/tools/public-search.ts
|
|
9678
|
-
import { z as
|
|
9716
|
+
import { z as z37 } from "zod";
|
|
9679
9717
|
var DEFAULT_LIMIT2 = 10;
|
|
9680
|
-
var optionalTimestampSchema =
|
|
9718
|
+
var optionalTimestampSchema = z37.preprocess(
|
|
9681
9719
|
(value) => typeof value === "string" && value.trim() === "" ? void 0 : value,
|
|
9682
|
-
|
|
9720
|
+
z37.coerce.number().int().nonnegative().describe("Optional Unix timestamp bound.").optional()
|
|
9683
9721
|
);
|
|
9684
|
-
var searchMessageSchema =
|
|
9685
|
-
author_name:
|
|
9686
|
-
author_user_id:
|
|
9687
|
-
channel_id:
|
|
9688
|
-
channel_name:
|
|
9689
|
-
message_ts:
|
|
9690
|
-
content:
|
|
9691
|
-
is_author_bot:
|
|
9692
|
-
permalink:
|
|
9722
|
+
var searchMessageSchema = z37.object({
|
|
9723
|
+
author_name: z37.string().optional(),
|
|
9724
|
+
author_user_id: z37.string().optional(),
|
|
9725
|
+
channel_id: z37.string().min(1),
|
|
9726
|
+
channel_name: z37.string().optional(),
|
|
9727
|
+
message_ts: z37.string().min(1),
|
|
9728
|
+
content: z37.string(),
|
|
9729
|
+
is_author_bot: z37.boolean().optional(),
|
|
9730
|
+
permalink: z37.string().url()
|
|
9693
9731
|
});
|
|
9694
9732
|
var publicSearchOutputSchema = juniorToolOutputSchema.extend({
|
|
9695
|
-
query:
|
|
9696
|
-
count:
|
|
9697
|
-
messages:
|
|
9698
|
-
next_cursor:
|
|
9733
|
+
query: z37.string(),
|
|
9734
|
+
count: z37.number().int().nonnegative(),
|
|
9735
|
+
messages: z37.array(searchMessageSchema),
|
|
9736
|
+
next_cursor: z37.string().optional()
|
|
9699
9737
|
});
|
|
9700
9738
|
function normalizeMessage(value) {
|
|
9701
9739
|
const parsed = searchMessageSchema.safeParse(value);
|
|
@@ -9722,8 +9760,8 @@ function createSlackPublicSearchTool(actionToken) {
|
|
|
9722
9760
|
openWorldHint: true,
|
|
9723
9761
|
readOnlyHint: true
|
|
9724
9762
|
},
|
|
9725
|
-
inputSchema:
|
|
9726
|
-
query:
|
|
9763
|
+
inputSchema: z37.object({
|
|
9764
|
+
query: z37.string().trim().min(1).max(500).describe(
|
|
9727
9765
|
"A focused Slack search query, including Slack search filters when useful."
|
|
9728
9766
|
),
|
|
9729
9767
|
after: optionalTimestampSchema.describe(
|
|
@@ -9732,10 +9770,10 @@ function createSlackPublicSearchTool(actionToken) {
|
|
|
9732
9770
|
before: optionalTimestampSchema.describe(
|
|
9733
9771
|
"Optional Unix timestamp upper bound."
|
|
9734
9772
|
),
|
|
9735
|
-
cursor:
|
|
9736
|
-
limit:
|
|
9737
|
-
sort:
|
|
9738
|
-
sort_dir:
|
|
9773
|
+
cursor: z37.string().min(1).describe("Cursor for the next result page.").optional(),
|
|
9774
|
+
limit: z37.coerce.number().int().min(1).max(20).describe("Maximum results to return; Slack allows at most 20.").optional(),
|
|
9775
|
+
sort: z37.enum(["score", "timestamp"]).describe("Rank by relevance or timestamp.").optional(),
|
|
9776
|
+
sort_dir: z37.enum(["asc", "desc"]).describe("Sort direction.").optional()
|
|
9739
9777
|
}),
|
|
9740
9778
|
outputSchema: publicSearchOutputSchema,
|
|
9741
9779
|
execute: async ({
|
|
@@ -9792,7 +9830,7 @@ function createSlackPublicSearchTool(actionToken) {
|
|
|
9792
9830
|
}
|
|
9793
9831
|
|
|
9794
9832
|
// src/chat/slack/tools/message-add-reaction.ts
|
|
9795
|
-
import { z as
|
|
9833
|
+
import { z as z38 } from "zod";
|
|
9796
9834
|
|
|
9797
9835
|
// src/chat/tools/idempotency.ts
|
|
9798
9836
|
function stableSerialize(value) {
|
|
@@ -9822,8 +9860,8 @@ function createSlackMessageAddReactionTool(context, state) {
|
|
|
9822
9860
|
readOnlyHint: false
|
|
9823
9861
|
},
|
|
9824
9862
|
description: "Add an emoji reaction to the current inbound Slack message. Use when the user asks for a reaction on the current message without another target. Provide a Slack emoji alias name (for example `thumbsup`, `white_check_mark`, or `thumbsup::skin-tone-6`), not a unicode emoji glyph. The target message is injected by runtime context; do not use this for arbitrary historical messages.",
|
|
9825
|
-
inputSchema:
|
|
9826
|
-
emoji:
|
|
9863
|
+
inputSchema: z38.object({
|
|
9864
|
+
emoji: z38.string().min(1).max(64).describe(
|
|
9827
9865
|
"Slack emoji alias name to react with (for example `thumbsup`, `white_check_mark`, or `thumbsup::skin-tone-6`). Optional surrounding colons are allowed."
|
|
9828
9866
|
)
|
|
9829
9867
|
}),
|
|
@@ -9872,14 +9910,14 @@ function createSlackMessageAddReactionTool(context, state) {
|
|
|
9872
9910
|
|
|
9873
9911
|
// src/chat/slack/tools/send-files.ts
|
|
9874
9912
|
import { createHash as createHash4 } from "crypto";
|
|
9875
|
-
import { z as
|
|
9913
|
+
import { z as z39 } from "zod";
|
|
9876
9914
|
var sendFilesResultSchema = juniorToolOutputSchema.extend({
|
|
9877
|
-
target:
|
|
9878
|
-
channel_id:
|
|
9879
|
-
deduplicated:
|
|
9880
|
-
file_count:
|
|
9881
|
-
file_ids:
|
|
9882
|
-
thread_ts:
|
|
9915
|
+
target: z39.string().min(1),
|
|
9916
|
+
channel_id: z39.string().min(1),
|
|
9917
|
+
deduplicated: z39.boolean().optional(),
|
|
9918
|
+
file_count: z39.number().int().nonnegative(),
|
|
9919
|
+
file_ids: z39.array(z39.string().min(1)).optional(),
|
|
9920
|
+
thread_ts: z39.string().min(1)
|
|
9883
9921
|
});
|
|
9884
9922
|
function normalizeFiles(files) {
|
|
9885
9923
|
return files.map((file) => ({
|
|
@@ -9909,8 +9947,8 @@ function createSendFilesTool(context, state, materializeFile) {
|
|
|
9909
9947
|
readOnlyHint: false
|
|
9910
9948
|
},
|
|
9911
9949
|
description: "Send one or more sandbox files into the active Slack conversation. Use when the user asks to attach, send, or share files here, in this conversation, or in this thread. Do not use for ordinary assistant text, top-level channel posts, other named channels, inline @mentions, or pinging mentioned users.",
|
|
9912
|
-
inputSchema:
|
|
9913
|
-
files:
|
|
9950
|
+
inputSchema: z39.object({
|
|
9951
|
+
files: z39.array(sandboxFileReferenceSchema).min(1).describe(
|
|
9914
9952
|
"One or more existing sandbox files. Objects returned by imageGenerate or webFetch can be passed unchanged."
|
|
9915
9953
|
)
|
|
9916
9954
|
}),
|
|
@@ -10342,7 +10380,7 @@ function storedCanvasUrl(state, canvasId) {
|
|
|
10342
10380
|
}
|
|
10343
10381
|
|
|
10344
10382
|
// src/chat/slack/tools/canvas/create.ts
|
|
10345
|
-
import { z as
|
|
10383
|
+
import { z as z40 } from "zod";
|
|
10346
10384
|
function createSlackCanvasCreateTool(context, state) {
|
|
10347
10385
|
return zodTool({
|
|
10348
10386
|
annotations: {
|
|
@@ -10352,9 +10390,9 @@ function createSlackCanvasCreateTool(context, state) {
|
|
|
10352
10390
|
readOnlyHint: false
|
|
10353
10391
|
},
|
|
10354
10392
|
description: "Create a Slack canvas for long-form output in the active assistant context channel. Use when the answer is better as a reusable document than a thread reply: long-form research, timelines, bios/profiles, structured notes, plans, comparisons, or anything likely to exceed one compact Slack reply. After creating it, reply with one or two short sentences plus the canvas link; do not recap the canvas contents. Do not use for short answers that fit cleanly in one normal thread reply.",
|
|
10355
|
-
inputSchema:
|
|
10356
|
-
title:
|
|
10357
|
-
markdown:
|
|
10393
|
+
inputSchema: z40.object({
|
|
10394
|
+
title: z40.string().min(1).max(160).describe("Canvas title."),
|
|
10395
|
+
markdown: z40.string().min(1).describe("Canvas markdown body content.")
|
|
10358
10396
|
}),
|
|
10359
10397
|
outputSchema: juniorToolOutputSchema,
|
|
10360
10398
|
execute: async ({ title, markdown }) => {
|
|
@@ -10410,26 +10448,26 @@ function createSlackCanvasCreateTool(context, state) {
|
|
|
10410
10448
|
}
|
|
10411
10449
|
|
|
10412
10450
|
// src/chat/slack/tools/canvas/edit.ts
|
|
10413
|
-
import { z as
|
|
10451
|
+
import { z as z41 } from "zod";
|
|
10414
10452
|
function prepareCanvasEditArguments(input) {
|
|
10415
10453
|
return prepareTextReplacementArguments(input);
|
|
10416
10454
|
}
|
|
10417
|
-
var editReplacementSchema2 =
|
|
10418
|
-
oldText:
|
|
10455
|
+
var editReplacementSchema2 = z41.object({
|
|
10456
|
+
oldText: z41.string().min(1).describe(
|
|
10419
10457
|
"Exact Canvas markdown to replace. It must be unique in the current Canvas body and must not overlap another edit."
|
|
10420
10458
|
),
|
|
10421
|
-
newText:
|
|
10459
|
+
newText: z41.string().describe("Replacement Canvas markdown for this edit.")
|
|
10422
10460
|
});
|
|
10423
10461
|
var slackCanvasEditOutputSchema = juniorToolOutputSchema.extend({
|
|
10424
|
-
canvas_id:
|
|
10425
|
-
title:
|
|
10426
|
-
permalink:
|
|
10427
|
-
diff:
|
|
10428
|
-
first_changed_line:
|
|
10429
|
-
replacements:
|
|
10430
|
-
normalized_heading_count:
|
|
10431
|
-
summary:
|
|
10432
|
-
deduplicated:
|
|
10462
|
+
canvas_id: z41.string().optional(),
|
|
10463
|
+
title: z41.string().optional(),
|
|
10464
|
+
permalink: z41.string().optional(),
|
|
10465
|
+
diff: z41.string().optional(),
|
|
10466
|
+
first_changed_line: z41.number().int().positive().optional(),
|
|
10467
|
+
replacements: z41.number().int().nonnegative().optional(),
|
|
10468
|
+
normalized_heading_count: z41.number().int().nonnegative().optional(),
|
|
10469
|
+
summary: z41.string().optional(),
|
|
10470
|
+
deduplicated: z41.boolean().optional()
|
|
10433
10471
|
}).strict();
|
|
10434
10472
|
function createSlackCanvasEditTool(state) {
|
|
10435
10473
|
return zodTool({
|
|
@@ -10442,9 +10480,9 @@ function createSlackCanvasEditTool(state) {
|
|
|
10442
10480
|
description: "Edit one Slack canvas with exact markdown replacements. Use for precise changes to existing Canvas content; prefer this over slackCanvasWrite for targeted changes. Each oldText must match exactly, be unique, and not overlap another edit. Returns a diff. Multiple changes to the same canvas: use one edits[] call.",
|
|
10443
10481
|
prepareArguments: prepareCanvasEditArguments,
|
|
10444
10482
|
executionMode: "sequential",
|
|
10445
|
-
inputSchema:
|
|
10446
|
-
canvas:
|
|
10447
|
-
edits:
|
|
10483
|
+
inputSchema: z41.object({
|
|
10484
|
+
canvas: z41.string().min(1).describe("Canvas/file ID (e.g. `F0ABCDEF`) or Slack canvas/docs URL."),
|
|
10485
|
+
edits: z41.array(editReplacementSchema2).min(1).describe(
|
|
10448
10486
|
"Exact replacements matched against the current Canvas body, not incrementally."
|
|
10449
10487
|
)
|
|
10450
10488
|
}),
|
|
@@ -10501,18 +10539,18 @@ function createSlackCanvasEditTool(state) {
|
|
|
10501
10539
|
}
|
|
10502
10540
|
|
|
10503
10541
|
// src/chat/slack/tools/canvas/read.ts
|
|
10504
|
-
import { z as
|
|
10542
|
+
import { z as z42 } from "zod";
|
|
10505
10543
|
var slackCanvasReadOutputSchema = juniorToolOutputSchema.extend({
|
|
10506
|
-
canvas_id:
|
|
10507
|
-
title:
|
|
10508
|
-
permalink:
|
|
10509
|
-
mimetype:
|
|
10510
|
-
filetype:
|
|
10511
|
-
original_byte_length:
|
|
10512
|
-
content:
|
|
10513
|
-
start_line:
|
|
10514
|
-
end_line:
|
|
10515
|
-
total_lines:
|
|
10544
|
+
canvas_id: z42.string().optional(),
|
|
10545
|
+
title: z42.string().optional(),
|
|
10546
|
+
permalink: z42.string().optional(),
|
|
10547
|
+
mimetype: z42.string().optional(),
|
|
10548
|
+
filetype: z42.string().optional(),
|
|
10549
|
+
original_byte_length: z42.number().int().nonnegative().optional(),
|
|
10550
|
+
content: z42.string().optional(),
|
|
10551
|
+
start_line: z42.number().int().positive().optional(),
|
|
10552
|
+
end_line: z42.number().int().nonnegative().optional(),
|
|
10553
|
+
total_lines: z42.number().int().nonnegative().optional()
|
|
10516
10554
|
}).strict();
|
|
10517
10555
|
function createSlackCanvasReadTool() {
|
|
10518
10556
|
return zodTool({
|
|
@@ -10523,12 +10561,12 @@ function createSlackCanvasReadTool() {
|
|
|
10523
10561
|
openWorldHint: true,
|
|
10524
10562
|
readOnlyHint: true
|
|
10525
10563
|
},
|
|
10526
|
-
inputSchema:
|
|
10527
|
-
canvas:
|
|
10564
|
+
inputSchema: z42.object({
|
|
10565
|
+
canvas: z42.string().min(1).describe(
|
|
10528
10566
|
"Canvas/file ID (e.g. `F0ABCDEF`) or Slack canvas/docs URL (e.g. `https://team.slack.com/docs/T.../F...`)."
|
|
10529
10567
|
),
|
|
10530
|
-
offset:
|
|
10531
|
-
limit:
|
|
10568
|
+
offset: z42.coerce.number().int().min(1).describe("1-indexed line number to start reading from.").optional(),
|
|
10569
|
+
limit: z42.coerce.number().int().min(1).describe("Maximum number of lines to read. Defaults to 1000.").optional()
|
|
10532
10570
|
}),
|
|
10533
10571
|
outputSchema: slackCanvasReadOutputSchema,
|
|
10534
10572
|
execute: async ({ canvas, offset, limit }) => {
|
|
@@ -10564,7 +10602,7 @@ function createSlackCanvasReadTool() {
|
|
|
10564
10602
|
}
|
|
10565
10603
|
|
|
10566
10604
|
// src/chat/slack/tools/canvas/write.ts
|
|
10567
|
-
import { z as
|
|
10605
|
+
import { z as z43 } from "zod";
|
|
10568
10606
|
function createSlackCanvasWriteTool(state) {
|
|
10569
10607
|
return zodTool({
|
|
10570
10608
|
annotations: {
|
|
@@ -10575,9 +10613,9 @@ function createSlackCanvasWriteTool(state) {
|
|
|
10575
10613
|
},
|
|
10576
10614
|
description: "Write UTF-8 markdown content to a Slack canvas. Use for deliberate full-Canvas replacement after validation; use slackCanvasEdit for targeted changes to existing canvas content.",
|
|
10577
10615
|
executionMode: "sequential",
|
|
10578
|
-
inputSchema:
|
|
10579
|
-
canvas:
|
|
10580
|
-
content:
|
|
10616
|
+
inputSchema: z43.object({
|
|
10617
|
+
canvas: z43.string().min(1).describe("Canvas/file ID (e.g. `F0ABCDEF`) or Slack canvas/docs URL."),
|
|
10618
|
+
content: z43.string().describe("UTF-8 markdown content to write.")
|
|
10581
10619
|
}),
|
|
10582
10620
|
outputSchema: juniorToolOutputSchema,
|
|
10583
10621
|
execute: async ({ canvas, content }) => {
|
|
@@ -10792,12 +10830,12 @@ async function updateListItem(input) {
|
|
|
10792
10830
|
}
|
|
10793
10831
|
|
|
10794
10832
|
// src/chat/slack/id-param.ts
|
|
10795
|
-
import { z as
|
|
10833
|
+
import { z as z44 } from "zod";
|
|
10796
10834
|
function slackChannelIdParam(description) {
|
|
10797
|
-
return
|
|
10835
|
+
return z44.string().min(1).describe(description);
|
|
10798
10836
|
}
|
|
10799
10837
|
function slackUserIdParam(description) {
|
|
10800
|
-
return
|
|
10838
|
+
return z44.string().min(1).describe(description);
|
|
10801
10839
|
}
|
|
10802
10840
|
function parseRequiredSlackChannelIdParam(field, value) {
|
|
10803
10841
|
const channelId = parseSlackChannelId(value);
|
|
@@ -10821,7 +10859,7 @@ function parseRequiredSlackUserIdParam(field, value) {
|
|
|
10821
10859
|
}
|
|
10822
10860
|
|
|
10823
10861
|
// src/chat/slack/tools/list/add-items.ts
|
|
10824
|
-
import { z as
|
|
10862
|
+
import { z as z45 } from "zod";
|
|
10825
10863
|
function createSlackListAddItemsTool(state) {
|
|
10826
10864
|
return zodTool({
|
|
10827
10865
|
annotations: {
|
|
@@ -10831,12 +10869,12 @@ function createSlackListAddItemsTool(state) {
|
|
|
10831
10869
|
readOnlyHint: false
|
|
10832
10870
|
},
|
|
10833
10871
|
description: "Add tasks to the active Slack list tracked in artifact context. Use when the user wants actionable items recorded in the current thread list. Do not use when no list exists and list creation was not requested.",
|
|
10834
|
-
inputSchema:
|
|
10835
|
-
items:
|
|
10872
|
+
inputSchema: z45.object({
|
|
10873
|
+
items: z45.array(z45.string().min(1)).min(1).max(25).describe("List item titles to create."),
|
|
10836
10874
|
assignee_user_id: slackUserIdParam(
|
|
10837
10875
|
"Optional Slack user ID assigned to all created items."
|
|
10838
10876
|
).optional(),
|
|
10839
|
-
due_date:
|
|
10877
|
+
due_date: z45.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Optional due date in YYYY-MM-DD format.").optional()
|
|
10840
10878
|
}),
|
|
10841
10879
|
outputSchema: juniorToolOutputSchema,
|
|
10842
10880
|
execute: async ({ items, assignee_user_id, due_date }) => {
|
|
@@ -10884,7 +10922,7 @@ function createSlackListAddItemsTool(state) {
|
|
|
10884
10922
|
}
|
|
10885
10923
|
|
|
10886
10924
|
// src/chat/slack/tools/list/create.ts
|
|
10887
|
-
import { z as
|
|
10925
|
+
import { z as z46 } from "zod";
|
|
10888
10926
|
function createSlackListCreateTool(state) {
|
|
10889
10927
|
return zodTool({
|
|
10890
10928
|
annotations: {
|
|
@@ -10894,8 +10932,8 @@ function createSlackListCreateTool(state) {
|
|
|
10894
10932
|
readOnlyHint: false
|
|
10895
10933
|
},
|
|
10896
10934
|
description: "Create a Slack todo list for action tracking. Use when the user needs structured tasks with ownership/completion tracking. Do not use for one-off notes without task management needs.",
|
|
10897
|
-
inputSchema:
|
|
10898
|
-
name:
|
|
10935
|
+
inputSchema: z46.object({
|
|
10936
|
+
name: z46.string().min(1).max(160).describe("Name for the new Slack list.")
|
|
10899
10937
|
}),
|
|
10900
10938
|
outputSchema: juniorToolOutputSchema,
|
|
10901
10939
|
execute: async ({ name }) => {
|
|
@@ -10925,7 +10963,7 @@ function createSlackListCreateTool(state) {
|
|
|
10925
10963
|
}
|
|
10926
10964
|
|
|
10927
10965
|
// src/chat/slack/tools/list/get-items.ts
|
|
10928
|
-
import { z as
|
|
10966
|
+
import { z as z47 } from "zod";
|
|
10929
10967
|
function createSlackListGetItemsTool(state) {
|
|
10930
10968
|
return zodTool({
|
|
10931
10969
|
description: "Read items from the active Slack list tracked in artifact context. Use when the user asks for task status, open items, or list contents. Do not use when list state is already known from the immediately prior result.",
|
|
@@ -10935,8 +10973,8 @@ function createSlackListGetItemsTool(state) {
|
|
|
10935
10973
|
openWorldHint: true,
|
|
10936
10974
|
readOnlyHint: true
|
|
10937
10975
|
},
|
|
10938
|
-
inputSchema:
|
|
10939
|
-
limit:
|
|
10976
|
+
inputSchema: z47.object({
|
|
10977
|
+
limit: z47.coerce.number().int().min(1).max(200).describe("Maximum number of list items to return.").optional()
|
|
10940
10978
|
}),
|
|
10941
10979
|
outputSchema: juniorToolOutputSchema,
|
|
10942
10980
|
execute: async ({ limit }) => {
|
|
@@ -10955,21 +10993,21 @@ function createSlackListGetItemsTool(state) {
|
|
|
10955
10993
|
}
|
|
10956
10994
|
|
|
10957
10995
|
// src/chat/slack/tools/list/update-item.ts
|
|
10958
|
-
import { z as
|
|
10959
|
-
var booleanInput3 = (description) =>
|
|
10996
|
+
import { z as z48 } from "zod";
|
|
10997
|
+
var booleanInput3 = (description) => z48.preprocess(
|
|
10960
10998
|
(value) => value === "true" ? true : value === "false" ? false : value,
|
|
10961
|
-
|
|
10999
|
+
z48.boolean()
|
|
10962
11000
|
).describe(description);
|
|
10963
|
-
var updateListItemInputSchema =
|
|
10964
|
-
|
|
10965
|
-
item_id:
|
|
11001
|
+
var updateListItemInputSchema = z48.union([
|
|
11002
|
+
z48.object({
|
|
11003
|
+
item_id: z48.string().min(1).describe("ID of the Slack list item to update."),
|
|
10966
11004
|
completed: booleanInput3("Optional completion status update."),
|
|
10967
|
-
title:
|
|
11005
|
+
title: z48.string().min(1).describe("Optional new item title.").optional()
|
|
10968
11006
|
}),
|
|
10969
|
-
|
|
10970
|
-
item_id:
|
|
11007
|
+
z48.object({
|
|
11008
|
+
item_id: z48.string().min(1).describe("ID of the Slack list item to update."),
|
|
10971
11009
|
completed: booleanInput3("Optional completion status update.").optional(),
|
|
10972
|
-
title:
|
|
11010
|
+
title: z48.string().min(1).describe("Optional new item title.")
|
|
10973
11011
|
})
|
|
10974
11012
|
]);
|
|
10975
11013
|
function createSlackListUpdateItemTool(state) {
|
|
@@ -11045,7 +11083,7 @@ async function checkSlackChannelReadAccess(args) {
|
|
|
11045
11083
|
}
|
|
11046
11084
|
|
|
11047
11085
|
// src/chat/slack/tools/thread-read.ts
|
|
11048
|
-
import { z as
|
|
11086
|
+
import { z as z49 } from "zod";
|
|
11049
11087
|
|
|
11050
11088
|
// src/chat/slack/tools/slack-message-url.ts
|
|
11051
11089
|
var SLACK_HOST_PATTERN = /^[a-z0-9-]+\.slack(?:-gov)?\.com$/;
|
|
@@ -11223,8 +11261,8 @@ function createSlackThreadReadTool(context, deps = {}) {
|
|
|
11223
11261
|
openWorldHint: true,
|
|
11224
11262
|
readOnlyHint: true
|
|
11225
11263
|
},
|
|
11226
|
-
inputSchema:
|
|
11227
|
-
url:
|
|
11264
|
+
inputSchema: z49.object({
|
|
11265
|
+
url: z49.string().min(1).describe(
|
|
11228
11266
|
"Slack message archive URL, e.g. https://workspace.slack.com/archives/C123/p1700000000123456"
|
|
11229
11267
|
).optional(),
|
|
11230
11268
|
channel_id: slackChannelIdParam(
|
|
@@ -11233,8 +11271,8 @@ function createSlackThreadReadTool(context, deps = {}) {
|
|
|
11233
11271
|
ts: slackTimestampParam(
|
|
11234
11272
|
"Slack message timestamp (e.g. 1700000000.123456). May be the thread root or any message in the thread."
|
|
11235
11273
|
).optional(),
|
|
11236
|
-
limit:
|
|
11237
|
-
max_pages:
|
|
11274
|
+
limit: z49.coerce.number().int().min(1).max(1e3).describe("Maximum number of thread messages to fetch.").optional(),
|
|
11275
|
+
max_pages: z49.coerce.number().int().min(1).max(10).describe("Maximum number of Slack API pages to traverse.").optional()
|
|
11238
11276
|
}),
|
|
11239
11277
|
outputSchema: juniorToolOutputSchema,
|
|
11240
11278
|
execute: async ({ url, channel_id, ts, limit, max_pages }) => {
|
|
@@ -11462,7 +11500,7 @@ async function searchSlackUsers(options) {
|
|
|
11462
11500
|
}
|
|
11463
11501
|
|
|
11464
11502
|
// src/chat/slack/tools/user-lookup.ts
|
|
11465
|
-
import { z as
|
|
11503
|
+
import { z as z50 } from "zod";
|
|
11466
11504
|
function explicitUserLookupError(error) {
|
|
11467
11505
|
if (error.apiError === "user_not_found") {
|
|
11468
11506
|
return "No Slack user found for the supplied user ID.";
|
|
@@ -11490,11 +11528,11 @@ function createSlackUserLookupTool() {
|
|
|
11490
11528
|
openWorldHint: true,
|
|
11491
11529
|
readOnlyHint: true
|
|
11492
11530
|
},
|
|
11493
|
-
inputSchema:
|
|
11494
|
-
mode:
|
|
11531
|
+
inputSchema: z50.object({
|
|
11532
|
+
mode: z50.enum(["user_id", "email", "query"]).describe(
|
|
11495
11533
|
"Lookup method: user_id for Slack IDs, email for email addresses, or query for name searches."
|
|
11496
11534
|
),
|
|
11497
|
-
value:
|
|
11535
|
+
value: z50.string().trim().min(2).describe(
|
|
11498
11536
|
"The Slack user ID, email address, or name to look up, interpreted according to mode."
|
|
11499
11537
|
)
|
|
11500
11538
|
}).strict(),
|
|
@@ -11552,18 +11590,18 @@ function createSlackUserLookupTool() {
|
|
|
11552
11590
|
}
|
|
11553
11591
|
|
|
11554
11592
|
// src/chat/tools/system-time.ts
|
|
11555
|
-
import { z as
|
|
11556
|
-
var systemTimeInputSchema =
|
|
11557
|
-
timezone:
|
|
11593
|
+
import { z as z51 } from "zod";
|
|
11594
|
+
var systemTimeInputSchema = z51.object({
|
|
11595
|
+
timezone: z51.string().trim().min(1).optional().describe(
|
|
11558
11596
|
"Optional IANA timezone, for example America/Los_Angeles. When set, iso_local and timezone_offset_minutes are for that zone."
|
|
11559
11597
|
)
|
|
11560
11598
|
});
|
|
11561
11599
|
var systemTimeOutputSchema = juniorToolOutputSchema.extend({
|
|
11562
|
-
unix_ms:
|
|
11563
|
-
iso_utc:
|
|
11564
|
-
iso_local:
|
|
11565
|
-
timezone:
|
|
11566
|
-
timezone_offset_minutes:
|
|
11600
|
+
unix_ms: z51.number(),
|
|
11601
|
+
iso_utc: z51.string(),
|
|
11602
|
+
iso_local: z51.string(),
|
|
11603
|
+
timezone: z51.string().nullable(),
|
|
11604
|
+
timezone_offset_minutes: z51.number()
|
|
11567
11605
|
});
|
|
11568
11606
|
function createSystemTimeTool() {
|
|
11569
11607
|
return zodTool({
|
|
@@ -11643,7 +11681,7 @@ function getTimeZoneOffsetMinutes(timestampMs, timezone) {
|
|
|
11643
11681
|
}
|
|
11644
11682
|
|
|
11645
11683
|
// src/chat/tools/query-conversation-events.ts
|
|
11646
|
-
import { z as
|
|
11684
|
+
import { z as z52 } from "zod";
|
|
11647
11685
|
var DEFAULT_LIMIT3 = 25;
|
|
11648
11686
|
var MAX_LIMIT = 100;
|
|
11649
11687
|
var MAX_EVENT_DATA_BYTES = 4e3;
|
|
@@ -11654,28 +11692,28 @@ var CONVERSATION_EVENTS_TOOL_SOURCE = {
|
|
|
11654
11692
|
id: "conversation-events",
|
|
11655
11693
|
description: "Inspect Junior's durable conversation event log for debugging runtime behavior."
|
|
11656
11694
|
};
|
|
11657
|
-
var knownEventTypeSchema =
|
|
11658
|
-
var projectedEventSchema =
|
|
11659
|
-
seq:
|
|
11660
|
-
history_version:
|
|
11695
|
+
var knownEventTypeSchema = z52.enum(KNOWN_CONVERSATION_EVENT_TYPES);
|
|
11696
|
+
var projectedEventSchema = z52.object({
|
|
11697
|
+
seq: z52.number().int().nonnegative().describe("Stable event position; use it for pagination bounds."),
|
|
11698
|
+
history_version: z52.number().int().nonnegative().describe(
|
|
11661
11699
|
"Model-history generation. It increments when handoff or compaction replaces active model context."
|
|
11662
11700
|
),
|
|
11663
|
-
created_at:
|
|
11664
|
-
idempotency_key:
|
|
11665
|
-
data:
|
|
11701
|
+
created_at: z52.iso.datetime().describe("When the event was recorded."),
|
|
11702
|
+
idempotency_key: z52.string().min(1).optional().describe("Retry-stable event identity, when one was assigned."),
|
|
11703
|
+
data: z52.record(z52.string(), z52.unknown()).describe(
|
|
11666
11704
|
"Event data. Oversized payloads are replaced by identifying fields, payload_omitted, and payload_json_bytes."
|
|
11667
11705
|
)
|
|
11668
11706
|
}).strict();
|
|
11669
11707
|
var queryConversationEventsOutputSchema = juniorToolOutputSchema.extend({
|
|
11670
|
-
conversation_id:
|
|
11671
|
-
events:
|
|
11672
|
-
has_older:
|
|
11708
|
+
conversation_id: z52.string().min(1),
|
|
11709
|
+
events: z52.array(projectedEventSchema),
|
|
11710
|
+
has_older: z52.boolean().describe(
|
|
11673
11711
|
"Whether matching events exist before this page; request them with before_seq set to the first returned seq."
|
|
11674
11712
|
),
|
|
11675
|
-
has_newer:
|
|
11713
|
+
has_newer: z52.boolean().describe(
|
|
11676
11714
|
"Whether matching events exist after this page; request them with after_seq set to the last returned seq."
|
|
11677
11715
|
),
|
|
11678
|
-
omitted_event_count:
|
|
11716
|
+
omitted_event_count: z52.number().int().nonnegative().optional().describe(
|
|
11679
11717
|
"Fetched events omitted to keep this response bounded. Continue with the pagination cursor for the omitted direction."
|
|
11680
11718
|
)
|
|
11681
11719
|
});
|
|
@@ -11690,20 +11728,20 @@ function createQueryConversationEventsTool(context) {
|
|
|
11690
11728
|
openWorldHint: false,
|
|
11691
11729
|
readOnlyHint: true
|
|
11692
11730
|
},
|
|
11693
|
-
inputSchema:
|
|
11694
|
-
conversation_id:
|
|
11731
|
+
inputSchema: z52.object({
|
|
11732
|
+
conversation_id: z52.string().trim().min(1).describe(
|
|
11695
11733
|
"Conversation ID to inspect, such as slack:{channelId}:{threadTs} or a child conversation id."
|
|
11696
11734
|
),
|
|
11697
|
-
after_seq:
|
|
11735
|
+
after_seq: z52.number().int().nonnegative().nullable().describe(
|
|
11698
11736
|
"Exclusive lower bound on event seq. When set, returns the next newer page in ascending order."
|
|
11699
11737
|
).optional(),
|
|
11700
|
-
before_seq:
|
|
11738
|
+
before_seq: z52.number().int().nonnegative().nullable().describe(
|
|
11701
11739
|
"Exclusive upper bound on event seq. Combine with defaults or after_seq to page older or bounded ranges."
|
|
11702
11740
|
).optional(),
|
|
11703
|
-
limit:
|
|
11741
|
+
limit: z52.number().int().min(1).max(MAX_LIMIT).nullable().describe(
|
|
11704
11742
|
`Maximum events to return. Defaults to ${DEFAULT_LIMIT3}; max ${MAX_LIMIT}.`
|
|
11705
11743
|
).optional(),
|
|
11706
|
-
types:
|
|
11744
|
+
types: z52.array(knownEventTypeSchema).min(1).nullable().describe(
|
|
11707
11745
|
"Optional event-type filter. Omit to return every durable event type."
|
|
11708
11746
|
).optional()
|
|
11709
11747
|
}).strict(),
|
|
@@ -11951,10 +11989,10 @@ function stripReplacementHistoryField(value) {
|
|
|
11951
11989
|
}
|
|
11952
11990
|
|
|
11953
11991
|
// src/chat/tools/handoff/tool.ts
|
|
11954
|
-
import { z as
|
|
11992
|
+
import { z as z53 } from "zod";
|
|
11955
11993
|
var HANDOFF_TOOL_NAME = "handoff";
|
|
11956
11994
|
function createHandoffTool(handoff) {
|
|
11957
|
-
const profileSchema =
|
|
11995
|
+
const profileSchema = z53.enum(handoff.profiles);
|
|
11958
11996
|
const handoffResultSchema = juniorToolOutputSchema.extend({
|
|
11959
11997
|
model_profile: modelProfileSchema
|
|
11960
11998
|
});
|
|
@@ -11968,7 +12006,7 @@ function createHandoffTool(handoff) {
|
|
|
11968
12006
|
},
|
|
11969
12007
|
description: `Switch to another execution profile and continue the same task. Profiles: ${profileNames}. Call this as the only tool.`,
|
|
11970
12008
|
executionMode: "sequential",
|
|
11971
|
-
inputSchema:
|
|
12009
|
+
inputSchema: z53.object({
|
|
11972
12010
|
profile: profileSchema.describe("Target execution profile")
|
|
11973
12011
|
}).strict(),
|
|
11974
12012
|
outputSchema: handoffResultSchema,
|
|
@@ -11989,7 +12027,7 @@ function createHandoffTool(handoff) {
|
|
|
11989
12027
|
}
|
|
11990
12028
|
|
|
11991
12029
|
// src/chat/tools/web/fetch-tool.ts
|
|
11992
|
-
import { z as
|
|
12030
|
+
import { z as z54 } from "zod";
|
|
11993
12031
|
|
|
11994
12032
|
// src/chat/tools/web/constants.ts
|
|
11995
12033
|
var USER_AGENT = "junior-bot/0.1";
|
|
@@ -12432,9 +12470,9 @@ function createWebFetchTool(hooks, options = {}) {
|
|
|
12432
12470
|
openWorldHint: true,
|
|
12433
12471
|
readOnlyHint: true
|
|
12434
12472
|
},
|
|
12435
|
-
inputSchema:
|
|
12436
|
-
url:
|
|
12437
|
-
max_chars:
|
|
12473
|
+
inputSchema: z54.object({
|
|
12474
|
+
url: z54.string().min(1).describe("HTTP(S) URL to fetch."),
|
|
12475
|
+
max_chars: z54.coerce.number().int().min(500).max(MAX_FETCH_CHARS).describe("Optional maximum number of extracted characters to return.").optional()
|
|
12438
12476
|
}),
|
|
12439
12477
|
outputSchema: juniorToolOutputSchema,
|
|
12440
12478
|
execute: async ({ url, max_chars }) => {
|
|
@@ -12479,7 +12517,7 @@ function createWebFetchTool(hooks, options = {}) {
|
|
|
12479
12517
|
}
|
|
12480
12518
|
|
|
12481
12519
|
// src/chat/tools/web/search.ts
|
|
12482
|
-
import { z as
|
|
12520
|
+
import { z as z55 } from "zod";
|
|
12483
12521
|
import { generateText } from "ai";
|
|
12484
12522
|
import { createGatewayProvider } from "@ai-sdk/gateway";
|
|
12485
12523
|
var SEARCH_TIMEOUT_MS = 6e4;
|
|
@@ -12521,9 +12559,9 @@ function createWebSearchTool(modelId, override) {
|
|
|
12521
12559
|
openWorldHint: true,
|
|
12522
12560
|
readOnlyHint: true
|
|
12523
12561
|
},
|
|
12524
|
-
inputSchema:
|
|
12525
|
-
query:
|
|
12526
|
-
max_results:
|
|
12562
|
+
inputSchema: z55.object({
|
|
12563
|
+
query: z55.string().min(1).max(500).describe("Search query."),
|
|
12564
|
+
max_results: z55.coerce.number().int().min(1).max(MAX_RESULTS2).describe("Max results to return.").optional()
|
|
12527
12565
|
}),
|
|
12528
12566
|
outputSchema: juniorToolOutputSchema,
|
|
12529
12567
|
execute: async ({ query, max_results }) => {
|
|
@@ -12532,7 +12570,10 @@ function createWebSearchTool(modelId, override) {
|
|
|
12532
12570
|
}
|
|
12533
12571
|
const maxResults = max_results ?? 3;
|
|
12534
12572
|
const controller = new AbortController();
|
|
12535
|
-
const
|
|
12573
|
+
const credential = await resolveGatewayCredential();
|
|
12574
|
+
const provider = createGatewayProvider(
|
|
12575
|
+
credential ? { apiKey: credential.token } : {}
|
|
12576
|
+
);
|
|
12536
12577
|
const response = await withTimeout(
|
|
12537
12578
|
generateText({
|
|
12538
12579
|
model: provider.chat(modelId),
|
|
@@ -12562,7 +12603,7 @@ function createWebSearchTool(modelId, override) {
|
|
|
12562
12603
|
}
|
|
12563
12604
|
|
|
12564
12605
|
// src/chat/tools/sandbox/write-file.ts
|
|
12565
|
-
import { z as
|
|
12606
|
+
import { z as z56 } from "zod";
|
|
12566
12607
|
function createWriteFileTool() {
|
|
12567
12608
|
return zodTool({
|
|
12568
12609
|
annotations: {
|
|
@@ -12573,9 +12614,9 @@ function createWriteFileTool() {
|
|
|
12573
12614
|
},
|
|
12574
12615
|
description: "Write UTF-8 content to a file in the sandbox workspace. Use for intentional file creation or deliberate full-file replacement after validation; use editFile instead for targeted changes to existing files. Do not use for exploratory analysis-only turns.",
|
|
12575
12616
|
executionMode: "sequential",
|
|
12576
|
-
inputSchema:
|
|
12577
|
-
path:
|
|
12578
|
-
content:
|
|
12617
|
+
inputSchema: z56.object({
|
|
12618
|
+
path: z56.string().min(1).describe("Path to write in the sandbox workspace."),
|
|
12619
|
+
content: z56.string().describe("UTF-8 file content to write.")
|
|
12579
12620
|
}),
|
|
12580
12621
|
outputSchema: juniorToolOutputSchema,
|
|
12581
12622
|
execute: async () => {
|
|
@@ -12674,6 +12715,9 @@ function createTools(availableSkills, hooks = {}, context, options = {}) {
|
|
|
12674
12715
|
if (context.handoff) {
|
|
12675
12716
|
tools.handoff = createHandoffTool(context.handoff);
|
|
12676
12717
|
}
|
|
12718
|
+
if (context.spawnAgent) {
|
|
12719
|
+
tools.spawnAgent = createSpawnAgentTool(context.spawnAgent);
|
|
12720
|
+
}
|
|
12677
12721
|
if (context.mcpToolManager) {
|
|
12678
12722
|
tools.searchMcpTools = createSearchMcpToolsTool(context.mcpToolManager);
|
|
12679
12723
|
tools.callMcpTool = createCallMcpToolTool(context.mcpToolManager);
|
|
@@ -12907,167 +12951,6 @@ function buildSandboxInput(toolName, params) {
|
|
|
12907
12951
|
// src/chat/tools/execution/tool-error-handler.ts
|
|
12908
12952
|
import { PluginToolInputError } from "@sentry/junior-plugin-api";
|
|
12909
12953
|
|
|
12910
|
-
// src/chat/services/plugin-auth-orchestration.ts
|
|
12911
|
-
var PluginAuthorizationPauseError = class extends AuthorizationPauseError {
|
|
12912
|
-
constructor(provider, providerDisplayName, disposition, requestText) {
|
|
12913
|
-
super("plugin", provider, providerDisplayName, disposition, requestText);
|
|
12914
|
-
}
|
|
12915
|
-
};
|
|
12916
|
-
var PluginCredentialFailureError = class extends Error {
|
|
12917
|
-
provider;
|
|
12918
|
-
constructor(provider, message) {
|
|
12919
|
-
super(message);
|
|
12920
|
-
this.name = "PluginCredentialFailureError";
|
|
12921
|
-
this.provider = provider;
|
|
12922
|
-
}
|
|
12923
|
-
};
|
|
12924
|
-
function pluginAuthRequiredSignal(details) {
|
|
12925
|
-
if (!details || typeof details !== "object") {
|
|
12926
|
-
return void 0;
|
|
12927
|
-
}
|
|
12928
|
-
const signal = details.auth_required;
|
|
12929
|
-
const parsedSignal = parseSandboxEgressAuthRequiredSignal(signal);
|
|
12930
|
-
if (!parsedSignal) {
|
|
12931
|
-
return void 0;
|
|
12932
|
-
}
|
|
12933
|
-
return {
|
|
12934
|
-
provider: parsedSignal.provider,
|
|
12935
|
-
grant: parsedSignal.grant,
|
|
12936
|
-
kind: parsedSignal.kind,
|
|
12937
|
-
...parsedSignal.message ? { message: parsedSignal.message } : {},
|
|
12938
|
-
...parsedSignal.authorization ? { authorization: parsedSignal.authorization } : {}
|
|
12939
|
-
};
|
|
12940
|
-
}
|
|
12941
|
-
function createPluginAuthOrchestration(input) {
|
|
12942
|
-
let pendingPause;
|
|
12943
|
-
const startAuthorizationPause = async (provider, options) => {
|
|
12944
|
-
if (pendingPause) {
|
|
12945
|
-
throw pendingPause;
|
|
12946
|
-
}
|
|
12947
|
-
if (!input.actorId || !pluginCatalogRuntime.getOAuthConfig(provider)) {
|
|
12948
|
-
throw new Error(`Cannot start plugin authorization for ${provider}`);
|
|
12949
|
-
}
|
|
12950
|
-
if (input.authorizationFlowMode === "disabled") {
|
|
12951
|
-
throw new AuthorizationFlowDisabledError("plugin", provider);
|
|
12952
|
-
}
|
|
12953
|
-
const recordPendingAuth = input.sessionId ? input.recordPendingAuth : void 0;
|
|
12954
|
-
if (input.sessionId && !recordPendingAuth) {
|
|
12955
|
-
throw new Error(
|
|
12956
|
-
`Missing pending auth recorder for plugin authorization pause "${provider}"`
|
|
12957
|
-
);
|
|
12958
|
-
}
|
|
12959
|
-
const providerLabel = formatProviderLabel(provider);
|
|
12960
|
-
const reusingPendingLink = input.sessionId ? canReusePendingAuthLink({
|
|
12961
|
-
pendingAuth: input.pendingAuth,
|
|
12962
|
-
kind: "plugin",
|
|
12963
|
-
provider,
|
|
12964
|
-
actorId: input.actorId,
|
|
12965
|
-
sessionId: input.sessionId,
|
|
12966
|
-
...options?.scope ? { scope: options.scope } : {}
|
|
12967
|
-
}) : false;
|
|
12968
|
-
if (!reusingPendingLink) {
|
|
12969
|
-
const oauthResult = await startOAuthFlow(provider, {
|
|
12970
|
-
actorId: input.actorId,
|
|
12971
|
-
channelId: input.channelId,
|
|
12972
|
-
destination: input.destination,
|
|
12973
|
-
source: input.source,
|
|
12974
|
-
threadTs: input.threadTs,
|
|
12975
|
-
...options?.scope ? { scope: options.scope } : {},
|
|
12976
|
-
resumeConversationId: input.conversationId,
|
|
12977
|
-
resumeSessionId: input.sessionId,
|
|
12978
|
-
authorization: input.authorization
|
|
12979
|
-
});
|
|
12980
|
-
if (!oauthResult.ok) {
|
|
12981
|
-
throw new Error(oauthResult.error);
|
|
12982
|
-
}
|
|
12983
|
-
if (!oauthResult.delivery) {
|
|
12984
|
-
throw new Error(
|
|
12985
|
-
`I need to connect your ${providerLabel} account first, but I wasn't able to send you a private authorization link. Please send me a direct message and try again.`
|
|
12986
|
-
);
|
|
12987
|
-
}
|
|
12988
|
-
}
|
|
12989
|
-
if (input.sessionId && recordPendingAuth) {
|
|
12990
|
-
const nextPendingAuth = {
|
|
12991
|
-
kind: "plugin",
|
|
12992
|
-
provider,
|
|
12993
|
-
actorId: input.actorId,
|
|
12994
|
-
...options?.scope ? { scope: options.scope } : {},
|
|
12995
|
-
sessionId: input.sessionId,
|
|
12996
|
-
linkSentAtMs: reusingPendingLink ? input.pendingAuth.linkSentAtMs : Date.now()
|
|
12997
|
-
};
|
|
12998
|
-
await recordPendingAuth(nextPendingAuth);
|
|
12999
|
-
await abandonReplacedPendingAuth({
|
|
13000
|
-
conversationId: input.conversationId,
|
|
13001
|
-
previousPendingAuth: input.pendingAuth,
|
|
13002
|
-
nextPendingAuth
|
|
13003
|
-
});
|
|
13004
|
-
}
|
|
13005
|
-
if (input.conversationId && input.sessionId) {
|
|
13006
|
-
await recordAuthorizationRequested({
|
|
13007
|
-
conversationId: input.conversationId,
|
|
13008
|
-
kind: "plugin",
|
|
13009
|
-
provider,
|
|
13010
|
-
actorId: input.actorId,
|
|
13011
|
-
authorizationId: authorizationId({
|
|
13012
|
-
kind: "plugin",
|
|
13013
|
-
provider,
|
|
13014
|
-
sessionId: input.sessionId
|
|
13015
|
-
}),
|
|
13016
|
-
delivery: reusingPendingLink ? "private_link_reused" : "private_link_sent"
|
|
13017
|
-
});
|
|
13018
|
-
}
|
|
13019
|
-
pendingPause = new PluginAuthorizationPauseError(
|
|
13020
|
-
provider,
|
|
13021
|
-
providerLabel,
|
|
13022
|
-
reusingPendingLink ? "link_already_sent" : "link_sent",
|
|
13023
|
-
input.userMessage
|
|
13024
|
-
);
|
|
13025
|
-
input.abortAgent();
|
|
13026
|
-
throw pendingPause;
|
|
13027
|
-
};
|
|
13028
|
-
return {
|
|
13029
|
-
maybeHandleAuthSignal: async (details) => {
|
|
13030
|
-
const signal = pluginAuthRequiredSignal(details);
|
|
13031
|
-
if (!signal) {
|
|
13032
|
-
return;
|
|
13033
|
-
}
|
|
13034
|
-
const { provider, authorization } = signal;
|
|
13035
|
-
if (signal.kind === "unavailable") {
|
|
13036
|
-
throw new PluginCredentialFailureError(
|
|
13037
|
-
provider,
|
|
13038
|
-
signal.message ?? `${formatProviderLabel(provider)} credentials are unavailable.`
|
|
13039
|
-
);
|
|
13040
|
-
}
|
|
13041
|
-
if (!authorization) {
|
|
13042
|
-
throw new PluginCredentialFailureError(
|
|
13043
|
-
provider,
|
|
13044
|
-
signal.message ?? `${formatProviderLabel(provider)} credentials are required but no OAuth flow is available for this provider.`
|
|
13045
|
-
);
|
|
13046
|
-
}
|
|
13047
|
-
if (!input.actorId || !input.userTokenStore) {
|
|
13048
|
-
if (input.authorizationFlowMode === "disabled") {
|
|
13049
|
-
throw new AuthorizationFlowDisabledError("plugin", provider);
|
|
13050
|
-
}
|
|
13051
|
-
throw new PluginCredentialFailureError(
|
|
13052
|
-
provider,
|
|
13053
|
-
signal.message ?? `${formatProviderLabel(provider)} credentials are required. Please connect your ${formatProviderLabel(provider)} account and try again.`
|
|
13054
|
-
);
|
|
13055
|
-
}
|
|
13056
|
-
if (!pluginCatalogRuntime.getOAuthConfig(authorization.provider)) {
|
|
13057
|
-
throw new PluginCredentialFailureError(
|
|
13058
|
-
provider,
|
|
13059
|
-
signal.message ?? `${formatProviderLabel(provider)} credentials are required but the provider is not configured for OAuth.`
|
|
13060
|
-
);
|
|
13061
|
-
}
|
|
13062
|
-
await startAuthorizationPause(
|
|
13063
|
-
authorization.provider,
|
|
13064
|
-
authorization.scope ? { scope: authorization.scope } : void 0
|
|
13065
|
-
);
|
|
13066
|
-
},
|
|
13067
|
-
getPendingPause: () => pendingPause
|
|
13068
|
-
};
|
|
13069
|
-
}
|
|
13070
|
-
|
|
13071
12954
|
// src/chat/tool-support/action-review.ts
|
|
13072
12955
|
var ACTION_CONFIRMATION_INSTRUCTIONS = [
|
|
13073
12956
|
"The action was not executed because explicit user confirmation is required.",
|
|
@@ -13443,7 +13326,7 @@ function handleToolExecutionError(error, toolName, toolCallId, shouldTrace, conv
|
|
|
13443
13326
|
}
|
|
13444
13327
|
|
|
13445
13328
|
// src/chat/tools/execute-tool.ts
|
|
13446
|
-
import { z as
|
|
13329
|
+
import { z as z57 } from "zod";
|
|
13447
13330
|
var EXECUTE_TOOL_NAME = "executeTool";
|
|
13448
13331
|
function createExecuteToolTool() {
|
|
13449
13332
|
return zodTool({
|
|
@@ -13455,11 +13338,11 @@ function createExecuteToolTool() {
|
|
|
13455
13338
|
},
|
|
13456
13339
|
description: "Execute any catalog tool by exact tool_name from searchTools or a tool-result execution hint. Put tool-specific parameters inside arguments.",
|
|
13457
13340
|
executionMode: "sequential",
|
|
13458
|
-
inputSchema:
|
|
13459
|
-
tool_name:
|
|
13341
|
+
inputSchema: z57.object({
|
|
13342
|
+
tool_name: z57.string().min(1).describe(
|
|
13460
13343
|
"Exact catalog tool_name returned by searchTools or a tool-result execution hint."
|
|
13461
13344
|
),
|
|
13462
|
-
arguments:
|
|
13345
|
+
arguments: z57.record(z57.string(), z57.unknown()).describe(
|
|
13463
13346
|
'Arguments matching the selected catalog tool schema, for example { "query": "..." }.'
|
|
13464
13347
|
).optional()
|
|
13465
13348
|
}).strict(),
|
|
@@ -13499,34 +13382,34 @@ function planToolExposure(tools) {
|
|
|
13499
13382
|
}
|
|
13500
13383
|
|
|
13501
13384
|
// src/chat/tools/search-tools.ts
|
|
13502
|
-
import { z as
|
|
13385
|
+
import { z as z58 } from "zod";
|
|
13503
13386
|
var SEARCH_TOOLS_NAME = "searchTools";
|
|
13504
13387
|
var DEFAULT_MAX_RESULTS2 = 5;
|
|
13505
13388
|
var MAX_RESULTS3 = 20;
|
|
13506
13389
|
var MODEL_VISIBLE_DESCRIPTION_CAP = 180;
|
|
13507
|
-
var searchToolsSourceSchema =
|
|
13508
|
-
id:
|
|
13509
|
-
description:
|
|
13390
|
+
var searchToolsSourceSchema = z58.object({
|
|
13391
|
+
id: z58.string(),
|
|
13392
|
+
description: z58.string()
|
|
13510
13393
|
}).strict();
|
|
13511
|
-
var searchToolsToolSchema =
|
|
13512
|
-
tool_name:
|
|
13513
|
-
description:
|
|
13514
|
-
exposure:
|
|
13515
|
-
source:
|
|
13516
|
-
input_schema:
|
|
13517
|
-
call_notes:
|
|
13518
|
-
annotations:
|
|
13394
|
+
var searchToolsToolSchema = z58.object({
|
|
13395
|
+
tool_name: z58.string(),
|
|
13396
|
+
description: z58.string(),
|
|
13397
|
+
exposure: z58.enum(["direct", "deferred", "modelOnly", "hidden"]),
|
|
13398
|
+
source: z58.string().optional(),
|
|
13399
|
+
input_schema: z58.unknown(),
|
|
13400
|
+
call_notes: z58.array(z58.string()),
|
|
13401
|
+
annotations: z58.record(z58.string(), z58.unknown())
|
|
13519
13402
|
}).strict();
|
|
13520
13403
|
var searchToolsOutputSchema = juniorToolOutputSchema.extend({
|
|
13521
|
-
query:
|
|
13522
|
-
source:
|
|
13523
|
-
sources:
|
|
13524
|
-
total_catalog_tools:
|
|
13525
|
-
total_eligible_tools:
|
|
13526
|
-
total_matches:
|
|
13527
|
-
returned_tools:
|
|
13528
|
-
execution_tool:
|
|
13529
|
-
tools:
|
|
13404
|
+
query: z58.string().nullable(),
|
|
13405
|
+
source: z58.string().nullable(),
|
|
13406
|
+
sources: z58.array(searchToolsSourceSchema),
|
|
13407
|
+
total_catalog_tools: z58.number().int().nonnegative(),
|
|
13408
|
+
total_eligible_tools: z58.number().int().nonnegative(),
|
|
13409
|
+
total_matches: z58.number().int().nonnegative(),
|
|
13410
|
+
returned_tools: z58.number().int().nonnegative(),
|
|
13411
|
+
execution_tool: z58.literal("executeTool"),
|
|
13412
|
+
tools: z58.array(searchToolsToolSchema)
|
|
13530
13413
|
}).strict();
|
|
13531
13414
|
function normalize2(value) {
|
|
13532
13415
|
return value.toLowerCase().replace(/[^a-z0-9_]+/g, " ").trim();
|
|
@@ -13641,14 +13524,14 @@ function createSearchToolsTool(catalogTools) {
|
|
|
13641
13524
|
openWorldHint: false,
|
|
13642
13525
|
readOnlyHint: true
|
|
13643
13526
|
},
|
|
13644
|
-
inputSchema:
|
|
13645
|
-
query:
|
|
13527
|
+
inputSchema: z58.object({
|
|
13528
|
+
query: z58.string().nullable().describe(
|
|
13646
13529
|
"Optional search terms describing the tool, owner, action, or arguments needed. Empty string lists catalog tools."
|
|
13647
13530
|
).optional(),
|
|
13648
|
-
source:
|
|
13531
|
+
source: z58.string().nullable().describe(
|
|
13649
13532
|
"Optional source id to search within, such as a plugin source returned in sources."
|
|
13650
13533
|
).optional(),
|
|
13651
|
-
max_results:
|
|
13534
|
+
max_results: z58.number().int().min(1).max(MAX_RESULTS3).nullable().describe("Maximum matching catalog tool descriptors to return.").optional()
|
|
13652
13535
|
}).strict(),
|
|
13653
13536
|
outputSchema: searchToolsOutputSchema,
|
|
13654
13537
|
privateTraceResult: (result) => ({
|
|
@@ -13963,7 +13846,7 @@ function createMcpAuthOrchestration(input) {
|
|
|
13963
13846
|
if (!input.conversationId || !input.sessionId || !input.actorId) {
|
|
13964
13847
|
return void 0;
|
|
13965
13848
|
}
|
|
13966
|
-
if (!input.recordPendingAuth && input.
|
|
13849
|
+
if (!input.recordPendingAuth && input.interactiveAuthEnabled !== false) {
|
|
13967
13850
|
throw new Error(
|
|
13968
13851
|
`Missing pending auth recorder for MCP authorization pause "${plugin.manifest.name}"`
|
|
13969
13852
|
);
|
|
@@ -13999,7 +13882,7 @@ function createMcpAuthOrchestration(input) {
|
|
|
13999
13882
|
`Missing MCP auth session context for plugin "${provider}"`
|
|
14000
13883
|
);
|
|
14001
13884
|
}
|
|
14002
|
-
if (input.
|
|
13885
|
+
if (input.interactiveAuthEnabled === false) {
|
|
14003
13886
|
await deleteMcpAuthSession(authSessionId);
|
|
14004
13887
|
throw new AuthorizationFlowDisabledError("mcp", provider);
|
|
14005
13888
|
}
|
|
@@ -14893,7 +14776,7 @@ function createPluginEgress(deps) {
|
|
|
14893
14776
|
}
|
|
14894
14777
|
|
|
14895
14778
|
// src/chat/services/guardian-action-review.ts
|
|
14896
|
-
import { z as
|
|
14779
|
+
import { z as z59 } from "zod";
|
|
14897
14780
|
|
|
14898
14781
|
// src/chat/services/guardian-action-policy.ts
|
|
14899
14782
|
var GUARDIAN_ACTION_POLICY = `You are judging one planned Junior agent action.
|
|
@@ -14959,17 +14842,17 @@ Assess the exact action's intrinsic risk and whether the user's intent authorize
|
|
|
14959
14842
|
- Keep the reason to one concise, specific sentence grounded in the main risk or authorization fact. For ask, name the exact action, target, and material side effects the user must confirm.`;
|
|
14960
14843
|
|
|
14961
14844
|
// src/chat/services/guardian-action-review.ts
|
|
14962
|
-
var guardianDecisionSchema =
|
|
14963
|
-
decision:
|
|
14964
|
-
reason:
|
|
14965
|
-
riskLevel:
|
|
14966
|
-
userAuthorization:
|
|
14845
|
+
var guardianDecisionSchema = z59.object({
|
|
14846
|
+
decision: z59.enum(["allow", "ask", "deny"]),
|
|
14847
|
+
reason: z59.string().trim().min(1).max(500),
|
|
14848
|
+
riskLevel: z59.enum(["low", "medium", "high", "critical"]),
|
|
14849
|
+
userAuthorization: z59.enum(["high", "medium", "low", "unknown"])
|
|
14967
14850
|
}).strict();
|
|
14968
14851
|
var GUARDIAN_REVIEW_TIMEOUT_MS = 6e4;
|
|
14969
14852
|
var GUARDIAN_REVIEW_MAX_TOKENS = 2e3;
|
|
14970
14853
|
var MAX_PROPOSAL_CHARS = 192e3;
|
|
14971
14854
|
function guardianPrompt(proposal) {
|
|
14972
|
-
const proposalJson = JSON.stringify(
|
|
14855
|
+
const proposalJson = JSON.stringify(z59.json().parse(proposal), null, 2);
|
|
14973
14856
|
if (proposalJson.length > MAX_PROPOSAL_CHARS) {
|
|
14974
14857
|
throw new Error(
|
|
14975
14858
|
`Guardian action proposal exceeds ${MAX_PROPOSAL_CHARS} characters.`
|
|
@@ -15257,7 +15140,10 @@ async function wireAgentTools(args) {
|
|
|
15257
15140
|
args.artifactStatePatch
|
|
15258
15141
|
),
|
|
15259
15142
|
recordPendingAuth: args.durability.recordPendingAuth,
|
|
15260
|
-
|
|
15143
|
+
interactiveAuthEnabled: !isAgentRunFeatureDisabled(
|
|
15144
|
+
args.policy,
|
|
15145
|
+
"interactive-auth"
|
|
15146
|
+
),
|
|
15261
15147
|
authorization: args.authorization
|
|
15262
15148
|
});
|
|
15263
15149
|
const pluginAuth = createPluginAuthOrchestration({
|
|
@@ -15272,7 +15158,10 @@ async function wireAgentTools(args) {
|
|
|
15272
15158
|
userMessage: args.userInput,
|
|
15273
15159
|
pendingAuth: args.state.pendingAuth,
|
|
15274
15160
|
recordPendingAuth: args.durability.recordPendingAuth,
|
|
15275
|
-
|
|
15161
|
+
interactiveAuthEnabled: !isAgentRunFeatureDisabled(
|
|
15162
|
+
args.policy,
|
|
15163
|
+
"interactive-auth"
|
|
15164
|
+
),
|
|
15276
15165
|
userTokenStore,
|
|
15277
15166
|
authorization: args.authorization
|
|
15278
15167
|
});
|
|
@@ -15325,6 +15214,7 @@ async function wireAgentTools(args) {
|
|
|
15325
15214
|
...args.currentActor ? {
|
|
15326
15215
|
resolveActorIdentity: async () => await readActorIdentity(args.currentActor)
|
|
15327
15216
|
} : {},
|
|
15217
|
+
...args.durability.spawnAgent ? { spawnAgent: args.durability.spawnAgent } : {},
|
|
15328
15218
|
...args.requestHandoff ? { handoff: args.requestHandoff } : {}
|
|
15329
15219
|
};
|
|
15330
15220
|
const toolDestination = toolInvocationDestination(args.routing);
|
|
@@ -16506,9 +16396,10 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy, run
|
|
|
16506
16396
|
const explicitSkill = invokedSkill ? activeSkills.find((skill) => skill.name === invokedSkill.name) ?? null : null;
|
|
16507
16397
|
const { contextContentParts, routerBlocks, userContentParts } = buildPromptInput(input);
|
|
16508
16398
|
const preAgentPromptMessages = () => existingSessionRecord?.piMessages ?? [...input.piMessages ?? []];
|
|
16399
|
+
const handoffEnabled = !isAgentRunFeatureDisabled(policy, "handoff");
|
|
16509
16400
|
const storedTurnRoute = await loadTurnRoute({ conversationId, turnId });
|
|
16510
16401
|
if (storedTurnRoute) {
|
|
16511
|
-
const resumedAfterHandoff = activeModelProfile !== STANDARD_MODEL_PROFILE && activeModelProfile !== storedTurnRoute.modelProfile;
|
|
16402
|
+
const resumedAfterHandoff = handoffEnabled && activeModelProfile !== STANDARD_MODEL_PROFILE && activeModelProfile !== storedTurnRoute.modelProfile;
|
|
16512
16403
|
if (resumedAfterHandoff) {
|
|
16513
16404
|
const activeProfileConfig = profileConfig(
|
|
16514
16405
|
botConfig,
|
|
@@ -16529,7 +16420,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy, run
|
|
|
16529
16420
|
source: storedTurnRoute.source
|
|
16530
16421
|
};
|
|
16531
16422
|
}
|
|
16532
|
-
} else if (activeModelProfile === STANDARD_MODEL_PROFILE) {
|
|
16423
|
+
} else if (activeModelProfile === STANDARD_MODEL_PROFILE && handoffEnabled) {
|
|
16533
16424
|
turnRoute = await selectTurnRoute({
|
|
16534
16425
|
completeObject,
|
|
16535
16426
|
conversationContext: input.conversationContext,
|
|
@@ -16555,6 +16446,15 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy, run
|
|
|
16555
16446
|
reason: `configured:${policy.reasoningLevel ? "agent_config" : "default"}:${turnRoute.reason}`
|
|
16556
16447
|
};
|
|
16557
16448
|
}
|
|
16449
|
+
} else if (!handoffEnabled) {
|
|
16450
|
+
const activeProfileConfig = profileConfig(botConfig, activeModelProfile);
|
|
16451
|
+
const reasoningSource = policy.reasoningLevel ? "agent_config" : activeProfileConfig.reasoningLevel ? "profile" : "default";
|
|
16452
|
+
turnRoute = {
|
|
16453
|
+
profile: activeModelProfile,
|
|
16454
|
+
reasoningLevel: policy.reasoningLevel ?? activeProfileConfig.reasoningLevel ?? botConfig.reasoningLevel ?? "medium",
|
|
16455
|
+
reason: `fixed:${reasoningSource}`,
|
|
16456
|
+
source: "configured"
|
|
16457
|
+
};
|
|
16558
16458
|
} else {
|
|
16559
16459
|
const activeProfileConfig = profileConfig(botConfig, activeModelProfile);
|
|
16560
16460
|
const reasoningSource = activeProfileConfig.reasoningLevel ? "profile" : policy.reasoningLevel ? "agent_config" : "default";
|
|
@@ -16674,7 +16574,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy, run
|
|
|
16674
16574
|
})
|
|
16675
16575
|
} : void 0;
|
|
16676
16576
|
};
|
|
16677
|
-
const requestHandoff = handoffControlFor(activeModelProfile);
|
|
16577
|
+
const requestHandoff = handoffEnabled ? handoffControlFor(activeModelProfile) : void 0;
|
|
16678
16578
|
setTags({
|
|
16679
16579
|
...runLogContext,
|
|
16680
16580
|
modelId: activeModelId
|
|
@@ -16733,7 +16633,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy, run
|
|
|
16733
16633
|
(tool) => tool.name === HANDOFF_TOOL_NAME
|
|
16734
16634
|
);
|
|
16735
16635
|
const toolsForActiveProfile = () => {
|
|
16736
|
-
const handoff = handoffControlFor(activeModelProfile);
|
|
16636
|
+
const handoff = handoffEnabled ? handoffControlFor(activeModelProfile) : void 0;
|
|
16737
16637
|
if (!handoff) {
|
|
16738
16638
|
return toolsWithoutHandoff;
|
|
16739
16639
|
}
|
|
@@ -16948,9 +16848,9 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy, run
|
|
|
16948
16848
|
}
|
|
16949
16849
|
return acceptedMessages;
|
|
16950
16850
|
};
|
|
16951
|
-
const apiKeyOverride = getPiGatewayApiKey();
|
|
16952
16851
|
agent = new Agent({
|
|
16953
|
-
|
|
16852
|
+
// Resolve on every provider call so runtime OIDC tokens stay fresh.
|
|
16853
|
+
getApiKey: getGatewayApiKey,
|
|
16954
16854
|
streamFn: createTracedStreamFn({
|
|
16955
16855
|
conversationPrivacy,
|
|
16956
16856
|
...streamFn ? { base: streamFn } : {}
|
|
@@ -17438,17 +17338,28 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy, run
|
|
|
17438
17338
|
// src/chat/runtime/agent-runner.ts
|
|
17439
17339
|
function createAgentRunner(run, options) {
|
|
17440
17340
|
const tracePropagation = options?.tracePropagation;
|
|
17441
|
-
|
|
17341
|
+
const bindSpawnAgent = options?.bindSpawnAgent;
|
|
17342
|
+
const canBindSpawn = Boolean(bindSpawnAgent) && isExperimentalFeatureEnabled("subagents");
|
|
17343
|
+
if (!tracePropagation && !canBindSpawn) {
|
|
17442
17344
|
return { run };
|
|
17443
17345
|
}
|
|
17444
17346
|
return {
|
|
17445
|
-
run: async (request) =>
|
|
17446
|
-
|
|
17447
|
-
|
|
17448
|
-
...request
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17347
|
+
run: async (request) => {
|
|
17348
|
+
const spawnAgent = bindSpawnAgent && canBindSpawn && !isAgentRunFeatureDisabled(request.policy, "subagents") ? bindSpawnAgent(request) : void 0;
|
|
17349
|
+
return await run({
|
|
17350
|
+
...request,
|
|
17351
|
+
policy: {
|
|
17352
|
+
...request.policy,
|
|
17353
|
+
sandboxTracePropagation: request.policy?.sandboxTracePropagation ?? tracePropagation
|
|
17354
|
+
},
|
|
17355
|
+
...spawnAgent ? {
|
|
17356
|
+
durability: {
|
|
17357
|
+
...request.durability,
|
|
17358
|
+
spawnAgent
|
|
17359
|
+
}
|
|
17360
|
+
} : {}
|
|
17361
|
+
});
|
|
17362
|
+
}
|
|
17452
17363
|
};
|
|
17453
17364
|
}
|
|
17454
17365
|
|
|
@@ -17456,7 +17367,6 @@ export {
|
|
|
17456
17367
|
setConfigDefaults,
|
|
17457
17368
|
getConfigDefaults,
|
|
17458
17369
|
shouldEmitDevAgentTrace,
|
|
17459
|
-
AuthorizationFlowDisabledError,
|
|
17460
17370
|
resolveDestinationVisibility,
|
|
17461
17371
|
buildSteeringPiMessage,
|
|
17462
17372
|
SANDBOX_EGRESS_PROXY_PATH,
|
|
@@ -17475,7 +17385,6 @@ export {
|
|
|
17475
17385
|
renderSlackLegacyAttachmentText,
|
|
17476
17386
|
appendSlackLegacyAttachmentText,
|
|
17477
17387
|
latestReportedProgress,
|
|
17478
|
-
PluginCredentialFailureError,
|
|
17479
17388
|
executeCredentialedEgressRequest,
|
|
17480
17389
|
createContextCompactor,
|
|
17481
17390
|
executeAgentRun,
|