@agentstep/agent-sdk 0.5.28 → 0.5.34
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-33QZ6KIY.js → chunk-25E64UIV.js} +5 -5
- package/dist/{chunk-PZKWZKRP.js → chunk-2KF2TIEY.js} +5 -5
- package/dist/{chunk-CXXL77ER.js → chunk-2R4IT7HG.js} +61 -4
- package/dist/{chunk-N627DRI6.js → chunk-3EI7IPMI.js} +3 -3
- package/dist/{chunk-Z25QQE5Z.js → chunk-3EWEKBVC.js} +4 -4
- package/dist/{chunk-V4DEOZFK.js → chunk-3LYNN5VT.js} +5 -5
- package/dist/{chunk-LJNLU5PQ.js → chunk-3NUTTKE5.js} +2 -2
- package/dist/{chunk-DI5WC2SQ.js → chunk-4EKHW6VS.js} +2 -2
- package/dist/{chunk-MZ6HBYGV.js → chunk-65XY7HRS.js} +7 -7
- package/dist/{chunk-KHTLT44I.js → chunk-6CODFATQ.js} +3 -3
- package/dist/{chunk-US26CY2Y.js → chunk-6EIONZ7F.js} +2 -2
- package/dist/chunk-6NEWWPL4.js +210 -0
- package/dist/{chunk-TFTJ734B.js → chunk-6NFK5RJX.js} +2 -2
- package/dist/chunk-6SD6MC2B.js +29 -0
- package/dist/{chunk-ENFWZ2QM.js → chunk-6U6HEVSN.js} +7 -3
- package/dist/{chunk-CXIP6H55.js → chunk-75US4UAE.js} +2 -2
- package/dist/{chunk-UB7GS7XT.js → chunk-A3FQHVUG.js} +7 -7
- package/dist/{chunk-ZP5QO5BR.js → chunk-ABUNDZCE.js} +1 -1
- package/dist/{chunk-QCP37SCU.js → chunk-AD2WPGDN.js} +8 -8
- package/dist/{chunk-Q62QJXGO.js → chunk-AGIXZFHQ.js} +1 -1
- package/dist/{chunk-NKOGWVP3.js → chunk-AUEKXYNE.js} +4 -4
- package/dist/{chunk-SKVAM5H2.js → chunk-B3W3E5CS.js} +1 -1
- package/dist/chunk-B5RR422E.js +0 -0
- package/dist/{chunk-IWI74DWW.js → chunk-BSAF4YJB.js} +51 -14
- package/dist/{chunk-CVYNMYIE.js → chunk-CWB2DQN5.js} +3 -3
- package/dist/{chunk-4ENK7S24.js → chunk-CXYMVLYK.js} +4 -0
- package/dist/{chunk-MNZB2OWP.js → chunk-CZ4N5FJW.js} +2 -2
- package/dist/{chunk-R37QM2U4.js → chunk-DF34ESOO.js} +1 -1
- package/dist/{chunk-GKNBECPD.js → chunk-DZKBUOYU.js} +2 -2
- package/dist/{chunk-CACVB5PH.js → chunk-FCPZF7KJ.js} +1 -1
- package/dist/{chunk-FC3UAHXM.js → chunk-FDLQ3IUB.js} +1 -1
- package/dist/{chunk-HVCY7DET.js → chunk-FHOJOLXU.js} +2 -2
- package/dist/{chunk-5AV732JY.js → chunk-GABMXDZZ.js} +2 -2
- package/dist/{chunk-LSMTQBMW.js → chunk-GBBQD6VY.js} +2 -2
- package/dist/{chunk-FDL2JHXO.js → chunk-GCT7A5KR.js} +2 -2
- package/dist/{chunk-QBZMVYDV.js → chunk-GFZ2WIVH.js} +4 -4
- package/dist/{chunk-ANTKOI3K.js → chunk-HHLVVJGT.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-3V4BPIBU.js → chunk-JDAOTVWV.js} +2 -2
- package/dist/{chunk-A4GJADRQ.js → chunk-JF777FWD.js} +2 -2
- package/dist/{chunk-IDQKHWWN.js → chunk-JFHYXFAL.js} +1 -1
- package/dist/{chunk-WLCI57J6.js → chunk-JIXRTWYL.js} +4 -4
- package/dist/{chunk-WG3N6VUA.js → chunk-JN3DHH7Z.js} +11 -11
- package/dist/{chunk-FQQ2R6FA.js → chunk-JNSJKHYX.js} +1 -1
- package/dist/{chunk-HPL2MQGY.js → chunk-K3LM6O44.js} +6 -6
- package/dist/{chunk-7DPZMROX.js → chunk-K5J4IN2S.js} +2 -2
- package/dist/{chunk-TJORQTH6.js → chunk-KGOOCFQY.js} +1 -1
- package/dist/{chunk-BYUIOMPX.js → chunk-KYKVHH7I.js} +23 -23
- package/dist/{chunk-ZM33GAEB.js → chunk-LKHJLSYG.js} +7 -7
- package/dist/{chunk-RKPT6O7I.js → chunk-LR6FK2J7.js} +5 -5
- package/dist/{chunk-MNW6D7T4.js → chunk-M72ERPMT.js} +1 -1
- package/dist/{chunk-IC5ZTBAW.js → chunk-MUARVVXF.js} +3 -3
- package/dist/{chunk-RRP4F6XC.js → chunk-NQ6BN7WH.js} +16 -6
- package/dist/{chunk-BRULBMRN.js → chunk-NSUVDKNC.js} +3 -3
- package/dist/chunk-OANORRFX.js +276 -0
- package/dist/{chunk-IS6CQPAQ.js → chunk-OEFJPZYH.js} +3 -3
- package/dist/{chunk-4BJTLMHV.js → chunk-OEYLPPID.js} +17 -17
- package/dist/{chunk-G6XFFNCQ.js → chunk-P7V3S2T3.js} +18 -18
- 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-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-CBPO2P4I.js → chunk-SAI6LBXW.js} +2 -2
- package/dist/{chunk-YMKQJY5F.js → chunk-SIO4LO2M.js} +1 -1
- package/dist/{chunk-QSRH4XUG.js → chunk-SUEPFZN2.js} +1 -1
- package/dist/{chunk-IITCQTBZ.js → chunk-T2PXAQND.js} +1 -1
- package/dist/{chunk-D3LKWVPA.js → chunk-TTDMQ54U.js} +2 -2
- package/dist/{chunk-GNXIA5WC.js → chunk-TVV7AE3G.js} +2 -2
- package/dist/{chunk-5BA36MSQ.js → chunk-UMXXZ6OX.js} +1 -1
- 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-TV6QMCDS.js → chunk-VQM2MCQR.js} +3 -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-QQGXM2OQ.js → chunk-XLMNSDUJ.js} +1 -1
- package/dist/{chunk-MAN6OCOP.js → chunk-XXAO5YYL.js} +3 -3
- package/dist/{chunk-AZLZOG5N.js → chunk-XYNEAJDF.js} +1 -1
- 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-F5SHFZUA.js → chunk-YTBVILAH.js} +1 -1
- package/dist/{chunk-IPTEXVQG.js → chunk-Z5IENUYV.js} +3 -3
- package/dist/{chunk-KD5Y4XSU.js → chunk-ZACPJA3G.js} +2 -2
- package/dist/{chunk-NOHH2ZH7.js → chunk-ZAUWB5DQ.js} +6 -6
- package/dist/{chunk-MQSTE4WH.js → chunk-ZBWKJ42J.js} +3 -3
- package/dist/{chunk-GBJ3OT4D.js → chunk-ZC7OR65K.js} +7 -5
- package/dist/{chunk-2REGK4VO.js → chunk-ZCCHLDLC.js} +11 -11
- package/dist/{chunk-7U62OZSD.js → chunk-ZDDMPGN4.js} +2 -2
- package/dist/chunk-ZHEE6UTX.js +108 -0
- 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/google-compat/index.js +101 -0
- package/dist/handlers/google-compat/interactions.js +100 -0
- package/dist/handlers/google-compat/types.js +0 -0
- package/dist/handlers/index.js +150 -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 +5 -5
- 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
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
jsonOk,
|
|
3
3
|
routeWrap
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4EKHW6VS.js";
|
|
5
5
|
import {
|
|
6
6
|
resolveContainerProvider
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XLMNSDUJ.js";
|
|
8
8
|
import {
|
|
9
9
|
getConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6EIONZ7F.js";
|
|
11
11
|
|
|
12
12
|
// src/handlers/providers.ts
|
|
13
13
|
var LOCAL_PROVIDERS = ["docker", "apple-container", "podman"];
|
|
@@ -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-4EKHW6VS.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
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-23UKWXJH.js";
|
|
7
7
|
import {
|
|
8
8
|
recordAudit
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-FDLQ3IUB.js";
|
|
10
10
|
import {
|
|
11
11
|
COMMUNITY_LIMITS,
|
|
12
12
|
hasFeature,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
jsonOk,
|
|
17
17
|
routeWrap
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-4EKHW6VS.js";
|
|
19
19
|
import {
|
|
20
20
|
createApiKey,
|
|
21
21
|
getApiKeyById,
|
|
@@ -23,14 +23,14 @@ import {
|
|
|
23
23
|
listApiKeys,
|
|
24
24
|
revokeApiKey,
|
|
25
25
|
updateApiKeyPermissions
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-3NUTTKE5.js";
|
|
27
27
|
import {
|
|
28
28
|
listSessionsByApiKey
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-ZC7OR65K.js";
|
|
30
30
|
import {
|
|
31
31
|
getDb,
|
|
32
32
|
init_client
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-AGIXZFHQ.js";
|
|
34
34
|
import {
|
|
35
35
|
badRequest,
|
|
36
36
|
forbidden,
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
getDrizzle,
|
|
11
11
|
init_drizzle
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZDDMPGN4.js";
|
|
13
13
|
import {
|
|
14
14
|
schema_exports
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-CXYMVLYK.js";
|
|
16
16
|
|
|
17
17
|
// src/db/api_keys.ts
|
|
18
18
|
init_drizzle();
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
} from "./chunk-D2XITRN6.js";
|
|
5
5
|
import {
|
|
6
6
|
authenticateAndIntercept
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-CWB2DQN5.js";
|
|
8
8
|
import {
|
|
9
9
|
checkAndBump
|
|
10
10
|
} from "./chunk-HVUWXUUI.js";
|
|
11
11
|
import {
|
|
12
12
|
ensureInitialized
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-P7V3S2T3.js";
|
|
14
14
|
import {
|
|
15
15
|
captureException
|
|
16
16
|
} from "./chunk-3MQ2FWXS.js";
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildFactoryArgs
|
|
3
|
+
} from "./chunk-TPMZO6S2.js";
|
|
4
|
+
import {
|
|
5
|
+
buildFactoryAuthEnv,
|
|
6
|
+
validateFactoryRuntime
|
|
7
|
+
} from "./chunk-M72ERPMT.js";
|
|
1
8
|
import {
|
|
2
9
|
prepareFactoryOnSandbox
|
|
3
10
|
} from "./chunk-AQHYCRTO.js";
|
|
@@ -7,13 +14,6 @@ import {
|
|
|
7
14
|
import {
|
|
8
15
|
FACTORY_WRAPPER_PATH
|
|
9
16
|
} from "./chunk-KJ2GJLPQ.js";
|
|
10
|
-
import {
|
|
11
|
-
buildFactoryArgs
|
|
12
|
-
} from "./chunk-TPMZO6S2.js";
|
|
13
|
-
import {
|
|
14
|
-
buildFactoryAuthEnv,
|
|
15
|
-
validateFactoryRuntime
|
|
16
|
-
} from "./chunk-MNW6D7T4.js";
|
|
17
17
|
import {
|
|
18
18
|
wrapPromptWithSystem
|
|
19
19
|
} from "./chunk-YE2RMJY7.js";
|
|
@@ -7,16 +7,16 @@ import {
|
|
|
7
7
|
pollWorkItem,
|
|
8
8
|
stopWorkItem,
|
|
9
9
|
updateWorkItemMetadata
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-JF777FWD.js";
|
|
11
11
|
import {
|
|
12
12
|
decodeCursor,
|
|
13
13
|
jsonOk,
|
|
14
14
|
paginatedOk,
|
|
15
15
|
routeWrap
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-4EKHW6VS.js";
|
|
17
17
|
import {
|
|
18
18
|
getEnvironment
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-NSUVDKNC.js";
|
|
20
20
|
import {
|
|
21
21
|
badRequest,
|
|
22
22
|
notFound
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
getDrizzle,
|
|
7
7
|
init_drizzle
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZDDMPGN4.js";
|
|
9
9
|
import {
|
|
10
10
|
schema_exports
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-CXYMVLYK.js";
|
|
12
12
|
|
|
13
13
|
// src/config/index.ts
|
|
14
14
|
init_drizzle();
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
tenantFilter
|
|
3
|
+
} from "./chunk-23UKWXJH.js";
|
|
4
|
+
import {
|
|
5
|
+
jsonOk,
|
|
6
|
+
routeWrap
|
|
7
|
+
} from "./chunk-4EKHW6VS.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
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
jsonOk,
|
|
3
3
|
routeWrap
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4EKHW6VS.js";
|
|
5
5
|
import {
|
|
6
6
|
readSetting,
|
|
7
7
|
writeSetting
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6EIONZ7F.js";
|
|
9
9
|
import {
|
|
10
10
|
badRequest
|
|
11
11
|
} from "./chunk-EZYKRG4W.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/backends/pi/args.ts
|
|
2
|
+
function normalizePiModel(model) {
|
|
3
|
+
if (model.includes("/")) return model;
|
|
4
|
+
if (model.startsWith("gemini-")) return `google/${model}`;
|
|
5
|
+
if (model.startsWith("claude-")) return `anthropic/${model}`;
|
|
6
|
+
if (model.startsWith("gpt-") || model.startsWith("o1-") || model.startsWith("o3-") || model.startsWith("o4-") || model.startsWith("chatgpt-")) return `openai/${model}`;
|
|
7
|
+
return model;
|
|
8
|
+
}
|
|
9
|
+
function buildPiArgs(input) {
|
|
10
|
+
const args = [
|
|
11
|
+
"-p",
|
|
12
|
+
"--mode",
|
|
13
|
+
"json",
|
|
14
|
+
"--no-extensions"
|
|
15
|
+
];
|
|
16
|
+
if (input.backendSessionId) {
|
|
17
|
+
args.push("--session", input.backendSessionId);
|
|
18
|
+
}
|
|
19
|
+
if (input.agent.model) {
|
|
20
|
+
const modelId = typeof input.agent.model === "string" ? input.agent.model : input.agent.model.id;
|
|
21
|
+
if (modelId) args.push("--model", normalizePiModel(modelId));
|
|
22
|
+
}
|
|
23
|
+
args.push(input.prompt);
|
|
24
|
+
return args;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
buildPiArgs
|
|
29
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_TENANT_ID
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YTBVILAH.js";
|
|
4
4
|
import {
|
|
5
5
|
init_ids,
|
|
6
6
|
newId
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
getDrizzle,
|
|
15
15
|
init_drizzle
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-ZDDMPGN4.js";
|
|
17
17
|
import {
|
|
18
18
|
schema_exports
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-CXYMVLYK.js";
|
|
20
20
|
|
|
21
21
|
// src/db/agents.ts
|
|
22
22
|
init_drizzle();
|
|
@@ -38,6 +38,7 @@ function hydrate(row, ver) {
|
|
|
38
38
|
threadsEnabled = true;
|
|
39
39
|
callableAgents = multiagent.agents.filter((a) => a.type === "agent").map((a) => ({ type: "agent", id: a.id, version: a.version }));
|
|
40
40
|
}
|
|
41
|
+
const permissionPolicy = ver.permission_policy_json ? JSON.parse(ver.permission_policy_json) : null;
|
|
41
42
|
return {
|
|
42
43
|
type: "agent",
|
|
43
44
|
id: row.id,
|
|
@@ -57,6 +58,7 @@ function hydrate(row, ver) {
|
|
|
57
58
|
confirmation_mode: Boolean(ver.confirmation_mode),
|
|
58
59
|
callable_agents: callableAgents,
|
|
59
60
|
multiagent,
|
|
61
|
+
permission_policy: permissionPolicy,
|
|
60
62
|
skills: ver.skills_json ? JSON.parse(ver.skills_json) : [],
|
|
61
63
|
model_config: modelConfig,
|
|
62
64
|
fallback_json: row.fallback_json ?? null,
|
|
@@ -95,6 +97,7 @@ function createAgent(input) {
|
|
|
95
97
|
confirmation_mode: input.confirmation_mode ? 1 : 0,
|
|
96
98
|
callable_agents_json: input.callable_agents?.length ? JSON.stringify(input.callable_agents) : null,
|
|
97
99
|
multiagent_json: input.multiagent ? JSON.stringify(input.multiagent) : null,
|
|
100
|
+
permission_policy_json: input.permission_policy ? JSON.stringify(input.permission_policy) : null,
|
|
98
101
|
skills_json: JSON.stringify(input.skills ?? []),
|
|
99
102
|
model_config_json: JSON.stringify(input.model_config ?? {}),
|
|
100
103
|
created_at: now
|
|
@@ -148,6 +151,7 @@ function updateAgent(id, input) {
|
|
|
148
151
|
confirmation_mode: input.confirmation_mode !== void 0 ? input.confirmation_mode ? 1 : 0 : existing.confirmation_mode ? 1 : 0,
|
|
149
152
|
callable_agents_json: input.callable_agents !== void 0 ? input.callable_agents.length ? JSON.stringify(input.callable_agents) : null : existing.callable_agents.length ? JSON.stringify(existing.callable_agents) : null,
|
|
150
153
|
multiagent_json: input.multiagent !== void 0 ? input.multiagent ? JSON.stringify(input.multiagent) : null : existing.multiagent ? JSON.stringify(existing.multiagent) : null,
|
|
154
|
+
permission_policy_json: input.permission_policy !== void 0 ? input.permission_policy ? JSON.stringify(input.permission_policy) : null : existing.permission_policy ? JSON.stringify(existing.permission_policy) : null,
|
|
151
155
|
skills_json: JSON.stringify(input.skills ?? existing.skills),
|
|
152
156
|
model_config_json: JSON.stringify(input.model_config !== void 0 ? input.model_config : existing.model_config),
|
|
153
157
|
created_at: now
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getSkill,
|
|
7
7
|
getSkillVersion,
|
|
8
8
|
listSkillVersions
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TTDMQ54U.js";
|
|
10
10
|
import {
|
|
11
11
|
resolveCreateTenant
|
|
12
12
|
} from "./chunk-23UKWXJH.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
jsonOk,
|
|
16
16
|
paginatedOk,
|
|
17
17
|
routeWrap
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-4EKHW6VS.js";
|
|
19
19
|
import {
|
|
20
20
|
badRequest,
|
|
21
21
|
notFound
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createGeminiTranslator
|
|
3
|
-
} from "./chunk-S3JRZFF5.js";
|
|
4
|
-
import {
|
|
5
|
-
buildGeminiArgs
|
|
6
|
-
} from "./chunk-IBYOMAZ3.js";
|
|
7
1
|
import {
|
|
8
2
|
buildGeminiAuthEnv,
|
|
9
3
|
validateGeminiRuntime
|
|
10
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KGOOCFQY.js";
|
|
11
5
|
import {
|
|
12
6
|
prepareGeminiOnSandbox
|
|
13
7
|
} from "./chunk-PAQ2JFVD.js";
|
|
8
|
+
import {
|
|
9
|
+
createGeminiTranslator
|
|
10
|
+
} from "./chunk-S3JRZFF5.js";
|
|
14
11
|
import {
|
|
15
12
|
GEMINI_WRAPPER_PATH
|
|
16
13
|
} from "./chunk-PZ5EGY64.js";
|
|
14
|
+
import {
|
|
15
|
+
buildGeminiArgs
|
|
16
|
+
} from "./chunk-IBYOMAZ3.js";
|
|
17
17
|
import {
|
|
18
18
|
wrapPromptWithSystem
|
|
19
19
|
} from "./chunk-YE2RMJY7.js";
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveRemoteSessionId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZBWKJ42J.js";
|
|
4
4
|
import {
|
|
5
5
|
assertResourceTenant
|
|
6
6
|
} from "./chunk-23UKWXJH.js";
|
|
7
7
|
import {
|
|
8
8
|
authenticateAndIntercept
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-CWB2DQN5.js";
|
|
10
10
|
import {
|
|
11
11
|
forwardToAnthropic
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-JFHYXFAL.js";
|
|
13
13
|
import {
|
|
14
14
|
ensureInitialized
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-P7V3S2T3.js";
|
|
16
16
|
import {
|
|
17
17
|
getProxiedTenantId,
|
|
18
18
|
isProxied
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-DZKBUOYU.js";
|
|
20
20
|
import {
|
|
21
21
|
subscribe
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-RES4BCTF.js";
|
|
23
23
|
import {
|
|
24
24
|
getSession
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-ZC7OR65K.js";
|
|
26
26
|
import {
|
|
27
27
|
getDb,
|
|
28
28
|
init_client
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-AGIXZFHQ.js";
|
|
30
30
|
import {
|
|
31
31
|
notFound,
|
|
32
32
|
toResponse
|
|
@@ -2,19 +2,19 @@ import {
|
|
|
2
2
|
getSyncRow,
|
|
3
3
|
getSyncedRemoteId,
|
|
4
4
|
upsertSync
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZBWKJ42J.js";
|
|
6
6
|
import {
|
|
7
7
|
injectMcpAuthHeaders
|
|
8
8
|
} from "./chunk-DBFPJSOY.js";
|
|
9
9
|
import {
|
|
10
10
|
listEntries
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MUARVVXF.js";
|
|
12
12
|
import {
|
|
13
13
|
getEnvironment
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NSUVDKNC.js";
|
|
15
15
|
import {
|
|
16
16
|
getAgent
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-6U6HEVSN.js";
|
|
18
18
|
|
|
19
19
|
// src/sync/anthropic.ts
|
|
20
20
|
import { createHash } from "crypto";
|
|
File without changes
|