@agentstep/agent-sdk 0.5.27 → 0.5.33
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/auth/middleware.js +8 -8
- package/dist/backends/claude/args.js +6 -6
- package/dist/backends/claude/index.js +11 -11
- package/dist/backends/codex/auth.js +6 -6
- package/dist/backends/codex/index.js +10 -10
- package/dist/backends/factory/auth.js +6 -6
- package/dist/backends/factory/index.js +12 -12
- package/dist/backends/gemini/auth.js +6 -6
- package/dist/backends/gemini/index.js +13 -13
- package/dist/backends/opencode/args.js +1 -1
- package/dist/backends/opencode/auth.js +6 -6
- package/dist/backends/opencode/index.js +14 -14
- package/dist/backends/pi/args.js +1 -1
- package/dist/backends/pi/auth.js +6 -6
- package/dist/backends/pi/index.js +11 -11
- package/dist/backends/registry.js +29 -29
- package/dist/{chunk-PZKWZKRP.js → chunk-2KF2TIEY.js} +5 -5
- package/dist/{chunk-GPGBT7JD.js → chunk-3B4JRSYA.js} +5 -5
- package/dist/{chunk-LJNLU5PQ.js → chunk-3NUTTKE5.js} +2 -2
- package/dist/{chunk-MZ6HBYGV.js → chunk-65XY7HRS.js} +7 -7
- package/dist/{chunk-US26CY2Y.js → chunk-6EIONZ7F.js} +2 -2
- package/dist/{chunk-OQ33WLYG.js → chunk-6RRK27I3.js} +3 -3
- package/dist/chunk-6SD6MC2B.js +29 -0
- package/dist/{chunk-ENFWZ2QM.js → chunk-6U6HEVSN.js} +7 -3
- package/dist/{chunk-J7XHNSPO.js → chunk-7JA6HCMK.js} +2 -2
- package/dist/{chunk-7HTCDMOB.js → chunk-7PFDF5PN.js} +7 -7
- package/dist/{chunk-UB7GS7XT.js → chunk-A3FQHVUG.js} +7 -7
- package/dist/{chunk-ZP5QO5BR.js → chunk-ABUNDZCE.js} +1 -1
- package/dist/{chunk-Q62QJXGO.js → chunk-AGIXZFHQ.js} +1 -1
- package/dist/{chunk-ELK5PVI3.js → chunk-AK6HMO7I.js} +8 -8
- package/dist/{chunk-BYUIOMPX.js → chunk-AKGWEACL.js} +23 -23
- package/dist/{chunk-NKOGWVP3.js → chunk-AUEKXYNE.js} +4 -4
- package/dist/{chunk-A6FHXGSI.js → chunk-B24Q4CUC.js} +5 -5
- package/dist/{chunk-SKVAM5H2.js → chunk-B3W3E5CS.js} +1 -1
- package/dist/{chunk-5AV732JY.js → chunk-BKMY6TSV.js} +2 -2
- package/dist/{chunk-H5UBRKRU.js → chunk-C3UXUDZS.js} +4 -4
- package/dist/{chunk-QQGXM2OQ.js → chunk-C7P2TYOG.js} +1 -1
- package/dist/{chunk-VOHHDBIX.js → chunk-CHNJK2KW.js} +2 -2
- package/dist/{chunk-A3MNXVCR.js → chunk-CJIGDJIJ.js} +3 -3
- package/dist/{chunk-BW6OSLW7.js → chunk-CWB2DQN5.js} +14 -6
- package/dist/{chunk-JC2XJBV2.js → chunk-CWVYFBZF.js} +4 -4
- package/dist/{chunk-4ENK7S24.js → chunk-CXYMVLYK.js} +4 -0
- package/dist/{chunk-LDUQ4FHX.js → chunk-DAOKOXGY.js} +17 -17
- package/dist/{chunk-R37QM2U4.js → chunk-DF34ESOO.js} +1 -1
- package/dist/{chunk-GKNBECPD.js → chunk-DZKBUOYU.js} +2 -2
- package/dist/{chunk-XPPOMXTN.js → chunk-EUMA5Q4U.js} +4 -4
- package/dist/{chunk-FC3UAHXM.js → chunk-FDLQ3IUB.js} +1 -1
- package/dist/{chunk-FDL2JHXO.js → chunk-GCT7A5KR.js} +2 -2
- package/dist/{chunk-Z5XQQN7H.js → chunk-HWWFRSAX.js} +4 -4
- package/dist/{chunk-KWG7NGYF.js → chunk-I2RVN7CP.js} +4 -4
- package/dist/{chunk-JCIAIJFF.js → chunk-IC2ETYU5.js} +3 -3
- package/dist/{chunk-3FLQ7KZP.js → chunk-IMJTHYN3.js} +1 -1
- package/dist/{chunk-ISGA4AOC.js → chunk-J6ESQUW6.js} +2 -2
- package/dist/{chunk-Y3V4COP7.js → chunk-J7F2OFWQ.js} +5 -5
- package/dist/chunk-J7VBHBXL.js +210 -0
- package/dist/{chunk-A4GJADRQ.js → chunk-JF777FWD.js} +2 -2
- package/dist/{chunk-IDQKHWWN.js → chunk-JFHYXFAL.js} +1 -1
- package/dist/{chunk-ZTHH374G.js → chunk-JMDV55BV.js} +2 -2
- package/dist/{chunk-WG3N6VUA.js → chunk-JN3DHH7Z.js} +11 -11
- package/dist/{chunk-MYRTMYTN.js → chunk-JNLVQGSH.js} +6 -6
- package/dist/{chunk-FQQ2R6FA.js → chunk-JNSJKHYX.js} +1 -1
- package/dist/{chunk-TJORQTH6.js → chunk-KGOOCFQY.js} +1 -1
- package/dist/chunk-KLGAE7V4.js +108 -0
- package/dist/{chunk-VEPT2NDJ.js → chunk-KSL2D4AD.js} +3 -3
- package/dist/{chunk-MNW6D7T4.js → chunk-M72ERPMT.js} +1 -1
- package/dist/{chunk-IC5ZTBAW.js → chunk-MUARVVXF.js} +3 -3
- package/dist/{chunk-G6XFFNCQ.js → chunk-N7XSXI5O.js} +18 -18
- package/dist/{chunk-NOW46DBT.js → chunk-NLJK7FEN.js} +3 -3
- package/dist/{chunk-BRULBMRN.js → chunk-NSUVDKNC.js} +3 -3
- package/dist/{chunk-IS6CQPAQ.js → chunk-OEFJPZYH.js} +3 -3
- package/dist/{chunk-P56WU3UT.js → chunk-PDWLVL34.js} +8 -5
- package/dist/{chunk-I2WVMCYN.js → chunk-PWLWDWRL.js} +1 -1
- package/dist/{chunk-JTGISCYV.js → chunk-QCGIYXN4.js} +1 -1
- package/dist/{chunk-6B66DQAS.js → chunk-QGPHATO3.js} +2 -2
- package/dist/{chunk-YS3W5AQA.js → chunk-REHIJQUD.js} +9 -9
- package/dist/{chunk-2K3UO6TC.js → chunk-RES4BCTF.js} +4 -4
- package/dist/{chunk-HDLPEXWS.js → chunk-S5CMAWEC.js} +20 -0
- package/dist/{chunk-KD5Y4XSU.js → chunk-S6HILC3F.js} +2 -2
- package/dist/{chunk-CBPO2P4I.js → chunk-SAI6LBXW.js} +2 -2
- package/dist/{chunk-EY7LWGRO.js → chunk-SDTRWSGF.js} +51 -14
- package/dist/{chunk-CG2VA2YP.js → chunk-SHUFUWAB.js} +61 -4
- package/dist/{chunk-YMKQJY5F.js → chunk-SIO4LO2M.js} +1 -1
- package/dist/{chunk-IITCQTBZ.js → chunk-T2PXAQND.js} +1 -1
- package/dist/{chunk-HPL2MQGY.js → chunk-T3TNJHED.js} +6 -6
- package/dist/{chunk-SBYBNAOU.js → chunk-TKFAWQD7.js} +2 -2
- package/dist/{chunk-D3LKWVPA.js → chunk-TTDMQ54U.js} +2 -2
- package/dist/{chunk-CPCGFE75.js → chunk-TTZGQIQS.js} +1 -1
- package/dist/{chunk-GNXIA5WC.js → chunk-TVV7AE3G.js} +2 -2
- package/dist/{chunk-2REGK4VO.js → chunk-U4SVWPLC.js} +11 -11
- package/dist/{chunk-5BA36MSQ.js → chunk-UMXXZ6OX.js} +1 -1
- package/dist/{chunk-HQQWAVL6.js → chunk-UNO3TSAT.js} +1 -1
- package/dist/{chunk-MGSVPAVF.js → chunk-USSUE7J2.js} +5 -5
- package/dist/{chunk-WHTGWLGJ.js → chunk-UTGP4X74.js} +1 -1
- package/dist/{chunk-XMZQW5G5.js → chunk-V5RHOS43.js} +8 -8
- package/dist/{chunk-Z2AVP3QL.js → chunk-VB6GGRIA.js} +16 -3
- package/dist/{chunk-RSXTLOY3.js → chunk-VY5XWTW7.js} +1 -1
- package/dist/{chunk-VVCRJ46V.js → chunk-WEUPM3IN.js} +4 -4
- package/dist/{chunk-RZHIYTI3.js → chunk-WK33IBKY.js} +10 -1
- package/dist/{chunk-I2GML5Z7.js → chunk-XOWRUT4X.js} +2 -2
- package/dist/{chunk-AZLZOG5N.js → chunk-XYNEAJDF.js} +1 -1
- package/dist/{chunk-K7Y3EAGL.js → chunk-Y5RNFM44.js} +2 -2
- package/dist/{chunk-GSDVHR43.js → chunk-YJCH35J4.js} +5 -3
- package/dist/{chunk-T77N7C3M.js → chunk-YKPRNV6J.js} +2 -2
- package/dist/chunk-YOZ6WDP3.js +103 -0
- package/dist/{chunk-7DPZMROX.js → chunk-YRFWPBGX.js} +2 -2
- package/dist/{chunk-F5SHFZUA.js → chunk-YTBVILAH.js} +1 -1
- package/dist/{chunk-IPTEXVQG.js → chunk-Z5IENUYV.js} +3 -3
- package/dist/{chunk-MQSTE4WH.js → chunk-ZBWKJ42J.js} +3 -3
- package/dist/{chunk-GBJ3OT4D.js → chunk-ZC7OR65K.js} +7 -5
- package/dist/{chunk-7U62OZSD.js → chunk-ZDDMPGN4.js} +2 -2
- package/dist/{chunk-5DFZE5OJ.js → chunk-ZPKQT6X2.js} +16 -6
- package/dist/{chunk-SX34YV6L.js → chunk-ZV5Y5JBE.js} +2 -2
- package/dist/config/index.js +5 -5
- package/dist/containers/client.js +6 -6
- package/dist/containers/exec.js +6 -6
- package/dist/containers/lifecycle.js +41 -41
- package/dist/containers/setup.js +9 -9
- package/dist/db/agents.js +6 -6
- package/dist/db/api_keys.js +5 -5
- package/dist/db/audit.js +3 -3
- package/dist/db/batch.js +10 -10
- package/dist/db/client.js +2 -2
- package/dist/db/credentials.js +5 -3
- package/dist/db/drizzle.js +4 -4
- package/dist/db/environments.js +6 -6
- package/dist/db/events.js +5 -5
- package/dist/db/files.js +5 -5
- package/dist/db/memory.js +5 -5
- package/dist/db/migrations.js +1 -1
- package/dist/db/proxy.js +5 -5
- package/dist/db/schema.js +1 -1
- package/dist/db/session-resources.js +5 -5
- package/dist/db/sessions.js +8 -8
- package/dist/db/skills.js +5 -5
- package/dist/db/sync.js +5 -5
- package/dist/db/tenants.js +3 -3
- package/dist/db/threads.js +7 -7
- package/dist/db/traces.js +5 -5
- package/dist/db/upstream_keys.js +3 -3
- package/dist/db/user-profiles.js +17 -0
- package/dist/db/vaults.js +6 -6
- package/dist/db/work.js +5 -5
- package/dist/dreaming/review.js +11 -11
- package/dist/handlers/agents.js +58 -57
- package/dist/handlers/api_keys.js +59 -58
- package/dist/handlers/audit.js +59 -58
- package/dist/handlers/batch.js +59 -58
- package/dist/handlers/credentials.js +61 -58
- package/dist/handlers/enrollment.js +103 -0
- package/dist/handlers/environments.js +59 -58
- package/dist/handlers/events.js +62 -61
- package/dist/handlers/files.js +59 -58
- package/dist/handlers/index.js +145 -126
- package/dist/handlers/license.js +58 -57
- package/dist/handlers/memory.js +60 -59
- package/dist/handlers/metrics.js +58 -57
- package/dist/handlers/models.js +59 -58
- package/dist/handlers/openapi.js +3 -3
- package/dist/handlers/providers.js +58 -57
- package/dist/handlers/resources.js +58 -57
- package/dist/handlers/sessions.js +62 -61
- package/dist/handlers/settings.js +58 -57
- package/dist/handlers/skills-write.js +59 -58
- package/dist/handlers/skills.js +59 -58
- package/dist/handlers/stream.js +58 -57
- package/dist/handlers/tenants.js +59 -58
- package/dist/handlers/threads.js +59 -58
- package/dist/handlers/traces.js +59 -58
- package/dist/handlers/upstream_keys.js +61 -60
- package/dist/handlers/user-profiles.js +107 -0
- package/dist/handlers/vaults.js +58 -57
- package/dist/handlers/whoami.js +58 -57
- package/dist/handlers/work.js +59 -58
- package/dist/http.js +57 -56
- package/dist/index.js +68 -67
- package/dist/init.js +54 -53
- package/dist/lib/model-registry.js +6 -6
- package/dist/lib/skills-cache.js +6 -6
- package/dist/observability/otlp.js +12 -12
- package/dist/observability/redactor.js +8 -8
- package/dist/openapi/schemas.js +1 -1
- package/dist/openapi/spec.js +2 -2
- package/dist/providers/fly.js +5 -5
- package/dist/providers/modal.js +5 -5
- package/dist/providers/registry.js +6 -6
- package/dist/providers/resolve-secrets.js +7 -7
- package/dist/providers/sprites.js +7 -7
- package/dist/providers/upstream-keys.js +12 -12
- package/dist/providers/vercel.js +6 -6
- package/dist/proxy/forward.js +6 -6
- package/dist/queue/index.js +6 -6
- package/dist/sessions/bus.js +10 -10
- package/dist/sessions/driver.js +47 -46
- package/dist/sessions/grader.js +5 -5
- package/dist/sessions/secrets.js +9 -8
- package/dist/sessions/sweeper.js +42 -42
- package/dist/sessions/threads.js +55 -47
- package/dist/shutdown.js +43 -43
- package/dist/sync/anthropic.js +10 -10
- package/dist/sync/container-file-sync.js +6 -6
- package/dist/sync/file-sync.js +17 -17
- package/dist/workers/runner.js +49 -48
- package/package.json +1 -1
- package/dist/chunk-6KWJASEO.js +0 -21
- package/dist/{dist-EY25RQ2S.js → dist-3ZD3ELTH.js} +3 -3
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
reportUpstreamFailure,
|
|
3
3
|
reportUpstreamSuccess,
|
|
4
4
|
resolveAnthropicKey
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HWWFRSAX.js";
|
|
6
6
|
import {
|
|
7
7
|
resolveRemoteSessionId
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZBWKJ42J.js";
|
|
9
9
|
import {
|
|
10
10
|
assertResourceTenant
|
|
11
11
|
} from "./chunk-23UKWXJH.js";
|
|
@@ -20,53 +20,53 @@ import {
|
|
|
20
20
|
listMemoryStores,
|
|
21
21
|
searchMemories,
|
|
22
22
|
updateMemory
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-TVV7AE3G.js";
|
|
24
24
|
import {
|
|
25
25
|
jsonOk,
|
|
26
26
|
paginatedOk,
|
|
27
27
|
routeWrap
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-XOWRUT4X.js";
|
|
29
29
|
import {
|
|
30
30
|
forwardToAnthropic
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import {
|
|
33
|
-
enqueueTurn
|
|
34
|
-
} from "./chunk-SKVAM5H2.js";
|
|
31
|
+
} from "./chunk-JFHYXFAL.js";
|
|
35
32
|
import {
|
|
36
33
|
runTurn,
|
|
37
34
|
writePermissionResponse
|
|
38
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-AKGWEACL.js";
|
|
36
|
+
import {
|
|
37
|
+
enqueueTurn
|
|
38
|
+
} from "./chunk-B3W3E5CS.js";
|
|
39
39
|
import {
|
|
40
40
|
getProxiedTenantId,
|
|
41
41
|
isProxied
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-DZKBUOYU.js";
|
|
43
43
|
import {
|
|
44
44
|
getActor
|
|
45
45
|
} from "./chunk-LAWTTG2E.js";
|
|
46
46
|
import {
|
|
47
47
|
appendEvent
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-RES4BCTF.js";
|
|
49
49
|
import {
|
|
50
50
|
bumpSessionStats,
|
|
51
51
|
getSession,
|
|
52
52
|
getSessionRow,
|
|
53
53
|
setOutcomeCriteria,
|
|
54
54
|
updateSessionMutable
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-ZC7OR65K.js";
|
|
56
56
|
import {
|
|
57
57
|
listEvents,
|
|
58
58
|
rowToManagedEvent
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-OEFJPZYH.js";
|
|
60
60
|
import {
|
|
61
61
|
getEnvironment,
|
|
62
62
|
getEnvironmentRow
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-NSUVDKNC.js";
|
|
64
64
|
import {
|
|
65
65
|
getAgent
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-6U6HEVSN.js";
|
|
67
67
|
import {
|
|
68
68
|
getConfig
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-6EIONZ7F.js";
|
|
70
70
|
import {
|
|
71
71
|
init_clock,
|
|
72
72
|
nowMs
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
import {
|
|
75
75
|
getDb,
|
|
76
76
|
init_client
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-AGIXZFHQ.js";
|
|
78
78
|
import {
|
|
79
79
|
badRequest,
|
|
80
80
|
notFound
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
listTraces
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UMXXZ6OX.js";
|
|
4
4
|
import {
|
|
5
5
|
jsonOk,
|
|
6
6
|
routeWrap
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XOWRUT4X.js";
|
|
8
8
|
import {
|
|
9
9
|
exportTrace
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2KF2TIEY.js";
|
|
11
11
|
import {
|
|
12
12
|
listEventsByTrace,
|
|
13
13
|
rowToManagedEvent
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-OEFJPZYH.js";
|
|
15
15
|
import {
|
|
16
16
|
badRequest,
|
|
17
17
|
notFound
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
disableUpstreamKey,
|
|
3
3
|
selectNextUpstreamKey
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ABUNDZCE.js";
|
|
5
5
|
import {
|
|
6
6
|
listEntries
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MUARVVXF.js";
|
|
8
8
|
import {
|
|
9
9
|
getSession
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZC7OR65K.js";
|
|
11
11
|
import {
|
|
12
12
|
getConfig
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-6EIONZ7F.js";
|
|
14
14
|
|
|
15
15
|
// src/providers/upstream-keys.ts
|
|
16
16
|
var CONSECUTIVE_FAIL_THRESHOLD = 3;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSession
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZC7OR65K.js";
|
|
4
4
|
import {
|
|
5
5
|
createEnvironment,
|
|
6
6
|
deleteEnvironment,
|
|
7
7
|
getEnvironment
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-NSUVDKNC.js";
|
|
9
9
|
import {
|
|
10
10
|
archiveAgent,
|
|
11
11
|
createAgent,
|
|
12
12
|
getAgent
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-6U6HEVSN.js";
|
|
14
14
|
import {
|
|
15
15
|
getDrizzle,
|
|
16
16
|
init_drizzle
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ZDDMPGN4.js";
|
|
18
18
|
|
|
19
19
|
// src/db/batch.ts
|
|
20
20
|
init_drizzle();
|
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
getMemoryByPath,
|
|
9
9
|
getMemoryStore,
|
|
10
10
|
listMemories
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-TVV7AE3G.js";
|
|
12
12
|
import {
|
|
13
13
|
listSessions
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ZC7OR65K.js";
|
|
15
15
|
import {
|
|
16
16
|
listEvents
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-OEFJPZYH.js";
|
|
18
18
|
import {
|
|
19
19
|
init_clock,
|
|
20
20
|
nowMs
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createPiTranslator
|
|
3
|
+
} from "./chunk-B6E6BVNK.js";
|
|
1
4
|
import {
|
|
2
5
|
buildPiArgs
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6SD6MC2B.js";
|
|
4
7
|
import {
|
|
5
8
|
buildPiAuthEnv,
|
|
6
9
|
validatePiRuntime
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-T2PXAQND.js";
|
|
8
11
|
import {
|
|
9
12
|
preparePiOnSandbox
|
|
10
13
|
} from "./chunk-CMOU2OFW.js";
|
|
11
|
-
import {
|
|
12
|
-
createPiTranslator
|
|
13
|
-
} from "./chunk-B6E6BVNK.js";
|
|
14
14
|
import {
|
|
15
15
|
PI_WRAPPER_PATH
|
|
16
16
|
} from "./chunk-OGA7KDQZ.js";
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
tenantFilter
|
|
3
|
+
} from "./chunk-23UKWXJH.js";
|
|
4
|
+
import {
|
|
5
|
+
jsonOk,
|
|
6
|
+
routeWrap
|
|
7
|
+
} from "./chunk-XOWRUT4X.js";
|
|
8
|
+
import {
|
|
9
|
+
getUserProfile,
|
|
10
|
+
updateUserProfile
|
|
11
|
+
} from "./chunk-YOZ6WDP3.js";
|
|
12
|
+
import {
|
|
13
|
+
createCredential,
|
|
14
|
+
getCredential,
|
|
15
|
+
updateCredential
|
|
16
|
+
} from "./chunk-WK33IBKY.js";
|
|
17
|
+
import {
|
|
18
|
+
badRequest,
|
|
19
|
+
notFound
|
|
20
|
+
} from "./chunk-EZYKRG4W.js";
|
|
21
|
+
|
|
22
|
+
// src/handlers/enrollment.ts
|
|
23
|
+
import { z } from "zod";
|
|
24
|
+
import { randomBytes } from "crypto";
|
|
25
|
+
var pendingEnrollments = /* @__PURE__ */ new Map();
|
|
26
|
+
setInterval(() => {
|
|
27
|
+
const cutoff = Date.now() - 10 * 6e4;
|
|
28
|
+
for (const [state, enrollment] of pendingEnrollments) {
|
|
29
|
+
if (enrollment.createdAt < cutoff) pendingEnrollments.delete(state);
|
|
30
|
+
}
|
|
31
|
+
}, 6e4);
|
|
32
|
+
var EnrollmentSchema = z.object({
|
|
33
|
+
vault_id: z.string().min(1),
|
|
34
|
+
credential_id: z.string().optional(),
|
|
35
|
+
// update existing credential, or omit to create new
|
|
36
|
+
display_name: z.string().min(1).optional(),
|
|
37
|
+
// required when creating new
|
|
38
|
+
authorize_url: z.string().url(),
|
|
39
|
+
token_endpoint: z.string().url(),
|
|
40
|
+
client_id: z.string().min(1),
|
|
41
|
+
client_secret: z.string().optional(),
|
|
42
|
+
scope: z.string().optional(),
|
|
43
|
+
redirect_uri: z.string().url().optional()
|
|
44
|
+
});
|
|
45
|
+
function handleEnrollmentUrl(request, profileId) {
|
|
46
|
+
return routeWrap(request, async ({ auth }) => {
|
|
47
|
+
const profile = getUserProfile(profileId);
|
|
48
|
+
if (!profile) throw notFound(`user profile not found: ${profileId}`);
|
|
49
|
+
const filter = tenantFilter(auth);
|
|
50
|
+
if (filter && profile.tenant_id !== filter) {
|
|
51
|
+
throw notFound(`user profile not found: ${profileId}`);
|
|
52
|
+
}
|
|
53
|
+
const body = await request.json().catch(() => null);
|
|
54
|
+
const parsed = EnrollmentSchema.safeParse(body);
|
|
55
|
+
if (!parsed.success) {
|
|
56
|
+
throw badRequest(`invalid body: ${parsed.error.issues.map((i) => i.message).join("; ")}`);
|
|
57
|
+
}
|
|
58
|
+
const data = parsed.data;
|
|
59
|
+
if (data.credential_id) {
|
|
60
|
+
const cred = getCredential(data.credential_id);
|
|
61
|
+
if (!cred || cred.vault_id !== data.vault_id) {
|
|
62
|
+
throw badRequest(`credential not found: ${data.credential_id}`);
|
|
63
|
+
}
|
|
64
|
+
} else if (!data.display_name) {
|
|
65
|
+
throw badRequest("display_name is required when creating a new credential");
|
|
66
|
+
}
|
|
67
|
+
const state = randomBytes(32).toString("hex");
|
|
68
|
+
const reqUrl = new URL(request.url);
|
|
69
|
+
const redirectUri = data.redirect_uri || `${reqUrl.origin}/v1/oauth/callback`;
|
|
70
|
+
pendingEnrollments.set(state, {
|
|
71
|
+
profileId,
|
|
72
|
+
vaultId: data.vault_id,
|
|
73
|
+
credentialId: data.credential_id ?? null,
|
|
74
|
+
tokenEndpoint: data.token_endpoint,
|
|
75
|
+
clientId: data.client_id,
|
|
76
|
+
clientSecret: data.client_secret,
|
|
77
|
+
scope: data.scope,
|
|
78
|
+
redirectUri,
|
|
79
|
+
createdAt: Date.now()
|
|
80
|
+
});
|
|
81
|
+
const params = new URLSearchParams({
|
|
82
|
+
response_type: "code",
|
|
83
|
+
client_id: data.client_id,
|
|
84
|
+
redirect_uri: redirectUri,
|
|
85
|
+
state,
|
|
86
|
+
...data.scope ? { scope: data.scope } : {}
|
|
87
|
+
});
|
|
88
|
+
const url = `${data.authorize_url}?${params.toString()}`;
|
|
89
|
+
return jsonOk({
|
|
90
|
+
type: "enrollment_url",
|
|
91
|
+
url,
|
|
92
|
+
state,
|
|
93
|
+
redirect_uri: redirectUri,
|
|
94
|
+
expires_in: 600
|
|
95
|
+
// 10 minutes
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
async function handleOAuthCallback(request) {
|
|
100
|
+
const { ensureInitialized } = await import("./init.js");
|
|
101
|
+
await ensureInitialized();
|
|
102
|
+
try {
|
|
103
|
+
const url = new URL(request.url);
|
|
104
|
+
const code = url.searchParams.get("code");
|
|
105
|
+
const state = url.searchParams.get("state");
|
|
106
|
+
const error = url.searchParams.get("error");
|
|
107
|
+
if (error) {
|
|
108
|
+
return new Response(
|
|
109
|
+
`<html><body><h2>Authorization failed</h2><p>${error}</p></body></html>`,
|
|
110
|
+
{ status: 400, headers: { "Content-Type": "text/html" } }
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
if (!code || !state) {
|
|
114
|
+
return new Response(
|
|
115
|
+
`<html><body><h2>Missing code or state parameter</h2></body></html>`,
|
|
116
|
+
{ status: 400, headers: { "Content-Type": "text/html" } }
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
const enrollment = pendingEnrollments.get(state);
|
|
120
|
+
if (!enrollment) {
|
|
121
|
+
return new Response(
|
|
122
|
+
`<html><body><h2>Invalid or expired enrollment state</h2><p>Please restart the enrollment process.</p></body></html>`,
|
|
123
|
+
{ status: 400, headers: { "Content-Type": "text/html" } }
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
pendingEnrollments.delete(state);
|
|
127
|
+
const body = new URLSearchParams({
|
|
128
|
+
grant_type: "authorization_code",
|
|
129
|
+
code,
|
|
130
|
+
client_id: enrollment.clientId,
|
|
131
|
+
redirect_uri: enrollment.redirectUri,
|
|
132
|
+
...enrollment.scope ? { scope: enrollment.scope } : {}
|
|
133
|
+
});
|
|
134
|
+
if (enrollment.clientSecret) {
|
|
135
|
+
body.set("client_secret", enrollment.clientSecret);
|
|
136
|
+
}
|
|
137
|
+
const tokenRes = await fetch(enrollment.tokenEndpoint, {
|
|
138
|
+
method: "POST",
|
|
139
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
140
|
+
body: body.toString(),
|
|
141
|
+
signal: AbortSignal.timeout(15e3)
|
|
142
|
+
});
|
|
143
|
+
if (!tokenRes.ok) {
|
|
144
|
+
const errText = await tokenRes.text().catch(() => "");
|
|
145
|
+
return new Response(
|
|
146
|
+
`<html><body><h2>Token exchange failed</h2><p>${tokenRes.status}: ${errText.slice(0, 200)}</p></body></html>`,
|
|
147
|
+
{ status: 502, headers: { "Content-Type": "text/html" } }
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
const tokens = await tokenRes.json();
|
|
151
|
+
let credentialId;
|
|
152
|
+
const expiresAt = tokens.expires_in ? new Date(Date.now() + tokens.expires_in * 1e3).toISOString() : null;
|
|
153
|
+
const refreshConfig = tokens.refresh_token ? {
|
|
154
|
+
token_endpoint: enrollment.tokenEndpoint,
|
|
155
|
+
client_id: enrollment.clientId,
|
|
156
|
+
scope: enrollment.scope ?? tokens.scope,
|
|
157
|
+
refresh_token: tokens.refresh_token,
|
|
158
|
+
...enrollment.clientSecret ? { token_endpoint_auth: { type: "client_secret_post", client_secret: enrollment.clientSecret } } : {}
|
|
159
|
+
} : null;
|
|
160
|
+
if (enrollment.credentialId) {
|
|
161
|
+
updateCredential(enrollment.credentialId, {
|
|
162
|
+
auth_type: "mcp_oauth",
|
|
163
|
+
token: tokens.access_token,
|
|
164
|
+
expires_at: expiresAt,
|
|
165
|
+
refresh_config: refreshConfig
|
|
166
|
+
});
|
|
167
|
+
credentialId = enrollment.credentialId;
|
|
168
|
+
} else {
|
|
169
|
+
const profile2 = getUserProfile(enrollment.profileId);
|
|
170
|
+
const displayName = `oauth-${enrollment.clientId}-${Date.now()}`;
|
|
171
|
+
const cred = createCredential({
|
|
172
|
+
vault_id: enrollment.vaultId,
|
|
173
|
+
display_name: displayName,
|
|
174
|
+
auth_type: "mcp_oauth",
|
|
175
|
+
token: tokens.access_token,
|
|
176
|
+
expires_at: expiresAt,
|
|
177
|
+
refresh_config: refreshConfig
|
|
178
|
+
});
|
|
179
|
+
credentialId = cred.id;
|
|
180
|
+
}
|
|
181
|
+
const profile = getUserProfile(enrollment.profileId);
|
|
182
|
+
if (profile) {
|
|
183
|
+
const existingGrant = profile.trust_grants.find(
|
|
184
|
+
(g) => g.vault_id === enrollment.vaultId && g.credential_id === credentialId
|
|
185
|
+
);
|
|
186
|
+
if (!existingGrant) {
|
|
187
|
+
const newGrants = [
|
|
188
|
+
...profile.trust_grants,
|
|
189
|
+
{ type: "vault_credential", vault_id: enrollment.vaultId, credential_id: credentialId }
|
|
190
|
+
];
|
|
191
|
+
updateUserProfile(enrollment.profileId, { trust_grants: newGrants });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return new Response(
|
|
195
|
+
`<html><body><h2>Enrollment complete</h2><p>Credential ${credentialId} has been linked to your profile. You can close this window.</p></body></html>`,
|
|
196
|
+
{ status: 200, headers: { "Content-Type": "text/html" } }
|
|
197
|
+
);
|
|
198
|
+
} catch (err) {
|
|
199
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
200
|
+
return new Response(
|
|
201
|
+
`<html><body><h2>Enrollment error</h2><p>${msg}</p></body></html>`,
|
|
202
|
+
{ status: 500, headers: { "Content-Type": "text/html" } }
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export {
|
|
208
|
+
handleEnrollmentUrl,
|
|
209
|
+
handleOAuthCallback
|
|
210
|
+
};
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
getDrizzle,
|
|
12
12
|
init_drizzle
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ZDDMPGN4.js";
|
|
14
14
|
import {
|
|
15
15
|
schema_exports
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-CXYMVLYK.js";
|
|
17
17
|
|
|
18
18
|
// src/db/work.ts
|
|
19
19
|
init_drizzle();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BatchError,
|
|
3
3
|
executeBatch
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-I2RVN7CP.js";
|
|
5
5
|
import {
|
|
6
6
|
jsonOk,
|
|
7
7
|
routeWrap
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XOWRUT4X.js";
|
|
9
9
|
import {
|
|
10
10
|
badRequest
|
|
11
11
|
} from "./chunk-EZYKRG4W.js";
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildClaudeArgs,
|
|
3
|
-
buildClaudeAuthEnv
|
|
4
|
-
} from "./chunk-GSDVHR43.js";
|
|
5
|
-
import {
|
|
6
|
-
PERMISSION_BRIDGE_DIR,
|
|
7
|
-
PERMISSION_HOOK_SCRIPT_PATH,
|
|
8
|
-
buildPermissionHooksConfig,
|
|
9
|
-
generatePermissionHookScript
|
|
10
|
-
} from "./chunk-CY6AWCC6.js";
|
|
11
1
|
import {
|
|
12
2
|
TOOL_BRIDGE_DIR,
|
|
13
3
|
TOOL_BRIDGE_SCRIPT_PATH,
|
|
@@ -19,13 +9,23 @@ import {
|
|
|
19
9
|
import {
|
|
20
10
|
createClaudeTranslator
|
|
21
11
|
} from "./chunk-D6RQPBRG.js";
|
|
12
|
+
import {
|
|
13
|
+
buildClaudeArgs,
|
|
14
|
+
buildClaudeAuthEnv
|
|
15
|
+
} from "./chunk-YJCH35J4.js";
|
|
16
|
+
import {
|
|
17
|
+
PERMISSION_BRIDGE_DIR,
|
|
18
|
+
PERMISSION_HOOK_SCRIPT_PATH,
|
|
19
|
+
buildPermissionHooksConfig,
|
|
20
|
+
generatePermissionHookScript
|
|
21
|
+
} from "./chunk-CY6AWCC6.js";
|
|
22
22
|
import {
|
|
23
23
|
CLAUDE_WRAPPER_PATH,
|
|
24
24
|
installClaudeWrapper
|
|
25
25
|
} from "./chunk-J6T3W6RY.js";
|
|
26
26
|
import {
|
|
27
27
|
getConfig
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-6EIONZ7F.js";
|
|
29
29
|
|
|
30
30
|
// src/backends/claude/index.ts
|
|
31
31
|
function buildTurn(input) {
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
archiveThread,
|
|
3
3
|
getThread,
|
|
4
4
|
listThreads
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-Z5IENUYV.js";
|
|
6
6
|
import {
|
|
7
7
|
assertResourceTenant
|
|
8
8
|
} from "./chunk-23UKWXJH.js";
|
|
@@ -10,21 +10,21 @@ import {
|
|
|
10
10
|
jsonOk,
|
|
11
11
|
paginatedOk,
|
|
12
12
|
routeWrap
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XOWRUT4X.js";
|
|
14
14
|
import {
|
|
15
15
|
subscribe
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-RES4BCTF.js";
|
|
17
17
|
import {
|
|
18
18
|
getSession
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-ZC7OR65K.js";
|
|
20
20
|
import {
|
|
21
21
|
listEvents,
|
|
22
22
|
rowToManagedEvent
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-OEFJPZYH.js";
|
|
24
24
|
import {
|
|
25
25
|
getDb,
|
|
26
26
|
init_client
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-AGIXZFHQ.js";
|
|
28
28
|
import {
|
|
29
29
|
badRequest,
|
|
30
30
|
notFound
|