@sentry/junior 0.257.0 → 0.259.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/{actor-BTtLaeWy.js → actor-tlxzqaRe.js} +3 -6
- package/dist/adapter-Bn0gFVSF.js +270 -0
- package/dist/{admin-DgIkm6Vy.js → admin-C8xz2f10.js} +2 -3
- package/dist/{agent-hooks-BjtTzvru.js → agent-hooks-B00FaKdP.js} +70 -109
- package/dist/{agent-invocations-Bdu3ROfo.js → agent-invocations-Qfz7dWgU.js} +6 -12
- package/dist/{agent-runner-D7OboVb3.js → agent-runner-CPSd7rKm.js} +324 -742
- package/dist/api/schema.d.ts +442 -447
- package/dist/api/schema.js +6 -6
- package/dist/api.d.ts +2 -12
- package/dist/api.js +165 -158
- package/dist/{app-BsU5QNBd.d.ts → app-Bbxrehjf.d.ts} +25 -45
- package/dist/app.d.ts +3 -3
- package/dist/app.js +206 -321
- package/dist/{assistant-reply-CbTPebzL.js → assistant-reply-CqthTerd.js} +3 -5
- package/dist/{automation-CHdlHVZP.js → automation-DWBFBenG.js} +6 -11
- package/dist/{briefs-oLOldnDM.js → briefs-DNYbQ9cD.js} +8 -11
- package/dist/{cadence-D00SCzT1.js → cadence-R7Em4RjE.js} +1 -2
- package/dist/{catalog-runtime-CZzhGQ7F.js → catalog-runtime-B8SuFPGb.js} +3 -4
- package/dist/cli/chat.d.ts +2 -4
- package/dist/cli/chat.js +22 -24
- package/dist/cli/check.d.ts +1 -3
- package/dist/cli/check.js +4 -5
- package/dist/cli/env.d.ts +1 -3
- package/dist/cli/env.js +1 -2
- package/dist/cli/init.d.ts +1 -3
- package/dist/cli/init.js +3 -3
- package/dist/cli/main.d.ts +1 -3
- package/dist/cli/main.js +8 -5
- package/dist/cli/plugins.d.ts +2 -4
- package/dist/cli/plugins.js +7 -8
- package/dist/cli/run.d.ts +3 -3
- package/dist/cli/run.js +3 -3
- package/dist/cli/snapshot-create.d.ts +1 -3
- package/dist/cli/snapshot-create.js +5 -5
- package/dist/cli/upgrade.d.ts +3 -6
- package/dist/cli/upgrade.js +11 -17
- package/dist/{client-D8HnkOQX.js → client-BZdxgKyL.js} +64 -18
- package/dist/{config-CJRnWK9H.js → config-Deqpfpg9.js} +21 -15
- package/dist/{connections-ClYrKzpX.js → connections-9gJkfS85.js} +179 -20
- package/dist/{conversation-CKNLYBJt.js → conversation-DjN3mlog.js} +8 -15
- package/dist/{conversation-privacy-C8b1nphZ.js → conversation-privacy-CFhNKxp-.js} +2 -3
- package/dist/{conversation-work-C6y3T5Hx.js → conversation-work-BaT_T6EB.js} +1 -2
- package/dist/{credential-sync-BXfohNmJ.js → credential-sync-BABGymK3.js} +23 -190
- package/dist/{db-Ca9Nt5ci.d.ts → db-BnRqQ7G5.d.ts} +1 -1
- package/dist/{executor-Do0THDRR.js → executor-Bb3eQb8q.js} +30 -52
- package/dist/{experimental-CQIvMUO7.js → experimental-BNK1l1jv.js} +2 -4
- package/dist/{history-9pO1Zd4Y.js → history-AY8rs-FR.js} +5 -9
- package/dist/{history-DvqWZlYX.d.ts → history-BgI33Kie.d.ts} +12 -20
- package/dist/{images-BN_BiBXF.js → images-BbSdVHC6.js} +5 -6
- package/dist/instrumentation.d.ts +1 -3
- package/dist/instrumentation.js +6 -8
- package/dist/{job-queue-B6SV9uVa.js → job-queue-vdGU-5ge.js} +6 -12
- package/dist/{logging-CWxiIuCF.js → logging-BStXN56b.js} +7 -12
- package/dist/{message-TUOdbSBW.js → message-DRf6m4uO.js} +5 -6
- package/dist/{model-profile-BwU8mqwD.js → model-profile-Bg8EoCKD.js} +2 -4
- package/dist/nitro.d.ts +3 -5
- package/dist/nitro.js +12 -17
- package/dist/{oauth-authorization-BA4Dt6a7.js → oauth-authorization-djQn5Nhy.js} +2 -4
- package/dist/{oauth-callback-server-Dj5UJODo.js → oauth-callback-server-JmOgLcGl.js} +3 -4
- package/dist/{oauth-relay-CdCnu80W.js → oauth-relay-CTygMkNx.js} +2 -3
- package/dist/{package-discovery-BVvSnQBB.js → package-discovery-DJBompdd.js} +17 -21
- package/dist/{pending-auth-s_QFribU.js → pending-auth-rG5U_QS1.js} +92 -83
- package/dist/{plugin-module-CVvEUSMH.js → plugin-module-Cf5gVPWP.js} +1 -2
- package/dist/{plugins-CjfUP5gJ.d.ts → plugins-B_0Cr0MO.d.ts} +5 -5
- package/dist/{plugins-egKWjgue.js → plugins-DOm9Y6qI.js} +2 -3
- package/dist/{private-trace-result-BLvBjy_e.js → private-trace-result-CE7_lEdq.js} +1 -2
- package/dist/{profile-h-72wM78.js → profile-qBM6B_-V.js} +14 -295
- package/dist/{prompt-DyoEj9c2.js → prompt-xgpyMtg7.js} +5 -9
- package/dist/{queue-B5SnqRln.d.ts → queue-C37RbDVc.d.ts} +0 -2
- package/dist/{registry-sLTr-sV9.js → registry-B_M_x_iS.js} +56 -30
- package/dist/{resolve-ncQPZROQ.js → resolve-BzpuLh8c.js} +8 -12
- package/dist/{result-C883vngT.js → result-DEZH_AnZ.js} +13 -17
- package/dist/{rolldown-runtime-B4FMCO8f.js → rolldown-runtime-nwUcYXjP.js} +1 -2
- package/dist/{runner-CzYImdOF.js → runner-BqQlG10t.js} +12 -13
- package/dist/{sandbox-egress-signals-CZbMINHI.js → sandbox-egress-signals-DCq3WLs5.js} +2 -3
- package/dist/{schema-Dy69D4Ge.js → schema-CF9HqNRY.js} +30 -27
- package/dist/{sentry-CgWZM_kV.js → sentry-BBUlHih9.js} +2 -3
- package/dist/service-account-BqTBkyD7.js +120 -0
- package/dist/service-account-BzhW7kXu.js +661 -0
- package/dist/{session-stop-CQjKd4a2.js → session-stop-CV65ZlU3.js} +23 -33
- package/dist/{skills-C22SLruK.js → skills-CiWS5_Ub.js} +9 -9
- package/dist/{spawn-DY9CLXDL.js → spawn-BSAQ7UQZ.js} +4 -5
- package/dist/{store-DXFIQy-G.js → store-B1GES4gC.js} +13 -15
- package/dist/{store-DoewL5mG.d.ts → store-CG0VJyye.d.ts} +0 -14
- package/dist/{task-queue-B17vV0La.js → task-queue-BAeGEMjJ.js} +5 -7
- package/dist/{task-runner-DUjvzYXj.js → task-runner-BlGhcQPi.js} +22 -26
- package/dist/{tasks-D_WIJtvO.js → tasks-DieKX3d4.js} +63 -78
- package/dist/{thread-state-Ch4yuCqG.js → thread-state-DpSWS4Rr.js} +13 -19
- package/dist/{turn-failure-response-C5nBKC4S.js → turn-failure-response-DQljogGJ.js} +16 -22
- package/dist/{turn-lifecycle-CO-ylUmV.js → turn-lifecycle-BLgrkV_L.js} +2 -3
- package/dist/{turn-session-routing-B3LWooK5.js → turn-session-routing-BlajheOU.js} +2 -3
- package/dist/{validation-CXYxaNYx.js → validation-23d7K9tX.js} +3 -4
- package/dist/vercel.d.ts +1 -3
- package/dist/vercel.js +1 -2
- package/dist/{version-BcdZy2zg.js → version-B_XumRx-.js} +3 -5
- package/dist/{version-CnXZ614E.d.ts → version-Cc2OFd9G.d.ts} +0 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -2
- package/dist/{viewer-DSZXygMU.js → viewer-B2_ABsYi.js} +26 -57
- package/dist/{web-input-B9Bv0_lR.js → web-input-BZDyxpzR.js} +101 -158
- package/dist/{web-message-id-xPI_EFSC.js → web-message-id-CJSUiksE.js} +3 -6
- package/dist/{work-nAfDSUFP.js → work-D3QKiV0O.js} +14 -16
- package/dist/{worker-vGXZ6XFT.js → worker-C8mUjYf9.js} +7 -8
- package/package.json +10 -9
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { b as setSpanStatus, y as setSpanAttributes } from "./logging-
|
|
3
|
-
import {
|
|
4
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-CZzhGQ7F.js";
|
|
1
|
+
import { C as toOptionalTrimmed } from "./client-BZdxgKyL.js";
|
|
2
|
+
import { b as setSpanStatus, y as setSpanAttributes } from "./logging-BStXN56b.js";
|
|
3
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-B8SuFPGb.js";
|
|
5
4
|
import { createHash } from "node:crypto";
|
|
6
|
-
|
|
7
|
-
import { createRedisState } from "@chat-adapter/state-redis";
|
|
8
|
-
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
9
|
-
//#region src/chat/sandbox/paths.ts
|
|
5
|
+
// src/chat/sandbox/paths.ts
|
|
10
6
|
function normalizeWorkspaceRoot(input) {
|
|
11
7
|
const candidate = (input ?? "").trim();
|
|
12
8
|
if (!candidate) return "/vercel/sandbox";
|
|
@@ -28,8 +24,7 @@ function sandboxSkillPathResolution(skillName) {
|
|
|
28
24
|
const skillDir = sandboxSkillDir(skillName);
|
|
29
25
|
return `Resolve relative paths in this skill against ${skillDir}. For bash commands from this skill, cd to ${skillDir} first or use absolute paths.`;
|
|
30
26
|
}
|
|
31
|
-
|
|
32
|
-
//#region src/chat/sleep.ts
|
|
27
|
+
// src/chat/sleep.ts
|
|
33
28
|
/** Wait for a duration, rejecting with the owning signal reason when cancelled. */
|
|
34
29
|
function sleep(ms, signal) {
|
|
35
30
|
if (!signal) return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -49,275 +44,7 @@ function sleep(ms, signal) {
|
|
|
49
44
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
50
45
|
});
|
|
51
46
|
}
|
|
52
|
-
|
|
53
|
-
//#region src/chat/state/locks.ts
|
|
54
|
-
const ACTIVE_LOCK_TTL_MS = 9e4;
|
|
55
|
-
const MUTATION_LOCK_TTL_MS = 1e4;
|
|
56
|
-
/**
|
|
57
|
-
* Acquire a lock for long-running work that the queued state adapter should
|
|
58
|
-
* keep alive while the owning invocation is still making progress.
|
|
59
|
-
*/
|
|
60
|
-
async function acquireActiveLock(state, threadId) {
|
|
61
|
-
return await state.acquireLock(threadId, ACTIVE_LOCK_TTL_MS);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Run work under one lock, optionally waiting for the current owner.
|
|
65
|
-
* `keepAlive` is for multi-store mutations that must retain ownership until all
|
|
66
|
-
* side effects finish; callers should still fence each blind write.
|
|
67
|
-
*/
|
|
68
|
-
async function withLock(state, key, run, options = {}) {
|
|
69
|
-
const startedAtMs = Date.now();
|
|
70
|
-
let lock;
|
|
71
|
-
while (true) {
|
|
72
|
-
lock = await state.acquireLock(key, options.ttlMs ?? 9e4);
|
|
73
|
-
if (lock) break;
|
|
74
|
-
if (Date.now() - startedAtMs >= (options.waitMs ?? 0)) return { acquired: false };
|
|
75
|
-
await setTimeout$1(options.retryMs ?? 25, void 0, { ref: false });
|
|
76
|
-
}
|
|
77
|
-
const ttlMs = options.ttlMs ?? 9e4;
|
|
78
|
-
const heartbeat = options.keepAlive ? setInterval(() => {
|
|
79
|
-
state.extendLock(lock, ttlMs);
|
|
80
|
-
}, Math.max(1, Math.floor(ttlMs / 3))) : void 0;
|
|
81
|
-
heartbeat?.unref();
|
|
82
|
-
try {
|
|
83
|
-
return {
|
|
84
|
-
acquired: true,
|
|
85
|
-
value: await run(lock)
|
|
86
|
-
};
|
|
87
|
-
} finally {
|
|
88
|
-
if (heartbeat) clearInterval(heartbeat);
|
|
89
|
-
await state.releaseLock(lock);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Prove lock ownership immediately before a blind write.
|
|
94
|
-
*
|
|
95
|
-
* Whole-record mutations must stop if their lock expired rather than overwrite
|
|
96
|
-
* state committed by a newer owner.
|
|
97
|
-
*/
|
|
98
|
-
async function fenceLock(state, lock, ttlMs = MUTATION_LOCK_TTL_MS) {
|
|
99
|
-
if (!await state.extendLock(lock, ttlMs)) throw new Error(`Lock ownership was lost before write for ${lock.threadId}`);
|
|
100
|
-
}
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/chat/state/adapter.ts
|
|
103
|
-
const ACTIVE_LOCK_HEARTBEAT_MS = 3e4;
|
|
104
|
-
let stateAdapter;
|
|
105
|
-
let redisStateAdapter;
|
|
106
|
-
/** Lazily connect state operations, including queued-adapter lock heartbeats. */
|
|
107
|
-
function createConnectingStateAdapter(base) {
|
|
108
|
-
const connected = async (operation) => {
|
|
109
|
-
await base.connect();
|
|
110
|
-
return await operation();
|
|
111
|
-
};
|
|
112
|
-
return {
|
|
113
|
-
appendToList: (key, value, options) => connected(() => base.appendToList(key, value, options)),
|
|
114
|
-
connect: () => base.connect(),
|
|
115
|
-
disconnect: () => base.disconnect(),
|
|
116
|
-
subscribe: (threadId) => connected(() => base.subscribe(threadId)),
|
|
117
|
-
unsubscribe: (threadId) => connected(() => base.unsubscribe(threadId)),
|
|
118
|
-
isSubscribed: (threadId) => connected(() => base.isSubscribed(threadId)),
|
|
119
|
-
acquireLock: (threadId, ttlMs) => connected(() => base.acquireLock(threadId, ttlMs)),
|
|
120
|
-
releaseLock: (lock) => connected(() => base.releaseLock(lock)),
|
|
121
|
-
extendLock: (lock, ttlMs) => connected(() => base.extendLock(lock, ttlMs)),
|
|
122
|
-
forceReleaseLock: (threadId) => connected(() => base.forceReleaseLock(threadId)),
|
|
123
|
-
enqueue: (threadId, entry, maxSize) => connected(() => base.enqueue(threadId, entry, maxSize)),
|
|
124
|
-
dequeue: (threadId) => connected(() => base.dequeue(threadId)),
|
|
125
|
-
queueDepth: (threadId) => connected(() => base.queueDepth(threadId)),
|
|
126
|
-
get: (key) => connected(() => base.get(key)),
|
|
127
|
-
getList: (key) => connected(() => base.getList(key)),
|
|
128
|
-
set: (key, value, ttlMs) => connected(() => base.set(key, value, ttlMs)),
|
|
129
|
-
setIfNotExists: (key, value, ttlMs) => connected(() => base.setIfNotExists(key, value, ttlMs)),
|
|
130
|
-
delete: (key) => connected(() => base.delete(key))
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function createPrefixedStateAdapter(base, prefix) {
|
|
134
|
-
const prefixed = (value) => `${prefix}:${value}`;
|
|
135
|
-
const unprefixed = (value) => value.startsWith(`${prefix}:`) ? value.slice(prefix.length + 1) : value;
|
|
136
|
-
const prefixLock = (lock) => ({
|
|
137
|
-
...lock,
|
|
138
|
-
threadId: prefixed(lock.threadId)
|
|
139
|
-
});
|
|
140
|
-
const unprefixLock = (lock) => ({
|
|
141
|
-
...lock,
|
|
142
|
-
threadId: unprefixed(lock.threadId)
|
|
143
|
-
});
|
|
144
|
-
return {
|
|
145
|
-
appendToList: (key, value, options) => base.appendToList(prefixed(key), value, options),
|
|
146
|
-
connect: () => base.connect(),
|
|
147
|
-
disconnect: () => base.disconnect(),
|
|
148
|
-
subscribe: (threadId) => base.subscribe(prefixed(threadId)),
|
|
149
|
-
unsubscribe: (threadId) => base.unsubscribe(prefixed(threadId)),
|
|
150
|
-
isSubscribed: (threadId) => base.isSubscribed(prefixed(threadId)),
|
|
151
|
-
acquireLock: async (threadId, ttlMs) => {
|
|
152
|
-
const lock = await base.acquireLock(prefixed(threadId), ttlMs);
|
|
153
|
-
return lock ? unprefixLock(lock) : null;
|
|
154
|
-
},
|
|
155
|
-
releaseLock: (lock) => base.releaseLock(prefixLock(lock)),
|
|
156
|
-
extendLock: async (lock, ttlMs) => {
|
|
157
|
-
const prefixedLock = prefixLock(lock);
|
|
158
|
-
const extended = await base.extendLock(prefixedLock, ttlMs);
|
|
159
|
-
if (extended) lock.expiresAt = prefixedLock.expiresAt;
|
|
160
|
-
return extended;
|
|
161
|
-
},
|
|
162
|
-
forceReleaseLock: (threadId) => base.forceReleaseLock(prefixed(threadId)),
|
|
163
|
-
enqueue: (threadId, entry, maxSize) => base.enqueue(prefixed(threadId), entry, maxSize),
|
|
164
|
-
dequeue: (threadId) => base.dequeue(prefixed(threadId)),
|
|
165
|
-
queueDepth: (threadId) => base.queueDepth(prefixed(threadId)),
|
|
166
|
-
get: (key) => base.get(prefixed(key)),
|
|
167
|
-
getList: (key) => base.getList(prefixed(key)),
|
|
168
|
-
set: (key, value, ttlMs) => base.set(prefixed(key), value, ttlMs),
|
|
169
|
-
setIfNotExists: (key, value, ttlMs) => base.setIfNotExists(prefixed(key), value, ttlMs),
|
|
170
|
-
delete: (key) => base.delete(prefixed(key))
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
function createQueuedStateAdapter(base, options) {
|
|
174
|
-
const heartbeats = /* @__PURE__ */ new Map();
|
|
175
|
-
const shouldHeartbeatLock = (ttlMs) => ttlMs === ACTIVE_LOCK_TTL_MS;
|
|
176
|
-
const heartbeatKey = (lock) => `${lock.threadId}:${lock.token}`;
|
|
177
|
-
const stopHeartbeatByKey = (key) => {
|
|
178
|
-
const heartbeat = heartbeats.get(key);
|
|
179
|
-
if (!heartbeat) return;
|
|
180
|
-
clearInterval(heartbeat.timer);
|
|
181
|
-
heartbeats.delete(key);
|
|
182
|
-
};
|
|
183
|
-
const stopHeartbeat = (lock) => {
|
|
184
|
-
stopHeartbeatByKey(heartbeatKey(lock));
|
|
185
|
-
};
|
|
186
|
-
const stopHeartbeatsForThread = (threadId) => {
|
|
187
|
-
for (const [key, heartbeat] of heartbeats) if (heartbeat.lock.threadId === threadId) stopHeartbeatByKey(key);
|
|
188
|
-
};
|
|
189
|
-
const stopAllHeartbeats = () => {
|
|
190
|
-
for (const key of heartbeats.keys()) stopHeartbeatByKey(key);
|
|
191
|
-
};
|
|
192
|
-
const runHeartbeat = async (key) => {
|
|
193
|
-
const heartbeat = heartbeats.get(key);
|
|
194
|
-
if (!heartbeat || heartbeat.inFlight) return;
|
|
195
|
-
heartbeat.inFlight = true;
|
|
196
|
-
try {
|
|
197
|
-
if (Date.now() - heartbeat.startedAtMs >= options.activeLockMaxAgeMs) {
|
|
198
|
-
stopHeartbeatByKey(key);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
if (!await base.extendLock(heartbeat.lock, heartbeat.ttlMs)) {
|
|
202
|
-
stopHeartbeatByKey(key);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
heartbeat.lock.expiresAt = Date.now() + heartbeat.ttlMs;
|
|
206
|
-
} catch {} finally {
|
|
207
|
-
const current = heartbeats.get(key);
|
|
208
|
-
if (current === heartbeat) current.inFlight = false;
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
const startOrUpdateHeartbeat = (lock, ttlMs) => {
|
|
212
|
-
const key = heartbeatKey(lock);
|
|
213
|
-
const existing = heartbeats.get(key);
|
|
214
|
-
if (existing) {
|
|
215
|
-
existing.ttlMs = ttlMs;
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
const timer = setInterval(() => {
|
|
219
|
-
runHeartbeat(key);
|
|
220
|
-
}, ACTIVE_LOCK_HEARTBEAT_MS);
|
|
221
|
-
timer.unref?.();
|
|
222
|
-
heartbeats.set(key, {
|
|
223
|
-
inFlight: false,
|
|
224
|
-
lock,
|
|
225
|
-
startedAtMs: Date.now(),
|
|
226
|
-
timer,
|
|
227
|
-
ttlMs
|
|
228
|
-
});
|
|
229
|
-
};
|
|
230
|
-
const acquireLock = async (threadId, ttlMs) => {
|
|
231
|
-
const lock = await base.acquireLock(threadId, ttlMs);
|
|
232
|
-
if (lock && shouldHeartbeatLock(ttlMs)) startOrUpdateHeartbeat(lock, ttlMs);
|
|
233
|
-
return lock;
|
|
234
|
-
};
|
|
235
|
-
return {
|
|
236
|
-
appendToList: (key, value, options) => base.appendToList(key, value, options),
|
|
237
|
-
connect: () => base.connect(),
|
|
238
|
-
disconnect: async () => {
|
|
239
|
-
stopAllHeartbeats();
|
|
240
|
-
await base.disconnect();
|
|
241
|
-
},
|
|
242
|
-
subscribe: (threadId) => base.subscribe(threadId),
|
|
243
|
-
unsubscribe: (threadId) => base.unsubscribe(threadId),
|
|
244
|
-
isSubscribed: (threadId) => base.isSubscribed(threadId),
|
|
245
|
-
acquireLock,
|
|
246
|
-
releaseLock: async (lock) => {
|
|
247
|
-
stopHeartbeat(lock);
|
|
248
|
-
await base.releaseLock(lock);
|
|
249
|
-
},
|
|
250
|
-
extendLock: async (lock, ttlMs) => {
|
|
251
|
-
const extended = await base.extendLock(lock, ttlMs);
|
|
252
|
-
if (extended) {
|
|
253
|
-
lock.expiresAt = Date.now() + ttlMs;
|
|
254
|
-
if (shouldHeartbeatLock(ttlMs)) startOrUpdateHeartbeat(lock, ttlMs);
|
|
255
|
-
else stopHeartbeat(lock);
|
|
256
|
-
} else stopHeartbeat(lock);
|
|
257
|
-
return extended;
|
|
258
|
-
},
|
|
259
|
-
forceReleaseLock: async (threadId) => {
|
|
260
|
-
stopHeartbeatsForThread(threadId);
|
|
261
|
-
await base.forceReleaseLock(threadId);
|
|
262
|
-
},
|
|
263
|
-
enqueue: (threadId, entry, maxSize) => base.enqueue(threadId, entry, maxSize),
|
|
264
|
-
dequeue: (threadId) => base.dequeue(threadId),
|
|
265
|
-
queueDepth: (threadId) => base.queueDepth(threadId),
|
|
266
|
-
get: (key) => base.get(key),
|
|
267
|
-
getList: (key) => base.getList(key),
|
|
268
|
-
set: (key, value, ttlMs) => base.set(key, value, ttlMs),
|
|
269
|
-
setIfNotExists: (key, value, ttlMs) => base.setIfNotExists(key, value, ttlMs),
|
|
270
|
-
delete: (key) => base.delete(key)
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
function withOptionalPrefix(base, prefix) {
|
|
274
|
-
return prefix ? createPrefixedStateAdapter(base, prefix) : base;
|
|
275
|
-
}
|
|
276
|
-
function createStateAdapter() {
|
|
277
|
-
const config = getChatConfig();
|
|
278
|
-
const activeLockMaxAgeMs = config.bot.turnTimeoutMs + ACTIVE_LOCK_TTL_MS;
|
|
279
|
-
if (config.state.adapter === "memory") {
|
|
280
|
-
redisStateAdapter = void 0;
|
|
281
|
-
return createQueuedStateAdapter(createConnectingStateAdapter(withOptionalPrefix(createMemoryState(), config.state.keyPrefix)), { activeLockMaxAgeMs });
|
|
282
|
-
}
|
|
283
|
-
if (!config.state.redisUrl) throw new Error("REDIS_URL is required for durable Slack thread state");
|
|
284
|
-
const redisState = createRedisState({ url: config.state.redisUrl });
|
|
285
|
-
redisStateAdapter = redisState;
|
|
286
|
-
return createQueuedStateAdapter(createConnectingStateAdapter(withOptionalPrefix(redisState, config.state.keyPrefix)), { activeLockMaxAgeMs });
|
|
287
|
-
}
|
|
288
|
-
function getOptionalRedisStateAdapter() {
|
|
289
|
-
getStateAdapter();
|
|
290
|
-
return redisStateAdapter;
|
|
291
|
-
}
|
|
292
|
-
async function getConnectedStateContext() {
|
|
293
|
-
const adapter = getStateAdapter();
|
|
294
|
-
await adapter.connect();
|
|
295
|
-
return {
|
|
296
|
-
redisStateAdapter: getOptionalRedisStateAdapter(),
|
|
297
|
-
stateAdapter: adapter
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
/** Return the Redis adapter only when the caller is using the default state adapter. */
|
|
301
|
-
async function getDefaultRedisStateAdapterFor(adapter) {
|
|
302
|
-
if (adapter !== stateAdapter) return;
|
|
303
|
-
const context = await getConnectedStateContext();
|
|
304
|
-
return context.stateAdapter === adapter ? context.redisStateAdapter : void 0;
|
|
305
|
-
}
|
|
306
|
-
function getStateAdapter() {
|
|
307
|
-
if (!stateAdapter) stateAdapter = createStateAdapter();
|
|
308
|
-
return stateAdapter;
|
|
309
|
-
}
|
|
310
|
-
async function disconnectStateAdapter() {
|
|
311
|
-
if (!stateAdapter) return;
|
|
312
|
-
try {
|
|
313
|
-
await stateAdapter.disconnect();
|
|
314
|
-
} finally {
|
|
315
|
-
stateAdapter = void 0;
|
|
316
|
-
redisStateAdapter = void 0;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
//#endregion
|
|
320
|
-
//#region src/chat/sandbox/noninteractive-command.ts
|
|
47
|
+
// src/chat/sandbox/noninteractive-command.ts
|
|
321
48
|
const NON_INTERACTIVE_ENV = {
|
|
322
49
|
CI: "1",
|
|
323
50
|
TERM: "dumb",
|
|
@@ -382,8 +109,7 @@ async function runNonInteractiveCommand(sandbox, input) {
|
|
|
382
109
|
};
|
|
383
110
|
return await sandbox.runCommand(command);
|
|
384
111
|
}
|
|
385
|
-
|
|
386
|
-
//#region src/chat/sandbox/credentials.ts
|
|
112
|
+
// src/chat/sandbox/credentials.ts
|
|
387
113
|
/**
|
|
388
114
|
* Resolve explicit Vercel Sandbox credentials, or return undefined to let
|
|
389
115
|
* the SDK read ambient Vercel auth from its own environment detection.
|
|
@@ -398,8 +124,7 @@ function getVercelSandboxCredentials() {
|
|
|
398
124
|
projectId
|
|
399
125
|
};
|
|
400
126
|
}
|
|
401
|
-
|
|
402
|
-
//#region src/chat/sandbox/http-error-details.ts
|
|
127
|
+
// src/chat/sandbox/http-error-details.ts
|
|
403
128
|
const DEFAULT_PREVIEW_LIMIT = 512;
|
|
404
129
|
function toTrimmedString(value, maxChars) {
|
|
405
130
|
if (typeof value !== "string") return;
|
|
@@ -458,8 +183,7 @@ function extractHttpErrorDetails(error, options = {}) {
|
|
|
458
183
|
searchableText
|
|
459
184
|
};
|
|
460
185
|
}
|
|
461
|
-
|
|
462
|
-
//#region src/chat/sandbox/snapshot/not-ready-error.ts
|
|
186
|
+
// src/chat/sandbox/snapshot/not-ready-error.ts
|
|
463
187
|
/** Report that a Workspace snapshot is not ready to use. */
|
|
464
188
|
var WorkspaceSnapshotNotReadyError = class extends Error {
|
|
465
189
|
workspaceName;
|
|
@@ -487,8 +211,7 @@ function isWorkspaceSnapshotNotReadyError(error) {
|
|
|
487
211
|
function workspaceSnapshotNotReadyUserMessage(error) {
|
|
488
212
|
return `The ${error.workspaceName} workspace is still preparing its sandbox. Wait for that preparation to finish, then try again.`;
|
|
489
213
|
}
|
|
490
|
-
|
|
491
|
-
//#region src/chat/sandbox/errors.ts
|
|
214
|
+
// src/chat/sandbox/errors.ts
|
|
492
215
|
const SANDBOX_ERROR_FIELDS = [{
|
|
493
216
|
sourceKey: "sandboxId",
|
|
494
217
|
attributeKey: "sandbox_id",
|
|
@@ -617,8 +340,7 @@ function throwSandboxOperationError(action, error, includeMissingPath = false) {
|
|
|
617
340
|
setSpanStatus("error");
|
|
618
341
|
throw new Error(details.summary ? `${action} failed (${details.summary})` : `${action} failed`, { cause: error });
|
|
619
342
|
}
|
|
620
|
-
|
|
621
|
-
//#region src/chat/sandbox/docker.ts
|
|
343
|
+
// src/chat/sandbox/docker.ts
|
|
622
344
|
/** Docker daemon config for Vercel sandbox guests (nested containers). */
|
|
623
345
|
const DOCKER_DAEMON_JSON = `{
|
|
624
346
|
"storage-driver": "overlay2",
|
|
@@ -714,8 +436,7 @@ async function ensureDockerDaemon(sandbox, signal) {
|
|
|
714
436
|
signal
|
|
715
437
|
});
|
|
716
438
|
}
|
|
717
|
-
|
|
718
|
-
//#region src/chat/sandbox/runtime-dependencies.ts
|
|
439
|
+
// src/chat/sandbox/runtime-dependencies.ts
|
|
719
440
|
const GLOBAL_RUNTIME_DEPENDENCIES = [
|
|
720
441
|
{
|
|
721
442
|
type: "system",
|
|
@@ -762,8 +483,7 @@ const GLOBAL_RUNTIME_POSTINSTALL = [{
|
|
|
762
483
|
].join("\n")],
|
|
763
484
|
sudo: true
|
|
764
485
|
}];
|
|
765
|
-
|
|
766
|
-
//#region src/chat/sandbox/snapshot/profile.ts
|
|
486
|
+
// src/chat/sandbox/snapshot/profile.ts
|
|
767
487
|
const VERSION = 1;
|
|
768
488
|
const DEFAULT_FLOATING_MAX_AGE_MS = 6048e5;
|
|
769
489
|
function isExactNpmVersion(version) {
|
|
@@ -852,5 +572,4 @@ function isStale(profile, createdAtMs) {
|
|
|
852
572
|
const maxAgeMs = floatingMaxAgeMs();
|
|
853
573
|
return maxAgeMs === 0 || Date.now() - createdAtMs > maxAgeMs;
|
|
854
574
|
}
|
|
855
|
-
|
|
856
|
-
export { SANDBOX_DATA_ROOT as A, getDefaultRedisStateAdapterFor as C, fenceLock as D, acquireActiveLock as E, sandboxSkillFile as F, sandboxSkillPathResolution as I, SANDBOX_SKILLS_ROOT as M, SANDBOX_WORKSPACE_ROOT as N, withLock as O, sandboxSkillDir as P, disconnectStateAdapter as S, MUTATION_LOCK_TTL_MS as T, workspaceSnapshotNotReadyUserMessage as _, isAbortError as a, buildNonInteractiveShellScript as b, isSandboxCommandStreamInterruptedError as c, isSnapshottingError as d, throwSandboxOperationError as f, isWorkspaceSnapshotNotReadyError as g, getWorkspaceSnapshotNotReadyError as h, ensureDockerDaemon as i, SANDBOX_REPOS_ROOT as j, sleep as k, isSandboxMissingError as l, WorkspaceSnapshotNotReadyError as m, hash as n, isAlreadyExistsError as o, wrapSandboxSetupError as p, isStale as r, isSandboxApiTransientError as s, create as t, isSandboxUnavailableError as u, getVercelSandboxCredentials as v, getStateAdapter as w, runNonInteractiveCommand as x, buildCommandScript as y };
|
|
575
|
+
export { SANDBOX_DATA_ROOT as C, sandboxSkillDir as D, SANDBOX_WORKSPACE_ROOT as E, sandboxSkillFile as O, sleep as S, SANDBOX_SKILLS_ROOT as T, workspaceSnapshotNotReadyUserMessage as _, isAbortError as a, buildNonInteractiveShellScript as b, isSandboxCommandStreamInterruptedError as c, isSnapshottingError as d, throwSandboxOperationError as f, isWorkspaceSnapshotNotReadyError as g, getWorkspaceSnapshotNotReadyError as h, ensureDockerDaemon as i, sandboxSkillPathResolution as k, isSandboxMissingError as l, WorkspaceSnapshotNotReadyError as m, hash as n, isAlreadyExistsError as o, wrapSandboxSetupError as p, isStale as r, isSandboxApiTransientError as s, create as t, isSandboxUnavailableError as u, getVercelSandboxCredentials as v, SANDBOX_REPOS_ROOT as w, runNonInteractiveCommand as x, buildCommandScript as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as conversationBriefSchema, U as parseBriefInput, V as briefOutcomeStatusSchema } from "./conversation-
|
|
1
|
+
import { H as conversationBriefSchema, U as parseBriefInput, V as briefOutcomeStatusSchema } from "./conversation-DjN3mlog.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
3
|
+
// src/chat/briefs/generate.ts
|
|
4
4
|
const MAX_INPUT_CHARS = 6e4;
|
|
5
5
|
const MAX_MESSAGE_TEXT_CHARS = 4e3;
|
|
6
6
|
const MAX_TOOL_TEXT_CHARS = 1500;
|
|
@@ -406,8 +406,7 @@ async function generateBrief(args) {
|
|
|
406
406
|
throughIndex: args.throughIndex
|
|
407
407
|
};
|
|
408
408
|
}
|
|
409
|
-
|
|
410
|
-
//#region src/chat/events/actor.ts
|
|
409
|
+
// src/chat/events/actor.ts
|
|
411
410
|
/**
|
|
412
411
|
* System author ID stamped on event mailbox messages.
|
|
413
412
|
*
|
|
@@ -439,8 +438,7 @@ const EVENT_SYSTEM_ACTOR = {
|
|
|
439
438
|
function isEventConversationMessage(message) {
|
|
440
439
|
return Boolean(message.meta?.eventType) || message.author?.userId === "UJRNEVENT";
|
|
441
440
|
}
|
|
442
|
-
|
|
443
|
-
//#region src/chat/briefs/event-entries.ts
|
|
441
|
+
// src/chat/briefs/event-entries.ts
|
|
444
442
|
const TOOL_TEXT_LIMIT = 1500;
|
|
445
443
|
function actorIdentityKey(actor) {
|
|
446
444
|
const slackUserId = actor?.slackUserId?.trim();
|
|
@@ -527,8 +525,7 @@ function briefEntriesFromReportEvents(events) {
|
|
|
527
525
|
}
|
|
528
526
|
return entries;
|
|
529
527
|
}
|
|
530
|
-
|
|
531
|
-
//#region src/chat/briefs/prompt.ts
|
|
528
|
+
// src/chat/briefs/prompt.ts
|
|
532
529
|
const BRIEF_PROMPT = `You write one durable Brief for a Junior Conversation.
|
|
533
530
|
|
|
534
531
|
Use only facts supported by the supplied entries, evidence, or previous Brief. Do not invent names, ids, numbers, outcomes, choices, owners, or links.
|
|
@@ -548,5 +545,4 @@ Rules:
|
|
|
548
545
|
- Cite a URL only when its exact full string occurs in an entry, evidence, or the previous Brief. Return cited URLs in urls. Core adds code changes and resources separately.
|
|
549
546
|
- Keep the summary under 600 characters, intent under 400 characters, outcome text under 600 characters, and each other string under 400 characters.
|
|
550
547
|
`;
|
|
551
|
-
//#endregion
|
|
552
548
|
export { EVENT_SYSTEM_ACTOR as a, EVENT_MESSAGE_AUTHOR as i, briefEntriesFromReportEvents as n, isEventConversationMessage as o, EVENT_AUTHOR_ID as r, generateBrief as s, BRIEF_PROMPT as t };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
//#region src/chat/task-execution/queue.d.ts
|
|
3
2
|
/** Validate the v2 conversation work hint sent through Vercel Queue. */
|
|
4
3
|
declare const conversationQueueMessageSchema: z.ZodObject<{
|
|
5
4
|
schemaVersion: z.ZodLiteral<2>;
|
|
@@ -21,5 +20,4 @@ interface ConversationQueueSendResult {
|
|
|
21
20
|
interface ConversationWorkQueue {
|
|
22
21
|
send(message: ConversationQueueMessage, options?: ConversationQueueSendOptions): Promise<ConversationQueueSendResult | void>;
|
|
23
22
|
}
|
|
24
|
-
//#endregion
|
|
25
23
|
export { ConversationWorkQueue as n, ConversationQueueMessage as t };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { m as logWarn, p as logInfo, y as setSpanAttributes } from "./logging-
|
|
2
|
-
import { a as isUserActor, o as parseActorUserId } from "./actor-
|
|
3
|
-
import { n as normalizePluginPackageNames, o as pluginRoots, t as discoverInstalledPluginPackageContent } from "./package-discovery-
|
|
1
|
+
import { m as logWarn, p as logInfo, y as setSpanAttributes } from "./logging-BStXN56b.js";
|
|
2
|
+
import { a as isUserActor, o as parseActorUserId } from "./actor-tlxzqaRe.js";
|
|
3
|
+
import { n as normalizePluginPackageNames, o as pluginRoots, t as discoverInstalledPluginPackageContent } from "./package-discovery-DJBompdd.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { parse } from "yaml";
|
|
8
8
|
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
9
|
-
|
|
9
|
+
// src/chat/plugins/inline-manifest-source.ts
|
|
10
10
|
function setDefined$1(target, key, value) {
|
|
11
11
|
if (value !== void 0) target[key] = value;
|
|
12
12
|
}
|
|
@@ -49,6 +49,13 @@ function mcpOauthClientSource(oauthClient) {
|
|
|
49
49
|
setDefined$1(result, "authorize-params", oauthClient.authorizeParams);
|
|
50
50
|
return result;
|
|
51
51
|
}
|
|
52
|
+
/** Convert a camelCase `accounts` block to its plugin.yaml source keys. */
|
|
53
|
+
function accountsSource(accounts) {
|
|
54
|
+
const result = {};
|
|
55
|
+
setDefined$1(result, "user-oauth", accounts.userOAuth);
|
|
56
|
+
setDefined$1(result, "service-account", accounts.serviceAccount);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
52
59
|
function inlineMcpSource(mcp) {
|
|
53
60
|
if (mcp === void 0 || !isRecord(mcp)) return mcp;
|
|
54
61
|
const result = {};
|
|
@@ -99,11 +106,11 @@ function inlineManifestSource(manifest) {
|
|
|
99
106
|
setDefined$1(result, "runtime-postinstall", manifest.runtimePostinstall);
|
|
100
107
|
setDefined$1(result, "mcp", inlineMcpSource(manifest.mcp));
|
|
101
108
|
setDefined$1(result, "oauth", inlineOauthSource(manifest.oauth));
|
|
109
|
+
setDefined$1(result, "accounts", manifest.accounts && accountsSource(manifest.accounts));
|
|
102
110
|
setDefined$1(result, "target", inlineTargetSource(manifest.name, manifest.target));
|
|
103
111
|
return result;
|
|
104
112
|
}
|
|
105
|
-
|
|
106
|
-
//#region src/chat/plugins/manifest.ts
|
|
113
|
+
// src/chat/plugins/manifest.ts
|
|
107
114
|
const PLUGIN_NAME_RE = /^[a-z][a-z0-9-]*$/;
|
|
108
115
|
const SHORT_CONFIG_KEY_RE = /^[a-z0-9]+(\.[a-z0-9-]+)*$/;
|
|
109
116
|
const TARGET_FLAG_RE = /^-{1,2}[A-Za-z0-9][A-Za-z0-9-]*$/;
|
|
@@ -250,6 +257,10 @@ const mcpOauthClientSourceSchema = z.object({
|
|
|
250
257
|
scope: nonEmptyTrimmedString.optional(),
|
|
251
258
|
"authorize-params": stringMapSchema.optional()
|
|
252
259
|
}).passthrough();
|
|
260
|
+
const accountsSourceSchema = z.object({
|
|
261
|
+
"user-oauth": z.boolean().optional(),
|
|
262
|
+
"service-account": z.object({ tools: nonEmptyStringArraySchema("tools") }).strict().optional()
|
|
263
|
+
}).strict();
|
|
253
264
|
const mcpSourceSchema = z.object({
|
|
254
265
|
transport: nonEmptyTrimmedString.refine((value) => value === "http", { error: "must be \"http\"" }).optional(),
|
|
255
266
|
url: httpsUrlString,
|
|
@@ -278,6 +289,7 @@ const manifestSourceSchema = z.object({
|
|
|
278
289
|
"env-vars": z.record(z.string(), z.unknown(), { error: "must be an object" }).optional(),
|
|
279
290
|
mcp: z.record(z.string(), z.unknown(), { error: "must be an object" }).optional(),
|
|
280
291
|
oauth: z.record(z.string(), z.unknown(), { error: "must be an object" }).optional(),
|
|
292
|
+
accounts: z.record(z.string(), z.unknown(), { error: "must be an object" }).optional(),
|
|
281
293
|
target: z.record(z.string(), z.unknown(), { error: "must be an object" }).optional()
|
|
282
294
|
}).passthrough();
|
|
283
295
|
function setDefined(target, key, value) {
|
|
@@ -336,6 +348,7 @@ function manifestConfigPatch(config) {
|
|
|
336
348
|
result.oauth = oauth;
|
|
337
349
|
}
|
|
338
350
|
}
|
|
351
|
+
if (config.accounts !== void 0) result.accounts = config.accounts && accountsSource(config.accounts);
|
|
339
352
|
if (config.target !== void 0) {
|
|
340
353
|
if (!config.target) result.target = null;
|
|
341
354
|
else {
|
|
@@ -621,6 +634,28 @@ function normalizeMcp(data, envVars, name) {
|
|
|
621
634
|
...result.data["wrapped-tools"] ? { wrappedTools: result.data["wrapped-tools"] } : void 0
|
|
622
635
|
};
|
|
623
636
|
}
|
|
637
|
+
/**
|
|
638
|
+
* Validate which accounts the plugin may use against the surfaces that
|
|
639
|
+
* support them. Today only MCP OAuth stores a service account.
|
|
640
|
+
*/
|
|
641
|
+
function normalizeAccounts(data, mcp, name) {
|
|
642
|
+
const result = accountsSourceSchema.safeParse(data);
|
|
643
|
+
if (!result.success) throw new Error(issueMessage(result.error, `Plugin ${name} accounts`));
|
|
644
|
+
const userOAuth = result.data["user-oauth"];
|
|
645
|
+
const serviceAccount = result.data["service-account"];
|
|
646
|
+
if (userOAuth === false && !serviceAccount) throw new Error(`Plugin ${name} accounts.user-oauth false requires accounts.service-account`);
|
|
647
|
+
if (!serviceAccount) return;
|
|
648
|
+
if (!mcp || mcp.auth || mcp.oauthClient) throw new Error(`Plugin ${name} accounts.service-account requires mcp without auth or oauth-client`);
|
|
649
|
+
if (mcp.allowedTools) {
|
|
650
|
+
const loadedTools = /* @__PURE__ */ new Set([...mcp.allowedTools, ...mcp.wrappedTools ?? []]);
|
|
651
|
+
const unknownTools = serviceAccount.tools.filter((tool) => !loadedTools.has(tool));
|
|
652
|
+
if (unknownTools.length > 0) throw new Error(`Plugin ${name} accounts.service-account.tools must be listed in mcp.allowed-tools or mcp.wrapped-tools: ${unknownTools.join(", ")}`);
|
|
653
|
+
}
|
|
654
|
+
return {
|
|
655
|
+
...userOAuth === false ? { userOAuth } : void 0,
|
|
656
|
+
serviceAccount: { tools: serviceAccount.tools }
|
|
657
|
+
};
|
|
658
|
+
}
|
|
624
659
|
function parseManifestSource(parsedSource, dir, config, options) {
|
|
625
660
|
const source = applyManifestConfig(parsedSource, config);
|
|
626
661
|
const sourceResult = manifestSourceSchema.safeParse(source);
|
|
@@ -639,6 +674,7 @@ function parseManifestSource(parsedSource, dir, config, options) {
|
|
|
639
674
|
if (path === "env-vars") throw new Error(`Plugin ${String(parsedSource.name ?? "unknown")} env-vars must be an object`);
|
|
640
675
|
if (path === "mcp") throw new Error(`Plugin ${String(parsedSource.name ?? "unknown")} mcp must be an object`);
|
|
641
676
|
if (path === "oauth") throw new Error(`Plugin ${String(parsedSource.name ?? "unknown")} oauth must be an object`);
|
|
677
|
+
if (path === "accounts") throw new Error(`Plugin ${String(parsedSource.name ?? "unknown")} accounts must be an object`);
|
|
642
678
|
if (path === "target") throw new Error(`Plugin ${String(parsedSource.name ?? "unknown")} target must be an object`);
|
|
643
679
|
throw new Error(issue?.message ?? `Invalid plugin manifest in ${dir}`);
|
|
644
680
|
}
|
|
@@ -657,6 +693,7 @@ function parseManifestSource(parsedSource, dir, config, options) {
|
|
|
657
693
|
const runtimeDependencies = data["runtime-dependencies"] ? normalizeRuntimeDependencies(data["runtime-dependencies"], data.name) : void 0;
|
|
658
694
|
const runtimePostinstall = data["runtime-postinstall"] ? normalizeRuntimePostinstall(data["runtime-postinstall"], data.name) : void 0;
|
|
659
695
|
const mcp = data.mcp ? normalizeMcp(data.mcp, envVars, data.name) : void 0;
|
|
696
|
+
const accounts = data.accounts ? normalizeAccounts(data.accounts, mcp, data.name) : void 0;
|
|
660
697
|
const manifest = {
|
|
661
698
|
name: data.name,
|
|
662
699
|
displayName: data["display-name"],
|
|
@@ -669,7 +706,8 @@ function parseManifestSource(parsedSource, dir, config, options) {
|
|
|
669
706
|
...credentials ? { credentials } : void 0,
|
|
670
707
|
...runtimeDependencies ? { runtimeDependencies } : void 0,
|
|
671
708
|
...runtimePostinstall ? { runtimePostinstall } : void 0,
|
|
672
|
-
...mcp ? { mcp } : void 0
|
|
709
|
+
...mcp ? { mcp } : void 0,
|
|
710
|
+
...accounts ? { accounts } : void 0
|
|
673
711
|
};
|
|
674
712
|
if (data.oauth) {
|
|
675
713
|
if (!credentials && options?.allowHookManagedEgress !== true) throw new Error(`Plugin ${data.name} oauth requires credentials`);
|
|
@@ -727,8 +765,7 @@ function parsePluginManifest(raw, dir, config) {
|
|
|
727
765
|
function parseInlinePluginManifest(manifest, dir, config) {
|
|
728
766
|
return parseManifestSource(inlineManifestSource(manifest), dir, config, { allowHookManagedEgress: true });
|
|
729
767
|
}
|
|
730
|
-
|
|
731
|
-
//#region src/chat/credentials/broker.ts
|
|
768
|
+
// src/chat/credentials/broker.ts
|
|
732
769
|
var CredentialUnavailableError = class extends Error {
|
|
733
770
|
provider;
|
|
734
771
|
constructor(provider, message) {
|
|
@@ -737,8 +774,7 @@ var CredentialUnavailableError = class extends Error {
|
|
|
737
774
|
this.provider = provider;
|
|
738
775
|
}
|
|
739
776
|
};
|
|
740
|
-
|
|
741
|
-
//#region src/chat/credentials/context.ts
|
|
777
|
+
// src/chat/credentials/context.ts
|
|
742
778
|
const exactActorIdSchema = z.string().refine((value) => parseActorUserId(value) === value);
|
|
743
779
|
const exactNonBlankStringSchema = z.string().min(1).refine((value) => value === value.trim());
|
|
744
780
|
const slackDirectCredentialSubjectBindingSchema = z.object({
|
|
@@ -885,8 +921,7 @@ function credentialUserSubjectId(context) {
|
|
|
885
921
|
if ("type" in context.actor) return context.actor.userId;
|
|
886
922
|
return "subject" in context ? context.subject?.userId : void 0;
|
|
887
923
|
}
|
|
888
|
-
|
|
889
|
-
//#region src/chat/credentials/header-transforms.ts
|
|
924
|
+
// src/chat/credentials/header-transforms.ts
|
|
890
925
|
/** Merge transforms by domain so later transforms override earlier headers. */
|
|
891
926
|
function mergeHeaderTransforms(transforms) {
|
|
892
927
|
const byDomain = /* @__PURE__ */ new Map();
|
|
@@ -899,8 +934,7 @@ function mergeHeaderTransforms(transforms) {
|
|
|
899
934
|
headers
|
|
900
935
|
}));
|
|
901
936
|
}
|
|
902
|
-
|
|
903
|
-
//#region src/chat/credentials/oauth-scope.ts
|
|
937
|
+
// src/chat/credentials/oauth-scope.ts
|
|
904
938
|
function parseScope(scope) {
|
|
905
939
|
if (!scope) return [];
|
|
906
940
|
return [...new Set(scope.split(/\s+/).filter(Boolean))].sort();
|
|
@@ -918,8 +952,7 @@ function hasRequiredOAuthScope(storedScope, requiredScope) {
|
|
|
918
952
|
if (stored.size === 0) return false;
|
|
919
953
|
return required.every((scope) => stored.has(scope));
|
|
920
954
|
}
|
|
921
|
-
|
|
922
|
-
//#region src/chat/oauth-response.ts
|
|
955
|
+
// src/chat/oauth-response.ts
|
|
923
956
|
const MAX_OAUTH_ERROR_BODY_BYTES = 16384;
|
|
924
957
|
const MAX_OAUTH_ERROR_BODY_READS = MAX_OAUTH_ERROR_BODY_BYTES;
|
|
925
958
|
const MAX_OAUTH_ERROR_BODY_READ_MS = 5e3;
|
|
@@ -1013,8 +1046,7 @@ function fetchWithBoundedOAuthErrorBodies(fetchFn = globalThis.fetch, onErrorRes
|
|
|
1013
1046
|
});
|
|
1014
1047
|
});
|
|
1015
1048
|
}
|
|
1016
|
-
|
|
1017
|
-
//#region src/chat/plugins/command-env.ts
|
|
1049
|
+
// src/chat/plugins/command-env.ts
|
|
1018
1050
|
const ENV_PLACEHOLDER_RE$1 = /\$\{([A-Z_][A-Z0-9_]*)\}/g;
|
|
1019
1051
|
function resolveValue(manifest, value) {
|
|
1020
1052
|
let missing = false;
|
|
@@ -1041,15 +1073,13 @@ function resolvePluginCommandEnv(manifest) {
|
|
|
1041
1073
|
}
|
|
1042
1074
|
return env;
|
|
1043
1075
|
}
|
|
1044
|
-
|
|
1045
|
-
//#region src/chat/plugins/auth/auth-token-placeholder.ts
|
|
1076
|
+
// src/chat/plugins/auth/auth-token-placeholder.ts
|
|
1046
1077
|
const DEFAULT_PLACEHOLDERS = { "oauth-bearer": "host_managed_credential" };
|
|
1047
1078
|
/** Resolve the non-secret sandbox token placeholder for token-backed credentials. */
|
|
1048
1079
|
function resolveAuthTokenPlaceholder(credentials) {
|
|
1049
1080
|
return credentials.authTokenPlaceholder?.trim() || DEFAULT_PLACEHOLDERS[credentials.type];
|
|
1050
1081
|
}
|
|
1051
|
-
|
|
1052
|
-
//#region src/chat/plugins/auth/api-headers-broker.ts
|
|
1082
|
+
// src/chat/plugins/auth/api-headers-broker.ts
|
|
1053
1083
|
const MAX_LEASE_MS$1 = 36e5;
|
|
1054
1084
|
const ENV_PLACEHOLDER_RE = /\$\{([A-Z_][A-Z0-9_]*)\}/g;
|
|
1055
1085
|
/**
|
|
@@ -1094,8 +1124,7 @@ function createApiHeadersBroker(manifest) {
|
|
|
1094
1124
|
};
|
|
1095
1125
|
} };
|
|
1096
1126
|
}
|
|
1097
|
-
|
|
1098
|
-
//#region src/chat/plugins/auth/oauth-request.ts
|
|
1127
|
+
// src/chat/plugins/auth/oauth-request.ts
|
|
1099
1128
|
const DEFAULT_TOKEN_CONTENT_TYPE = "application/x-www-form-urlencoded";
|
|
1100
1129
|
function requireNonEmptyTokenField(data, field) {
|
|
1101
1130
|
const value = data[field];
|
|
@@ -1171,8 +1200,7 @@ function parseOAuthTokenResponse(data, requestedScope, options) {
|
|
|
1171
1200
|
}
|
|
1172
1201
|
return parsedOAuthTokenResponseSchema.parse(result);
|
|
1173
1202
|
}
|
|
1174
|
-
|
|
1175
|
-
//#region src/chat/plugins/auth/oauth-bearer-broker.ts
|
|
1203
|
+
// src/chat/plugins/auth/oauth-bearer-broker.ts
|
|
1176
1204
|
const MAX_LEASE_MS = 36e5;
|
|
1177
1205
|
const REFRESH_BUFFER_MS = 3e5;
|
|
1178
1206
|
const TOKEN_REFRESH_TIMEOUT_MS = 2e4;
|
|
@@ -1321,8 +1349,7 @@ function createOAuthBearerBroker(manifest, credentials, deps) {
|
|
|
1321
1349
|
throw new CredentialUnavailableError(provider, `No ${provider} credentials available.`);
|
|
1322
1350
|
} };
|
|
1323
1351
|
}
|
|
1324
|
-
|
|
1325
|
-
//#region src/chat/plugins/registry.ts
|
|
1352
|
+
// src/chat/plugins/registry.ts
|
|
1326
1353
|
function getLoggedPluginNames() {
|
|
1327
1354
|
const globalState = globalThis;
|
|
1328
1355
|
globalState.__juniorLoggedPluginNames ??= /* @__PURE__ */ new Set();
|
|
@@ -1643,5 +1670,4 @@ function createPluginCatalogRuntime() {
|
|
|
1643
1670
|
}
|
|
1644
1671
|
};
|
|
1645
1672
|
}
|
|
1646
|
-
//#endregion
|
|
1647
1673
|
export { CredentialUnavailableError as _, resolveAuthTokenPlaceholder as a, fetchWithBoundedOAuthErrorBodies as c, actorLogContext as d, credentialContextForActor as f, credentialUserSubjectId as g, credentialSubjectSchema as h, resolvePluginHeaderEnvRefs as i, getOAuthProviderErrorAttributes as l, credentialLogContext as m, buildOAuthTokenRequest as n, resolvePluginCommandEnv as o, credentialContextSchema as p, parseOAuthTokenResponse as r, OAuthProviderError as s, createPluginCatalogRuntime as t, hasRequiredOAuthScope as u, parseInlinePluginManifest as v, parsePluginManifest as y };
|