@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
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveCreateTenant,
|
|
3
|
+
tenantFilter
|
|
4
|
+
} from "./chunk-23UKWXJH.js";
|
|
5
|
+
import {
|
|
6
|
+
jsonOk,
|
|
7
|
+
paginatedOk,
|
|
8
|
+
routeWrap
|
|
9
|
+
} from "./chunk-XOWRUT4X.js";
|
|
10
|
+
import {
|
|
11
|
+
createUserProfile,
|
|
12
|
+
getUserProfile,
|
|
13
|
+
listUserProfiles,
|
|
14
|
+
updateUserProfile
|
|
15
|
+
} from "./chunk-YOZ6WDP3.js";
|
|
16
|
+
import {
|
|
17
|
+
badRequest,
|
|
18
|
+
notFound
|
|
19
|
+
} from "./chunk-EZYKRG4W.js";
|
|
20
|
+
|
|
21
|
+
// src/handlers/user-profiles.ts
|
|
22
|
+
import { z } from "zod";
|
|
23
|
+
var TrustGrantSchema = z.object({
|
|
24
|
+
type: z.literal("vault_credential"),
|
|
25
|
+
vault_id: z.string().min(1),
|
|
26
|
+
credential_id: z.string().min(1)
|
|
27
|
+
});
|
|
28
|
+
var CreateSchema = z.object({
|
|
29
|
+
external_id: z.string().max(256).optional(),
|
|
30
|
+
display_name: z.string().max(256).optional(),
|
|
31
|
+
trust_grants: z.array(TrustGrantSchema).max(50).optional()
|
|
32
|
+
});
|
|
33
|
+
var UpdateSchema = z.object({
|
|
34
|
+
external_id: z.string().max(256).nullish(),
|
|
35
|
+
display_name: z.string().max(256).nullish(),
|
|
36
|
+
trust_grants: z.array(TrustGrantSchema).max(50).optional()
|
|
37
|
+
});
|
|
38
|
+
function handleCreateUserProfile(request) {
|
|
39
|
+
return routeWrap(request, async ({ auth }) => {
|
|
40
|
+
const body = await request.json().catch(() => null);
|
|
41
|
+
const parsed = CreateSchema.safeParse(body);
|
|
42
|
+
if (!parsed.success) {
|
|
43
|
+
throw badRequest(`invalid body: ${parsed.error.issues.map((i) => i.message).join("; ")}`);
|
|
44
|
+
}
|
|
45
|
+
const tenantId = resolveCreateTenant(auth, void 0);
|
|
46
|
+
const profile = createUserProfile({
|
|
47
|
+
external_id: parsed.data.external_id,
|
|
48
|
+
display_name: parsed.data.display_name,
|
|
49
|
+
trust_grants: parsed.data.trust_grants,
|
|
50
|
+
tenant_id: tenantId
|
|
51
|
+
});
|
|
52
|
+
return jsonOk(profile, 201);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function handleListUserProfiles(request) {
|
|
56
|
+
return routeWrap(request, async ({ auth }) => {
|
|
57
|
+
const url = new URL(request.url);
|
|
58
|
+
const limit = Math.min(Number(url.searchParams.get("limit") ?? 50), 100);
|
|
59
|
+
const afterId = url.searchParams.get("after_id") ?? void 0;
|
|
60
|
+
const filter = tenantFilter(auth);
|
|
61
|
+
const result = listUserProfiles({
|
|
62
|
+
tenant_id: filter ?? void 0,
|
|
63
|
+
limit,
|
|
64
|
+
after_id: afterId
|
|
65
|
+
});
|
|
66
|
+
return paginatedOk(result.data, limit);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function handleGetUserProfile(request, id) {
|
|
70
|
+
return routeWrap(request, async ({ auth }) => {
|
|
71
|
+
const profile = getUserProfile(id);
|
|
72
|
+
if (!profile) throw notFound(`user profile not found: ${id}`);
|
|
73
|
+
const filter = tenantFilter(auth);
|
|
74
|
+
if (filter && profile.tenant_id !== filter) {
|
|
75
|
+
throw notFound(`user profile not found: ${id}`);
|
|
76
|
+
}
|
|
77
|
+
return jsonOk(profile);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function handleUpdateUserProfile(request, id) {
|
|
81
|
+
return routeWrap(request, async ({ auth }) => {
|
|
82
|
+
const existing = getUserProfile(id);
|
|
83
|
+
if (!existing) throw notFound(`user profile not found: ${id}`);
|
|
84
|
+
const filter = tenantFilter(auth);
|
|
85
|
+
if (filter && existing.tenant_id !== filter) {
|
|
86
|
+
throw notFound(`user profile not found: ${id}`);
|
|
87
|
+
}
|
|
88
|
+
const body = await request.json().catch(() => null);
|
|
89
|
+
const parsed = UpdateSchema.safeParse(body);
|
|
90
|
+
if (!parsed.success) {
|
|
91
|
+
throw badRequest(`invalid body: ${parsed.error.issues.map((i) => i.message).join("; ")}`);
|
|
92
|
+
}
|
|
93
|
+
const updated = updateUserProfile(id, {
|
|
94
|
+
external_id: parsed.data.external_id,
|
|
95
|
+
display_name: parsed.data.display_name,
|
|
96
|
+
trust_grants: parsed.data.trust_grants
|
|
97
|
+
});
|
|
98
|
+
if (!updated) throw notFound(`user profile not found: ${id}`);
|
|
99
|
+
return jsonOk(updated);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
handleCreateUserProfile,
|
|
105
|
+
handleListUserProfiles,
|
|
106
|
+
handleGetUserProfile,
|
|
107
|
+
handleUpdateUserProfile
|
|
108
|
+
};
|
|
@@ -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-XOWRUT4X.js";
|
|
17
17
|
import {
|
|
18
18
|
getEnvironment
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-NSUVDKNC.js";
|
|
20
20
|
import {
|
|
21
21
|
badRequest,
|
|
22
22
|
notFound
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-AIBH32FN.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_TENANT_ID
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YTBVILAH.js";
|
|
8
8
|
import {
|
|
9
9
|
init_ids,
|
|
10
10
|
newId
|
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
import {
|
|
18
18
|
getDrizzle,
|
|
19
19
|
init_drizzle
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-ZDDMPGN4.js";
|
|
21
21
|
import {
|
|
22
22
|
schema_exports
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-CXYMVLYK.js";
|
|
24
24
|
|
|
25
25
|
// src/db/vaults.ts
|
|
26
26
|
init_drizzle();
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
enqueueTurn
|
|
3
|
-
} from "./chunk-SKVAM5H2.js";
|
|
4
1
|
import {
|
|
5
2
|
runTurn
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AKGWEACL.js";
|
|
7
4
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
5
|
+
enqueueTurn
|
|
6
|
+
} from "./chunk-B3W3E5CS.js";
|
|
10
7
|
import {
|
|
11
8
|
redactAppendInput
|
|
12
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-J6ESQUW6.js";
|
|
10
|
+
import {
|
|
11
|
+
installOtlpExporter
|
|
12
|
+
} from "./chunk-2KF2TIEY.js";
|
|
13
13
|
import {
|
|
14
14
|
createApiKey,
|
|
15
15
|
listApiKeys
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-3NUTTKE5.js";
|
|
17
17
|
import {
|
|
18
18
|
initSentry
|
|
19
19
|
} from "./chunk-3MQ2FWXS.js";
|
|
20
20
|
import {
|
|
21
21
|
installShutdownHandlers
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-S6HILC3F.js";
|
|
23
23
|
import {
|
|
24
24
|
runSweep
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-T3TNJHED.js";
|
|
26
26
|
import {
|
|
27
27
|
fillWarmPools,
|
|
28
28
|
reconcileDockerOrphanSandboxes,
|
|
29
29
|
reconcileOrphanSandboxes
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-U4SVWPLC.js";
|
|
31
31
|
import {
|
|
32
32
|
appendEvent,
|
|
33
33
|
installPayloadRedactor
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-RES4BCTF.js";
|
|
35
35
|
import {
|
|
36
36
|
setSessionSandbox
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-ZC7OR65K.js";
|
|
38
38
|
import {
|
|
39
39
|
readEnvValue,
|
|
40
40
|
upsertEnvLine
|
|
41
41
|
} from "./chunk-YPXI7Q2M.js";
|
|
42
42
|
import {
|
|
43
43
|
getLastUnprocessedUserMessage
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-OEFJPZYH.js";
|
|
45
45
|
import {
|
|
46
46
|
getBySession,
|
|
47
47
|
register
|
|
48
48
|
} from "./chunk-EFOIR7R3.js";
|
|
49
49
|
import {
|
|
50
50
|
tryResolveProvider
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-C7P2TYOG.js";
|
|
52
52
|
import {
|
|
53
53
|
getEnvironment
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-NSUVDKNC.js";
|
|
55
55
|
import {
|
|
56
56
|
getConfig
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-6EIONZ7F.js";
|
|
58
58
|
import {
|
|
59
59
|
init_clock,
|
|
60
60
|
nowMs
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
import {
|
|
63
63
|
getDb,
|
|
64
64
|
init_client
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-AGIXZFHQ.js";
|
|
66
66
|
import {
|
|
67
67
|
getRuntime
|
|
68
68
|
} from "./chunk-UYTSKFGK.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
jsonOk,
|
|
3
3
|
routeWrap
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XOWRUT4X.js";
|
|
5
5
|
import {
|
|
6
6
|
resolveContainerProvider
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-C7P2TYOG.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,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/environments.ts
|
|
22
22
|
init_drizzle();
|
|
@@ -10,14 +10,14 @@ 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
|
import {
|
|
18
18
|
getDb,
|
|
19
19
|
init_client
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-AGIXZFHQ.js";
|
|
21
21
|
|
|
22
22
|
// src/db/events.ts
|
|
23
23
|
init_client();
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
// src/backends/opencode/args.ts
|
|
2
|
+
function normalizeOpencodeModel(model) {
|
|
3
|
+
if (model.includes("/")) return model;
|
|
4
|
+
if (model.startsWith("claude-")) return `anthropic/${model}`;
|
|
5
|
+
if (model.startsWith("gemini-")) return `google/${model}`;
|
|
6
|
+
if (model.startsWith("gpt-") || model.startsWith("o1-") || model.startsWith("o3-") || model.startsWith("o4-") || model.startsWith("chatgpt-")) return `openai/${model}`;
|
|
7
|
+
return `ollama/${model}`;
|
|
8
|
+
}
|
|
2
9
|
function buildOpencodeArgs(input) {
|
|
3
10
|
const args = ["run", "--format", "json", "--dangerously-skip-permissions"];
|
|
4
11
|
if (input.backendSessionId) {
|
|
5
12
|
args.push("--session", input.backendSessionId);
|
|
6
13
|
}
|
|
7
14
|
if (input.agent.model) {
|
|
8
|
-
|
|
9
|
-
const cloudPrefixes = ["claude-", "gpt-", "o1-", "o3-", "o4-", "codex-", "chatgpt-", "gemini-"];
|
|
10
|
-
const isOllama = !modelId.includes("/") && !cloudPrefixes.some((p) => modelId.startsWith(p));
|
|
11
|
-
const modelArg = isOllama ? `ollama/${modelId}` : modelId;
|
|
12
|
-
args.push("--model", modelArg);
|
|
15
|
+
args.push("--model", normalizeOpencodeModel(input.agent.model.id));
|
|
13
16
|
}
|
|
14
17
|
return args;
|
|
15
18
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildOpencodeArgs
|
|
3
|
-
} from "./chunk-P56WU3UT.js";
|
|
4
|
-
import {
|
|
5
|
-
buildOpencodeAuthEnv,
|
|
6
|
-
validateOpencodeRuntime
|
|
7
|
-
} from "./chunk-JTGISCYV.js";
|
|
8
1
|
import {
|
|
9
2
|
buildOpencodeConfigEnv
|
|
10
3
|
} from "./chunk-V5DH3OAC.js";
|
|
11
4
|
import {
|
|
12
5
|
prepareOpencodeOnSandbox
|
|
13
6
|
} from "./chunk-URNG7ZX2.js";
|
|
7
|
+
import {
|
|
8
|
+
createOpencodeTranslator
|
|
9
|
+
} from "./chunk-ETWGCBIQ.js";
|
|
14
10
|
import {
|
|
15
11
|
OPENCODE_WRAPPER_PATH
|
|
16
12
|
} from "./chunk-UY3VT3HQ.js";
|
|
17
13
|
import {
|
|
18
|
-
|
|
19
|
-
} from "./chunk-
|
|
14
|
+
buildOpencodeArgs
|
|
15
|
+
} from "./chunk-PDWLVL34.js";
|
|
16
|
+
import {
|
|
17
|
+
buildOpencodeAuthEnv,
|
|
18
|
+
validateOpencodeRuntime
|
|
19
|
+
} from "./chunk-QCGIYXN4.js";
|
|
20
20
|
import {
|
|
21
21
|
wrapPromptWithSystem
|
|
22
22
|
} from "./chunk-YE2RMJY7.js";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSession
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZC7OR65K.js";
|
|
4
4
|
import {
|
|
5
5
|
appendEvent,
|
|
6
6
|
appendEventsBatch,
|
|
7
7
|
listEvents,
|
|
8
8
|
rowToManagedEvent
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OEFJPZYH.js";
|
|
10
10
|
import {
|
|
11
11
|
getAgent
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-6U6HEVSN.js";
|
|
13
13
|
import {
|
|
14
14
|
getDb,
|
|
15
15
|
init_client
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-AGIXZFHQ.js";
|
|
17
17
|
|
|
18
18
|
// src/sessions/bus.ts
|
|
19
19
|
import { EventEmitter } from "events";
|
|
@@ -636,6 +636,26 @@ function runMigrations(db) {
|
|
|
636
636
|
db.exec(`CREATE INDEX IF NOT EXISTS idx_vaults_tenant ON vaults(tenant_id)`);
|
|
637
637
|
}
|
|
638
638
|
}
|
|
639
|
+
db.exec(`
|
|
640
|
+
CREATE TABLE IF NOT EXISTS user_profiles (
|
|
641
|
+
id TEXT PRIMARY KEY,
|
|
642
|
+
external_id TEXT,
|
|
643
|
+
display_name TEXT,
|
|
644
|
+
trust_grants_json TEXT NOT NULL DEFAULT '[]',
|
|
645
|
+
tenant_id TEXT,
|
|
646
|
+
created_at INTEGER NOT NULL,
|
|
647
|
+
updated_at INTEGER NOT NULL,
|
|
648
|
+
UNIQUE(tenant_id, external_id)
|
|
649
|
+
)
|
|
650
|
+
`);
|
|
651
|
+
try {
|
|
652
|
+
db.exec(`ALTER TABLE sessions ADD COLUMN user_profile_id TEXT`);
|
|
653
|
+
} catch {
|
|
654
|
+
}
|
|
655
|
+
try {
|
|
656
|
+
db.exec(`ALTER TABLE agent_versions ADD COLUMN permission_policy_json TEXT`);
|
|
657
|
+
} catch {
|
|
658
|
+
}
|
|
639
659
|
}
|
|
640
660
|
var init_migrations = __esm({
|
|
641
661
|
"src/db/migrations.ts"() {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
markStopping
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-T3TNJHED.js";
|
|
4
4
|
import {
|
|
5
5
|
closeDb,
|
|
6
6
|
init_client,
|
|
7
7
|
syncDb
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-AGIXZFHQ.js";
|
|
9
9
|
import {
|
|
10
10
|
getRuntime
|
|
11
11
|
} from "./chunk-UYTSKFGK.js";
|
|
@@ -139,7 +139,7 @@ var CreateAgentRequestSchema = registry.register(
|
|
|
139
139
|
"CreateAgentRequest",
|
|
140
140
|
z.object({
|
|
141
141
|
name: z.string().min(1).openapi({ example: "my-agent" }),
|
|
142
|
-
model: z.object({ id: z.string().min(1), speed: z.enum(["standard", "fast"]).optional() }).openapi({ description: "Model configuration. `id` is the
|
|
142
|
+
model: z.object({ id: z.string().min(1), speed: z.enum(["standard", "fast"]).optional() }).openapi({ description: "Model configuration. `id` is the bare model identifier (e.g. `gemini-2.5-flash`, `claude-sonnet-4-6`, `gpt-5.4`). Do not include provider prefixes.", example: { id: "claude-sonnet-4-6" } }),
|
|
143
143
|
description: z.string().max(2048).optional().openapi({
|
|
144
144
|
description: "Human-readable description of the agent."
|
|
145
145
|
}),
|
|
@@ -156,7 +156,7 @@ var CreateAgentRequestSchema = registry.register(
|
|
|
156
156
|
description: "MCP servers as an array of objects with name, type, and optional url."
|
|
157
157
|
}),
|
|
158
158
|
engine: z.enum(["claude", "opencode", "codex", "anthropic", "gemini", "factory", "pi"]).optional().openapi({
|
|
159
|
-
description: "Agent harness.
|
|
159
|
+
description: "Agent harness. Auto-inferred from model prefix if omitted: `gemini-*` \u2192 gemini, `gpt-*`/`o1-*` \u2192 codex, `claude-*` \u2192 claude. Always use bare model IDs (`gemini-2.5-flash`, not `google/gemini-2.5-flash`) \u2014 provider prefixes are added internally where needed. Non-claude engines must NOT declare `tools` (they manage tool permissions internally). Required vault keys: claude \u2192 ANTHROPIC_API_KEY, gemini \u2192 GEMINI_API_KEY, codex \u2192 OPENAI_API_KEY, pi \u2192 any of the three.",
|
|
160
160
|
example: "claude"
|
|
161
161
|
}),
|
|
162
162
|
webhook_url: z.string().url().optional().openapi({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
syncAndCreateSession
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AUEKXYNE.js";
|
|
4
4
|
import {
|
|
5
5
|
resolveRemoteSessionId,
|
|
6
6
|
upsertSync
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZBWKJ42J.js";
|
|
8
8
|
import {
|
|
9
9
|
assertResourceTenant,
|
|
10
10
|
tenantFilter
|
|
@@ -14,19 +14,19 @@ import {
|
|
|
14
14
|
} from "./chunk-DC2UMEQH.js";
|
|
15
15
|
import {
|
|
16
16
|
getMemoryStore
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TVV7AE3G.js";
|
|
18
18
|
import {
|
|
19
19
|
kickoffEnvironmentSetup
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-YRFWPBGX.js";
|
|
21
21
|
import {
|
|
22
22
|
decodeCursor,
|
|
23
23
|
jsonOk,
|
|
24
24
|
paginatedOk,
|
|
25
25
|
routeWrap
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-XOWRUT4X.js";
|
|
27
27
|
import {
|
|
28
28
|
forwardToAnthropic
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-JFHYXFAL.js";
|
|
30
30
|
import {
|
|
31
31
|
errors_exports,
|
|
32
32
|
init_errors
|
|
@@ -36,32 +36,33 @@ import {
|
|
|
36
36
|
isProxied,
|
|
37
37
|
markProxied,
|
|
38
38
|
unmarkProxied
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-DZKBUOYU.js";
|
|
40
40
|
import {
|
|
41
41
|
dropActor,
|
|
42
42
|
getActor
|
|
43
43
|
} from "./chunk-LAWTTG2E.js";
|
|
44
44
|
import {
|
|
45
45
|
releaseSession
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-U4SVWPLC.js";
|
|
47
47
|
import {
|
|
48
48
|
appendEvent,
|
|
49
49
|
dropEmitter
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-RES4BCTF.js";
|
|
51
51
|
import {
|
|
52
52
|
archiveSession,
|
|
53
53
|
createSession,
|
|
54
54
|
getSession,
|
|
55
55
|
listSessions,
|
|
56
|
+
setOutcomeCriteria,
|
|
56
57
|
updateSessionMutable,
|
|
57
58
|
updateSessionStatus
|
|
58
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-ZC7OR65K.js";
|
|
59
60
|
import {
|
|
60
61
|
getEnvironment
|
|
61
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-NSUVDKNC.js";
|
|
62
63
|
import {
|
|
63
64
|
getAgent
|
|
64
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-6U6HEVSN.js";
|
|
65
66
|
import {
|
|
66
67
|
init_clock,
|
|
67
68
|
nowMs
|
|
@@ -69,7 +70,7 @@ import {
|
|
|
69
70
|
import {
|
|
70
71
|
getDb,
|
|
71
72
|
init_client
|
|
72
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-AGIXZFHQ.js";
|
|
73
74
|
import {
|
|
74
75
|
badRequest,
|
|
75
76
|
notFound
|
|
@@ -149,7 +150,17 @@ var CreateSchema = z.object({
|
|
|
149
150
|
max_tokens: z.number().int().positive().optional(),
|
|
150
151
|
max_wall_duration_ms: z.number().int().positive().optional(),
|
|
151
152
|
resources: z.array(ResourceSchema).optional(),
|
|
152
|
-
vault_ids: z.array(z.string()).optional()
|
|
153
|
+
vault_ids: z.array(z.string()).optional(),
|
|
154
|
+
user_profile_id: z.string().optional(),
|
|
155
|
+
outcomes: z.object({
|
|
156
|
+
description: z.string().min(1),
|
|
157
|
+
rubric: z.array(z.object({
|
|
158
|
+
name: z.string(),
|
|
159
|
+
description: z.string(),
|
|
160
|
+
weight: z.number().optional()
|
|
161
|
+
})).optional(),
|
|
162
|
+
max_iterations: z.number().int().min(1).max(10).optional()
|
|
163
|
+
}).optional()
|
|
153
164
|
});
|
|
154
165
|
var UpdateSchema = z.object({
|
|
155
166
|
title: z.string().nullish(),
|
|
@@ -250,6 +261,14 @@ function handleCreateSession(request) {
|
|
|
250
261
|
}
|
|
251
262
|
}
|
|
252
263
|
}
|
|
264
|
+
if (data.user_profile_id) {
|
|
265
|
+
const { getUserProfile } = await import("./db/user-profiles.js");
|
|
266
|
+
const profile = getUserProfile(data.user_profile_id);
|
|
267
|
+
if (!profile) throw badRequest(`user profile not found: ${data.user_profile_id}`);
|
|
268
|
+
if (profile.tenant_id && profile.tenant_id !== agentTenantId) {
|
|
269
|
+
throw badRequest(`user profile does not belong to this tenant`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
253
272
|
if (data.resources?.length) {
|
|
254
273
|
const memStoreResources = data.resources.filter((r) => r.type === "memory_store");
|
|
255
274
|
if (memStoreResources.length > 8) {
|
|
@@ -296,6 +315,7 @@ function handleCreateSession(request) {
|
|
|
296
315
|
max_wall_duration_ms: data.max_wall_duration_ms ?? null,
|
|
297
316
|
resources: data.resources?.length ? data.resources : null,
|
|
298
317
|
vault_ids: data.vault_ids?.length ? data.vault_ids : null,
|
|
318
|
+
user_profile_id: data.user_profile_id ?? null,
|
|
299
319
|
api_key_id: auth.keyId,
|
|
300
320
|
tenant_id: agentTenantId
|
|
301
321
|
});
|
|
@@ -335,6 +355,14 @@ function handleCreateSession(request) {
|
|
|
335
355
|
});
|
|
336
356
|
upsertSync(session2.id, "session", remoteSessionId);
|
|
337
357
|
markProxied(session2.id, "session", agentTenantId);
|
|
358
|
+
if (data.outcomes) {
|
|
359
|
+
setOutcomeCriteria(session2.id, {
|
|
360
|
+
description: data.outcomes.description,
|
|
361
|
+
rubric: data.outcomes.rubric ?? [],
|
|
362
|
+
max_iterations: data.outcomes.max_iterations ?? 3,
|
|
363
|
+
status: "running"
|
|
364
|
+
});
|
|
365
|
+
}
|
|
338
366
|
getActor(session2.id);
|
|
339
367
|
return jsonOk(session2, 201);
|
|
340
368
|
}
|
|
@@ -357,6 +385,7 @@ function handleCreateSession(request) {
|
|
|
357
385
|
max_wall_duration_ms: data.max_wall_duration_ms ?? null,
|
|
358
386
|
resources: data.resources?.length ? data.resources : null,
|
|
359
387
|
vault_ids: data.vault_ids?.length ? data.vault_ids : null,
|
|
388
|
+
user_profile_id: data.user_profile_id ?? null,
|
|
360
389
|
api_key_id: auth.keyId,
|
|
361
390
|
tenant_id: agentTenantId
|
|
362
391
|
});
|
|
@@ -391,6 +420,14 @@ function handleCreateSession(request) {
|
|
|
391
420
|
});
|
|
392
421
|
}
|
|
393
422
|
}
|
|
423
|
+
if (data.outcomes) {
|
|
424
|
+
setOutcomeCriteria(session.id, {
|
|
425
|
+
description: data.outcomes.description,
|
|
426
|
+
rubric: data.outcomes.rubric ?? [],
|
|
427
|
+
max_iterations: data.outcomes.max_iterations ?? 3,
|
|
428
|
+
status: "running"
|
|
429
|
+
});
|
|
430
|
+
}
|
|
394
431
|
getActor(session.id);
|
|
395
432
|
return jsonOk(session, 201);
|
|
396
433
|
}
|