@shumai-one/shumai 0.2.0 → 0.2.2
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/bin/chunk-0aj303as.js +3 -0
- package/bin/{chunk-kbzm1pwx.js → chunk-0qkj838r.js} +1 -1
- package/bin/{chunk-5a2maxwp.js → chunk-0rxhc7ka.js} +2 -2
- package/bin/chunk-0xbf8bcg.js +2 -0
- package/bin/{chunk-xh2ntgmk.js → chunk-14fh4s1a.js} +2 -2
- package/bin/{chunk-6mn3jqm9.js → chunk-15sefy5t.js} +2 -2
- package/bin/{chunk-mjan6b09.js → chunk-1wm57c6y.js} +3 -3
- package/bin/{chunk-pf8edn5x.js → chunk-1xpec5r8.js} +2 -2
- package/bin/chunk-23d3968z.js +2 -0
- package/bin/{chunk-r3n9zpfw.js → chunk-262hkppb.js} +2 -2
- package/bin/{chunk-3n1k9qt5.js → chunk-29tx9qe2.js} +1 -1
- package/bin/chunk-2aamsc5v.js +2 -0
- package/bin/chunk-2aascrtb.js +2 -0
- package/bin/chunk-2dsmsa6a.js +3 -0
- package/bin/chunk-2g12s6mc.js +2 -0
- package/bin/chunk-31baz5n0.js +2 -0
- package/bin/{chunk-a5kfa0k9.js → chunk-3rmc8nz6.js} +1 -1
- package/bin/{chunk-dyybbn07.js → chunk-46ar48f9.js} +1 -1
- package/bin/chunk-4e3jbp84.js +1 -0
- package/bin/chunk-4jk0y1w1.js +1 -0
- package/bin/{chunk-7ddaxdpf.js → chunk-4qpa7b5t.js} +1 -1
- package/bin/{chunk-8wv3kdz9.js → chunk-54tr7y2x.js} +2 -2
- package/bin/{chunk-ehfk24cf.js → chunk-5d2q46mx.js} +1 -1
- package/bin/{chunk-2cmg5sfn.js → chunk-5m9be8an.js} +2 -2
- package/bin/{chunk-yk3k5g5w.js → chunk-5r8858hx.js} +2 -2
- package/bin/{chunk-fwe9g818.js → chunk-5t6c3038.js} +1 -1
- package/bin/chunk-6z65xd0w.js +3 -0
- package/bin/{chunk-cp18trqb.js → chunk-77r8w95d.js} +2 -2
- package/bin/chunk-7b17fb36.js +6 -0
- package/bin/chunk-7e06b2zb.js +2 -0
- package/bin/{chunk-29ectt6g.js → chunk-7hsgmjpa.js} +2 -2
- package/bin/chunk-7we7ex0m.js +3 -0
- package/bin/{chunk-6r9w7z15.js → chunk-88fg1sw7.js} +2 -2
- package/bin/chunk-891h8br6.js +3 -0
- package/bin/{chunk-m7jfszqt.js → chunk-8mkfgcvb.js} +2 -2
- package/bin/chunk-8qg47kj6.js +3 -0
- package/bin/chunk-8tf6kgdj.js +2 -0
- package/bin/{chunk-s8d2045p.js → chunk-8wqfkm4c.js} +1 -1
- package/bin/{chunk-3rajscaz.js → chunk-922nnh39.js} +1 -1
- package/bin/{chunk-aakzq0w1.js → chunk-925q4paa.js} +1 -1
- package/bin/{chunk-frm7vz6v.js → chunk-92xxys10.js} +6 -6
- package/bin/chunk-97jzve52.js +4 -0
- package/bin/{chunk-w4y97tzy.js → chunk-9ab6k4rq.js} +1 -1
- package/bin/chunk-9avkn3x1.js +3 -0
- package/bin/{chunk-22dje1f5.js → chunk-9h027f50.js} +1 -1
- package/bin/{chunk-ec88pb09.js → chunk-9h3ds7rn.js} +2 -2
- package/bin/chunk-av71yjaa.js +1 -0
- package/bin/{chunk-xpqcvxej.js → chunk-b8js74jk.js} +1 -1
- package/bin/chunk-bd71dp4j.js +8 -0
- package/bin/{chunk-yhj8c5re.js → chunk-bs0fjz3w.js} +2 -2
- package/bin/chunk-byqc8tzq.js +1 -0
- package/bin/chunk-c45rh4hk.js +3 -0
- package/bin/chunk-ccw7mjgq.js +5 -0
- package/bin/{chunk-3x62t1m0.js → chunk-cxhmr356.js} +1 -1
- package/bin/chunk-d2vxmn9v.js +3 -0
- package/bin/chunk-d3wmdjze.js +8 -0
- package/bin/{chunk-z42cyc20.js → chunk-de99643r.js} +2 -2
- package/bin/{chunk-4kk5g619.js → chunk-dghtwyq1.js} +2 -2
- package/bin/chunk-dqgv5yy1.js +6 -0
- package/bin/chunk-e3s3rz2e.js +12 -0
- package/bin/chunk-e52nga6c.js +3 -0
- package/bin/chunk-e7ndw3hg.js +12 -0
- package/bin/chunk-f14sqw1d.js +1 -0
- package/bin/chunk-f7sbkfmk.js +2 -0
- package/bin/{chunk-mnv6pj0k.js → chunk-fa2g2wge.js} +2 -2
- package/bin/{chunk-fcb14agg.js → chunk-fbte2rmd.js} +1 -1
- package/bin/chunk-fcvtgx1y.js +7 -0
- package/bin/chunk-fd5a3pdd.js +1 -0
- package/bin/{chunk-49ej1y67.js → chunk-fepymbka.js} +2 -2
- package/bin/{chunk-j8q688sx.js → chunk-fz88kkk1.js} +2 -2
- package/bin/chunk-g6zzg6v2.js +1 -0
- package/bin/chunk-g8th86na.js +2 -0
- package/bin/chunk-gswbc6y9.js +2 -0
- package/bin/{chunk-d1ka11hc.js → chunk-gtrc5ka2.js} +1 -1
- package/bin/chunk-h0ytx8zc.js +2 -0
- package/bin/{chunk-gdm6y33a.js → chunk-hkbybhww.js} +1 -1
- package/bin/chunk-hr97a5j5.js +4 -0
- package/bin/{chunk-dypsm6m2.js → chunk-j8qtab70.js} +1 -1
- package/bin/{chunk-hdk93ghf.js → chunk-jf3vn5c3.js} +2 -2
- package/bin/{chunk-ajqsprm0.js → chunk-kfhtk3eh.js} +2 -2
- package/bin/chunk-kr06nrbx.js +2 -0
- package/bin/{chunk-9rw65s3e.js → chunk-m4zpf9gg.js} +2 -2
- package/bin/{chunk-y1xs4c5j.js → chunk-mqjzmn0e.js} +1 -1
- package/bin/{chunk-d2y3rbjm.js → chunk-mzg1h07d.js} +1 -1
- package/bin/{chunk-ysq64j13.js → chunk-n4meg9wb.js} +1 -1
- package/bin/{chunk-acxm86fh.js → chunk-nrwna4ha.js} +1 -1
- package/bin/chunk-nyhqy6q2.js +62 -0
- package/bin/{chunk-4zq8vxcy.css → chunk-pmswtfe3.css} +1 -1
- package/bin/chunk-pq18zenh.js +2 -0
- package/bin/chunk-pxw97qbq.js +3 -0
- package/bin/chunk-q09dfja5.js +3 -0
- package/bin/{chunk-m54p1cvp.js → chunk-q24epdh8.js} +2 -2
- package/bin/{chunk-k5w64spz.js → chunk-qksb0v3c.js} +2 -2
- package/bin/chunk-qqk51620.js +2 -0
- package/bin/chunk-r0w920zb.js +1 -0
- package/bin/{chunk-08m8mzfa.js → chunk-re0b7sj7.js} +1 -1
- package/bin/chunk-rtngbgpk.js +7 -0
- package/bin/{chunk-5tmf3c0g.js → chunk-ry33f2qk.js} +2 -2
- package/bin/{chunk-9n0etqsy.js → chunk-s1n39qte.js} +1 -1
- package/bin/{chunk-3qdn3pty.js → chunk-s46zwr4p.js} +1 -1
- package/bin/chunk-s8t74q9m.js +1 -0
- package/bin/chunk-sd86v1e6.js +1 -0
- package/bin/{chunk-kpy0kpna.js → chunk-srn8t0v7.js} +2 -2
- package/bin/chunk-szzff7gd.js +1 -0
- package/bin/{chunk-fwf8yne2.js → chunk-t3t6021k.js} +2 -2
- package/bin/{chunk-eadb78m8.js → chunk-ta7bfdrn.js} +1 -1
- package/bin/chunk-thsbcbay.js +8 -0
- package/bin/chunk-tspps87j.js +1 -0
- package/bin/chunk-w7dn1m95.js +2 -0
- package/bin/chunk-w88219ex.js +3 -0
- package/bin/{chunk-pqm0g14r.js → chunk-wc8sc9r9.js} +2 -2
- package/bin/chunk-wg98cacx.js +2 -0
- package/bin/chunk-wsyg4rwg.js +2 -0
- package/bin/{chunk-n5hfy93f.js → chunk-xcwbg4w9.js} +3 -3
- package/bin/{chunk-dgx2zxze.js → chunk-xyjw8w3r.js} +2 -2
- package/bin/chunk-y2qp11v9.js +1 -0
- package/bin/{chunk-1fpqq6ed.js → chunk-ybhgmvxa.js} +2 -2
- package/bin/{chunk-1wq9hjjr.js → chunk-ygz6pawn.js} +1 -1
- package/bin/{chunk-mv79zk8q.js → chunk-ymeycphq.js} +3 -3
- package/bin/{chunk-wv4fe1fj.js → chunk-zemrvz79.js} +2 -2
- package/bin/{chunk-3rt9mnj3.js → chunk-ztmj61z9.js} +1 -1
- package/bin/chunk-zzx99j8t.js +2 -0
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +308 -283
- package/package.json +7 -7
- package/prisma/migrations/20260722022359_add_skill_permission/migration.sql +2 -0
- package/prisma/migrations/20260723025234_add_ai_usage_table/migration.sql +28 -0
- package/prisma/migrations/20260723032755_add_ai_usage_unique_constraint/migration.sql +8 -0
- package/prisma/schema.prisma +26 -0
- package/bin/chunk-09wp20mv.js +0 -1
- package/bin/chunk-0at8vxt5.js +0 -3
- package/bin/chunk-0zv7f9ca.js +0 -2
- package/bin/chunk-2k4vp654.js +0 -2
- package/bin/chunk-2s5a64nr.js +0 -2
- package/bin/chunk-2tbya52d.js +0 -2
- package/bin/chunk-2vs3evc7.js +0 -14
- package/bin/chunk-33169en9.js +0 -8
- package/bin/chunk-33ee1cvv.js +0 -2
- package/bin/chunk-3m39v371.js +0 -1
- package/bin/chunk-4hnrd4qh.js +0 -2
- package/bin/chunk-6c4c7t0n.js +0 -1
- package/bin/chunk-6frqqxkv.js +0 -1
- package/bin/chunk-7rhjej0x.js +0 -3
- package/bin/chunk-7wvgtw25.js +0 -3
- package/bin/chunk-8s0ae37g.js +0 -1
- package/bin/chunk-94h8644q.js +0 -2
- package/bin/chunk-ac2ky3q0.js +0 -12
- package/bin/chunk-axx5bh38.js +0 -2
- package/bin/chunk-cthpdt54.js +0 -11
- package/bin/chunk-d0earxhc.js +0 -4
- package/bin/chunk-d0n8nxp3.js +0 -3
- package/bin/chunk-d22pyc5n.js +0 -1
- package/bin/chunk-dmgjse02.js +0 -4
- package/bin/chunk-e5833tbd.js +0 -2
- package/bin/chunk-g7wrxnmd.js +0 -1
- package/bin/chunk-gk7158n4.js +0 -2
- package/bin/chunk-hb5v9ees.js +0 -2
- package/bin/chunk-jrvrg4fx.js +0 -1
- package/bin/chunk-k712q1zj.js +0 -2
- package/bin/chunk-kef0rnwn.js +0 -1
- package/bin/chunk-n296vcfw.js +0 -3
- package/bin/chunk-n6jgyv4y.js +0 -3
- package/bin/chunk-nar4s9v9.js +0 -3
- package/bin/chunk-nn8e9j7c.js +0 -1
- package/bin/chunk-nwtb6dt1.js +0 -62
- package/bin/chunk-ps4h3387.js +0 -5
- package/bin/chunk-q4f5vvtx.js +0 -2
- package/bin/chunk-qqesrgjk.js +0 -7
- package/bin/chunk-qz9xht6d.js +0 -2
- package/bin/chunk-symna5cj.js +0 -1
- package/bin/chunk-twzgpwst.js +0 -2
- package/bin/chunk-vgvmt2m1.js +0 -2
- package/bin/chunk-w4t9n9te.js +0 -6
- package/bin/chunk-z14hh99h.js +0 -2
- package/bin/chunk-zsdwska1.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shumai-one/shumai",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A fullstack AI-powered media workspace and workflow engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"zod": "4.4.3"
|
|
28
28
|
},
|
|
29
29
|
"optionalDependencies": {
|
|
30
|
-
"@shumai-one/shumai-darwin-arm64": "0.2.
|
|
31
|
-
"@shumai-one/shumai-darwin-x64": "0.2.
|
|
32
|
-
"@shumai-one/shumai-linux-arm64": "0.2.
|
|
33
|
-
"@shumai-one/shumai-linux-x64": "0.2.
|
|
34
|
-
"@shumai-one/shumai-win32-arm64": "0.2.
|
|
35
|
-
"@shumai-one/shumai-win32-x64": "0.2.
|
|
30
|
+
"@shumai-one/shumai-darwin-arm64": "0.2.2",
|
|
31
|
+
"@shumai-one/shumai-darwin-x64": "0.2.2",
|
|
32
|
+
"@shumai-one/shumai-linux-arm64": "0.2.2",
|
|
33
|
+
"@shumai-one/shumai-linux-x64": "0.2.2",
|
|
34
|
+
"@shumai-one/shumai-win32-arm64": "0.2.2",
|
|
35
|
+
"@shumai-one/shumai-win32-x64": "0.2.2"
|
|
36
36
|
},
|
|
37
37
|
"repository": {
|
|
38
38
|
"type": "git",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "ai_usages" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"team_id" TEXT NOT NULL,
|
|
5
|
+
"user_id" TEXT,
|
|
6
|
+
"period_start" TIMESTAMP(3) NOT NULL,
|
|
7
|
+
"input_tokens" INTEGER NOT NULL DEFAULT 0,
|
|
8
|
+
"output_tokens" INTEGER NOT NULL DEFAULT 0,
|
|
9
|
+
"cache_read_tokens" INTEGER NOT NULL DEFAULT 0,
|
|
10
|
+
"total_tokens" INTEGER NOT NULL DEFAULT 0,
|
|
11
|
+
"cost" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
12
|
+
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
13
|
+
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
14
|
+
|
|
15
|
+
CONSTRAINT "ai_usages_pkey" PRIMARY KEY ("id")
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
-- CreateIndex
|
|
19
|
+
CREATE INDEX "ai_usages_team_id_period_start_idx" ON "ai_usages"("team_id", "period_start");
|
|
20
|
+
|
|
21
|
+
-- CreateIndex
|
|
22
|
+
CREATE INDEX "ai_usages_team_id_user_id_period_start_idx" ON "ai_usages"("team_id", "user_id", "period_start");
|
|
23
|
+
|
|
24
|
+
-- AddForeignKey
|
|
25
|
+
ALTER TABLE "ai_usages" ADD CONSTRAINT "ai_usages_team_id_fkey" FOREIGN KEY ("team_id") REFERENCES "teams"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
26
|
+
|
|
27
|
+
-- AddForeignKey
|
|
28
|
+
ALTER TABLE "ai_usages" ADD CONSTRAINT "ai_usages_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- A unique constraint covering the columns `[team_id,user_id,period_start]` on the table `ai_usages` will be added. If there are existing duplicate values, this will fail.
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
-- CreateIndex
|
|
8
|
+
CREATE UNIQUE INDEX "ai_usages_team_id_user_id_period_start_key" ON "ai_usages"("team_id", "user_id", "period_start");
|
package/prisma/schema.prisma
CHANGED
|
@@ -155,6 +155,7 @@ model User {
|
|
|
155
155
|
collections Collection[] @relation("UserToCollection")
|
|
156
156
|
shareLinks ShareLink[] @relation("UserToShareLink")
|
|
157
157
|
apiTokens ApiToken[] @relation("UserToApiToken")
|
|
158
|
+
aiUsages AiUsage[] @relation("UserToAiUsage")
|
|
158
159
|
|
|
159
160
|
@@map("users")
|
|
160
161
|
}
|
|
@@ -237,6 +238,7 @@ model Team {
|
|
|
237
238
|
skills Skill[] @relation("TeamToSkill")
|
|
238
239
|
sandbox Sandbox? @relation("TeamToSandbox")
|
|
239
240
|
agents Agent[] @relation("TeamToAgent")
|
|
241
|
+
aiUsages AiUsage[] @relation("TeamToAiUsage")
|
|
240
242
|
|
|
241
243
|
@@map("teams")
|
|
242
244
|
}
|
|
@@ -262,6 +264,7 @@ model Skill {
|
|
|
262
264
|
config Json? @default("{}")
|
|
263
265
|
assetId String @map("asset_id")
|
|
264
266
|
hash String @map("hash")
|
|
267
|
+
permission TeamMemberRole @default(reviewer)
|
|
265
268
|
createdAt DateTime @default(now()) @map("created_at")
|
|
266
269
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
267
270
|
|
|
@@ -813,3 +816,26 @@ model ApiToken {
|
|
|
813
816
|
|
|
814
817
|
@@map("api_tokens")
|
|
815
818
|
}
|
|
819
|
+
|
|
820
|
+
model AiUsage {
|
|
821
|
+
id String @id @default(ulid())
|
|
822
|
+
teamId String @map("team_id")
|
|
823
|
+
userId String? @map("user_id")
|
|
824
|
+
periodStart DateTime @map("period_start")
|
|
825
|
+
inputTokens Int @default(0) @map("input_tokens")
|
|
826
|
+
outputTokens Int @default(0) @map("output_tokens")
|
|
827
|
+
cacheReadTokens Int @default(0) @map("cache_read_tokens")
|
|
828
|
+
totalTokens Int @default(0) @map("total_tokens")
|
|
829
|
+
cost Float @default(0) @map("cost")
|
|
830
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
831
|
+
updatedAt DateTime @updatedAt @map("updated_at")
|
|
832
|
+
|
|
833
|
+
team Team @relation("TeamToAiUsage", fields: [teamId], references: [id], onDelete: Cascade)
|
|
834
|
+
user User? @relation("UserToAiUsage", fields: [userId], references: [id], onDelete: SetNull)
|
|
835
|
+
|
|
836
|
+
@@map("ai_usages")
|
|
837
|
+
@@unique([teamId, userId, periodStart])
|
|
838
|
+
@@index([teamId, periodStart])
|
|
839
|
+
@@index([teamId, userId, periodStart])
|
|
840
|
+
}
|
|
841
|
+
|
package/bin/chunk-09wp20mv.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as RB,c as bB}from"./chunk-hb5v9ees.js";import{g as gB}from"./chunk-2s5a64nr.js";import{k as LB,n as MB}from"./chunk-dgx2zxze.js";import{I as NB}from"./chunk-axx5bh38.js";import"./chunk-q4f5vvtx.js";import{Wa as DB}from"./chunk-kpy0kpna.js";import"./chunk-ajqsprm0.js";import"./chunk-xpqcvxej.js";import"./chunk-4hnrd4qh.js";import"./chunk-cp18trqb.js";import{mf as VB,nf as wB}from"./chunk-8wv3kdz9.js";import"./chunk-j8q688sx.js";import"./chunk-5a2maxwp.js";import"./chunk-4kk5g619.js";import{Vf as kB}from"./chunk-5tmf3c0g.js";import{Wf as $B,Xf as EB}from"./chunk-mnv6pj0k.js";import{$f as XB,Eg as q,Ng as p,Pi as UB,Zf as d,_g as ZB,ag as zB,bg as G,cg as D,dg as HB,fg as j,hg as QB,hj as yB,ij as PB,ng as qB,pg as YB,sg as TB,wh as _B}from"./chunk-nwtb6dt1.js";import{Zj as KB}from"./chunk-kbzm1pwx.js";var $=KB(XB(),1);var tB=({item:J})=>{if(J.preview?.thumbnailUrl)return G("img",{src:J.preview.thumbnailUrl,alt:"Preview",className:"w-full h-full object-cover"});if(J.preview?.proxyType==="audio"||J.proxyType==="audio")return G("div",{className:"w-full h-full flex items-center justify-center bg-muted",children:G(ZB,{className:"w-5 h-5 text-muted-foreground"})});return G("div",{className:"w-full h-full flex items-center justify-center bg-muted",children:G(_B,{className:"w-5 h-5 text-muted-foreground"})})},OB=({projectId:J,currentAssetId:X,parentFolderId:Q,initialFiles:_,initialNextCursor:w})=>{let{ref:z,inView:k}=$B({threshold:0,rootMargin:"200px"}),T=$.useRef(null),N=$.useRef(!1),[O,y]=$.useState(_),[Z,R]=$.useState(w),[b,S]=$.useState(!!w),[L,P]=$.useState(!1);return $.useEffect(()=>{y(_),R(w),S(!!w),N.current=!1},[_,w]),$.useEffect(()=>{(async()=>{if(!Z||L||!k||!b)return;P(!0);try{let W=await q.api.folders[":folderId"].search.$post({param:{folderId:Q},json:{assetType:"file",after:Z,first:200,recursively:!1,conditions:[]}});if(!W.ok)throw Error("Failed to fetch next page");let g=await W.json(),M=g.data||[];y((f)=>[...f,...M]),R(g.pageInfo?.cursor||void 0),S(!!g.pageInfo?.cursor&&M.length>0)}catch(W){console.error("Error fetching next page:",W)}finally{P(!1)}})()},[k,Z,b,L,Q]),$.useEffect(()=>{N.current=!1},[X]),$.useEffect(()=>{if(O.some((W)=>W?.id===X)&&T.current&&!N.current)T.current.scrollIntoView({block:"center",inline:"center",behavior:"smooth"}),N.current=!0},[O,X]),G("div",{className:"h-24 md:h-full w-full md:w-24 bg-gray-100 dark:bg-gray-950 flex flex-row md:flex-col flex-shrink-0 select-none",children:D("div",{className:"flex-1 overflow-x-auto overflow-y-hidden md:overflow-y-auto md:overflow-x-hidden px-4 md:px-0 py-2 md:py-4 flex flex-row md:flex-col items-center gap-3 no-scrollbar",children:[O.map((H)=>{if(!H)return null;let W=H.id===X;return G("div",{ref:H.id===X?T:null,className:"flex-shrink-0",children:G(YB,{to:"/projects/$projectId/files/$fileId",params:{projectId:J,fileId:H.id},search:{version:void 0},className:UB("rounded-lg border overflow-hidden flex items-center justify-center transition-all bg-muted/30 block",W?"w-[62px] h-[62px] opacity-100":"w-[52px] h-[52px] opacity-60 hover:opacity-100"),children:G(tB,{item:H})})},H.id)}),b&&G("div",{ref:z,className:"px-2 md:px-0 py-2 md:py-4 flex justify-center items-center h-full md:w-full flex-shrink-0",children:L&&G(p,{className:"h-5 w-5 animate-spin text-muted-foreground"})})]})})};var Y=KB(XB(),1);function eB(){let{projectId:J,fileId:X}=WB.useParams(),Q=WB.useSearch(),_=Q.version,w=Q.start,z=_||X,k=Q.cmpLeft,T=Q.cmpRight,N=Q.cmpActive??"left",O=!!Q.compare&&!!k&&!!T,y=Y.useRef(null),{teamId:Z,ensureTeamIdForProject:R}=PB(),[b,S]=Y.useState(360),[L,P]=Y.useState([]),{fileViewRightSidebarCollapsed:H}=EB(),{isChatbotOpen:W}=wB(),[g,M]=Y.useState(0),[f,C]=Y.useState(null),[l,AB]=Y.useState(null),[xB,jB]=Y.useState(void 0),[A,I]=Y.useState({show:!1,files:[],nextCursor:void 0,folderId:void 0}),SB=q.api.files[":fileId"].metadata.$patch,{mutate:CB}=QB({mutationFn:async(B)=>{let K=await SB(B);if(!K.ok)throw Error("Failed to patch metadata");return await K.json()}}),hB=HB(),{members:FB,fetchMembers:n}=NB();Y.useEffect(()=>{R(J)},[J,R]),Y.useEffect(()=>{if(Z)n(Z,!0)},[Z,n]);let{data:o,isLoading:vB,isError:pB,isFetching:fB}=j({queryKey:["files",X],queryFn:async()=>{let B=await q.api.files[":fileId"].$get({param:{fileId:X}});if(!B.ok)throw Error("Failed to fetch stack");return await B.json()},enabled:!!Z,placeholderData:d}),{data:IB,isLoading:mB,isError:uB,isFetching:cB}=j({queryKey:["files",_],queryFn:async()=>{let B=await q.api.files[":fileId"].$get({param:{fileId:_}});if(!B.ok)throw Error("Failed to fetch version");return await B.json()},enabled:!!Z&&!!_,placeholderData:d}),{data:dB}=j({queryKey:["version_stacks",X,"versions"],queryFn:async()=>{let B=await q.api.version_stacks[":stackId"].versions.$get({param:{stackId:X}});if(!B.ok)throw Error("Failed to fetch versions");return await B.json()},enabled:!!J&&!!X&&(!!_||O)}),{data:x}=j({queryKey:["projects",J],queryFn:async()=>{let B=await q.api.projects[":projectId"].$get({param:{projectId:J}});if(!B.ok)throw Error("Failed to fetch project");return await B.json()}}),h=qB(),{setProjectState:a,clearProjectState:r}=VB(),lB=vB||!!_&&mB,nB=pB||!!_&&uB,oB=fB||!!_&&cB,U=IB||o,V=_?dB:o?.versionStack?.versions;Y.useEffect(()=>{if(U&&x&&Z)a({teamId:Z,projectId:J,projectName:x.name??"",ancestorFolders:U.ancestorFolders??[],currentAsset:{name:U.name,type:"file",version:V?V.find((B)=>B.id===z)?.version??V.length:void 0,proxyType:U.proxyType},isRootFolder:!1,fileId:X,downloadInfo:{originalKey:U.media?.original?.key,videoTranscodes:U.media?.videoTranscodes?.map((B)=>({key:B.key,width:B.width,height:B.height,isRaw:B.isRaw}))},versions:V,compareMode:O,canCompareVersions:(V?.length??0)>=2,onCompareVersions:()=>{let B=LB(V);if(!B)return;h({to:"/projects/$projectId/files/$fileId",params:{projectId:J,fileId:X},search:(K)=>({...K,version:void 0,compare:!0,cmpLeft:B.left.id,cmpRight:B.right.id,cmpActive:"left"})})},onFolderClick:(B)=>{h({to:"/projects/$projectId/folders/$folderId",params:{projectId:J,folderId:B}})}});return()=>r()},[Z,J,x,U,V,z,X,O,a,r,h]);let E=U?.ancestorFolders?.[0]?.id??x?.rootFolder??"";if(Y.useEffect(()=>{if(!E||!z)return;if(A.folderId===E)return;let B=!0;return(async()=>{try{let F="",t=!1,e=[],BB=void 0;for(let GB=0;GB<5;GB++){let JB=await q.api.folders[":folderId"].search.$post({param:{folderId:E},json:{assetType:"file",after:F,first:200,recursively:!1,conditions:[]}});if(!JB.ok)throw Error("Failed to search parent folder for carousel");let v=await JB.json(),c=v.data||[];if(e.push(...c),c.some((sB)=>sB.id===z)){t=!0,BB=v.pageInfo?.cursor||void 0;break}if(!v.pageInfo?.cursor||c.length<200)break;F=v.pageInfo.cursor}if(B)if(t)I({show:!0,files:e,nextCursor:BB,folderId:E});else I({show:!1,files:[],nextCursor:void 0,folderId:E})}catch(F){if(console.error(F),B)I({show:!1,files:[],nextCursor:void 0,folderId:E})}})(),()=>{B=!1}},[E,z,A.folderId]),Y.useEffect(()=>{M(0),C(null),P([])},[U?.id]),Y.useEffect(()=>{C(null),P([])},[l?.id]),lB&&!U)return G(kB,{});if(nB||!U||!x||!Z)return G("div",{children:yB.file_not_found()});let m=O?l:U,i=m?.id??z,aB=(B,K)=>{if(!Z)return;CB({param:{fileId:i},json:[{key:B,value:K}]},{onSuccess:()=>{hB.invalidateQueries({queryKey:["files",i]})}})},u=(B)=>{h({to:"/projects/$projectId/files/$fileId",params:{projectId:J,fileId:X},search:(K)=>({...K,...B})})},rB=()=>{u({compare:void 0,cmpLeft:void 0,cmpRight:void 0,cmpActive:void 0,version:N==="left"?k:T})},iB=(B)=>{C(B.id||null);let K=B.annotations;if(K&&K.length>0)P(K);else P([]);if(O){if(B.second!==null&&B.second!==void 0)jB({second:B.second,nonce:Date.now()});return}if(B.second!==null&&B.second!==void 0)y.current?.seekTo(B.second),y.current?.pause();else if(K&&K.length>0)y.current?.pause()},s=()=>{P([]),C(null)};return G("div",{className:"h-full flex flex-1 flex-col bg-background",children:D("div",{className:"h-full flex flex-1 overflow-hidden",children:[D("div",{className:"flex-1 relative",children:[oB&&!O&&G("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/50",children:G(p,{className:"h-8 w-8 animate-spin text-foreground"})}),O&&k&&T?G(bB,{versions:V??[],leftId:k,rightId:T,activeSide:N,annotations:L,seekRequest:xB,onActiveSideChange:(B)=>u({cmpActive:B}),onSwitchVersion:(B,K)=>u(B==="left"?{cmpLeft:K}:{cmpRight:K}),onExit:rB,onActiveAssetChange:AB,onPlay:s,onTimeUpdate:M}):G(RB,{file:U,mediaControllerRef:y,onPlay:s,onTimeUpdate:M,annotations:L,startTime:w,children:A.show&&G(OB,{projectId:J,currentAssetId:z,parentFolderId:E,initialFiles:A.files,initialNextCursor:A.nextCursor})})]}),(!H||W)&&D(zB,{children:[G(DB,{onResize:(B)=>{S((K)=>Math.max(300,Math.min(600,K-B)))},className:"hidden md:block"}),G("div",{style:{width:b},className:"flex-shrink-0 bg-background flex flex-col",children:W?G(gB,{projectId:J,contextAssetId:z}):G(MB,{teamId:Z,projectId:J,file:m,onSaveField:aB,members:FB,onCommentSelect:iB,currentTime:g,onTyping:()=>{if(O)return;y.current?.pause()},selectedCommentId:f,hideAnnotationControl:m?.proxyType==="audio"})})]})]})})}var WB=TB("/projects/$projectId/files/$fileId")({component:eB});export{WB as Route};
|
package/bin/chunk-0at8vxt5.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
function L(G,q,D){return{temperature:q?.temperature,maxTokens:q?.maxTokens,signal:q?.signal,apiKey:D||q?.apiKey,transport:q?.transport,cacheRetention:q?.cacheRetention,sessionId:q?.sessionId,headers:q?.headers,onPayload:q?.onPayload,onResponse:q?.onResponse,timeoutMs:q?.timeoutMs,maxRetries:q?.maxRetries,maxRetryDelayMs:q?.maxRetryDelayMs,metadata:q?.metadata}}function K(G){return G==="xhigh"?"high":G}function y(G,q,D,N){let _={...{minimal:1024,low:2048,medium:8192,high:16384},...N},O=1024,V=K(D),J=_[V],Q=G===void 0?q:Math.min(G+J,q);if(Q<=J)J=Math.max(0,Q-1024);return{maxTokens:Q,thinkingBudget:J}}function j(G,q){let D=[],N=!1;for(let Y of G){if(Y.type==="image"){if(!N)D.push({type:"text",text:q});N=!0;continue}D.push(Y),N=Y.text===q}return D}function U(G,q){if(q.input.includes("image"))return G;return G.map((D)=>{if(D.role==="user"&&Array.isArray(D.content))return{...D,content:j(D.content,"(image omitted: model does not support images)")};if(D.role==="toolResult")return{...D,content:j(D.content,"(tool image omitted: model does not support images)")};return D})}function W(G,q,D){let N=new Map,_=U(G,q).map((E)=>{if(E.role==="user")return E;if(E.role==="toolResult"){let A=N.get(E.toolCallId);if(A&&A!==E.toolCallId)return{...E,toolCallId:A};return E}if(E.role==="assistant"){let A=E,H=A.provider===q.provider&&A.api===q.api&&A.model===q.id,$=A.content.flatMap((F)=>{if(F.type==="thinking"){if(F.redacted)return H?F:[];if(H&&F.thinkingSignature)return F;if(!F.thinking||F.thinking.trim()==="")return[];if(H)return F;return{type:"text",text:F.thinking}}if(F.type==="text"){if(H)return F;return{type:"text",text:F.text}}if(F.type==="toolCall"){let X=F,Z=X;if(!H&&X.thoughtSignature)Z={...X},delete Z.thoughtSignature;if(!H&&D){let w=D(X.id,q,A);if(w!==X.id)N.set(X.id,w),Z={...Z,id:w}}return Z}return F});return{...A,content:$}}return E}),O=[],V=[],J=new Set,Q=()=>{if(V.length>0){for(let E of V)if(!J.has(E.id))O.push({role:"toolResult",toolCallId:E.id,toolName:E.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});V=[],J=new Set}};for(let E=0;E<_.length;E++){let A=_[E];if(A.role==="assistant"){Q();let H=A;if(H.stopReason==="error"||H.stopReason==="aborted")continue;let $=H.content.filter((F)=>F.type==="toolCall");if($.length>0)V=$,J=new Set;O.push(A)}else if(A.role==="toolResult")J.add(A.toolCallId),O.push(A);else if(A.role==="user")Q(),O.push(A);else O.push(A)}return Q(),O}
|
|
3
|
-
export{L as xb,y as yb,W as zb};
|
package/bin/chunk-0zv7f9ca.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{rb as C,sb as j,tb as v,ub as T,vb as I,wb as B}from"./chunk-k5w64spz.js";import{xb as M}from"./chunk-0at8vxt5.js";import{Ab as P}from"./chunk-22dje1f5.js";import{ie as L,je as K,ke as G}from"./chunk-7rhjej0x.js";import{Oj as F,Qj as y,Rj as H}from"./chunk-mjan6b09.js";import"./chunk-kbzm1pwx.js";var b="v1",k="gcp-vertex-credentials",g={THINKING_LEVEL_UNSPECIFIED:F.THINKING_LEVEL_UNSPECIFIED,MINIMAL:F.MINIMAL,LOW:F.LOW,MEDIUM:F.MEDIUM,HIGH:F.HIGH},m=0,S=(q,w,J)=>{let Y=new G;return(async()=>{let Q={role:"assistant",content:[],api:"google-vertex",provider:q.provider,model:q.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let W=p(J),z=W?u(q,W,J?.headers):d(q,r(J),s(J),J?.headers),N=i(q,w,J),R=await J?.onPayload?.(N,q);if(R!==void 0)N=R;let x=await z.models.generateContentStream(N);Y.push({type:"start",partial:Q});let Z=null,A=Q.content,X=()=>A.length-1;for await(let D of x){Q.responseId||=D.responseId;let V=D.candidates?.[0];if(V?.content?.parts)for(let $ of V.content.parts){if($.text!==void 0){let _=C($);if(!Z||_&&Z.type!=="thinking"||!_&&Z.type!=="text"){if(Z)if(Z.type==="text")Y.push({type:"text_end",contentIndex:A.length-1,content:Z.text,partial:Q});else Y.push({type:"thinking_end",contentIndex:X(),content:Z.thinking,partial:Q});if(_)Z={type:"thinking",thinking:"",thinkingSignature:void 0},Q.content.push(Z),Y.push({type:"thinking_start",contentIndex:X(),partial:Q});else Z={type:"text",text:""},Q.content.push(Z),Y.push({type:"text_start",contentIndex:X(),partial:Q})}if(Z.type==="thinking")Z.thinking+=$.text,Z.thinkingSignature=j(Z.thinkingSignature,$.thoughtSignature),Y.push({type:"thinking_delta",contentIndex:X(),delta:$.text,partial:Q});else Z.text+=$.text,Z.textSignature=j(Z.textSignature,$.thoughtSignature),Y.push({type:"text_delta",contentIndex:X(),delta:$.text,partial:Q})}if($.functionCall){if(Z){if(Z.type==="text")Y.push({type:"text_end",contentIndex:X(),content:Z.text,partial:Q});else Y.push({type:"thinking_end",contentIndex:X(),content:Z.thinking,partial:Q});Z=null}let _=$.functionCall.id,E={type:"toolCall",id:!_||Q.content.some((U)=>U.type==="toolCall"&&U.id===_)?`${$.functionCall.name}_${Date.now()}_${++m}`:_,name:$.functionCall.name||"",arguments:$.functionCall.args??{},...$.thoughtSignature&&{thoughtSignature:$.thoughtSignature}};Q.content.push(E),Y.push({type:"toolcall_start",contentIndex:X(),partial:Q}),Y.push({type:"toolcall_delta",contentIndex:X(),delta:JSON.stringify(E.arguments),partial:Q}),Y.push({type:"toolcall_end",contentIndex:X(),toolCall:E,partial:Q})}}if(V?.finishReason){if(Q.stopReason=B(V.finishReason),Q.content.some(($)=>$.type==="toolCall"))Q.stopReason="toolUse"}if(D.usageMetadata)Q.usage={input:(D.usageMetadata.promptTokenCount||0)-(D.usageMetadata.cachedContentTokenCount||0),output:(D.usageMetadata.candidatesTokenCount||0)+(D.usageMetadata.thoughtsTokenCount||0),cacheRead:D.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:D.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},L(q,Q.usage)}if(Z)if(Z.type==="text")Y.push({type:"text_end",contentIndex:X(),content:Z.text,partial:Q});else Y.push({type:"thinking_end",contentIndex:X(),content:Z.thinking,partial:Q});if(J?.signal?.aborted)throw Error("Request was aborted");if(Q.stopReason==="aborted"||Q.stopReason==="error")throw Error("An unknown error occurred");Y.push({type:"done",reason:Q.stopReason,message:Q}),Y.end()}catch(W){for(let z of Q.content)if("index"in z)delete z.index;Q.stopReason=J?.signal?.aborted?"aborted":"error",Q.errorMessage=W instanceof Error?W.message:JSON.stringify(W),Y.push({type:"error",reason:Q.stopReason,error:Q}),Y.end()}})(),Y},Wq=(q,w,J)=>{let Y=M(q,J,void 0);if(!J?.reasoning)return S(q,w,{...Y,thinking:{enabled:!1}});let Q=K(q,J.reasoning),W=Q==="off"?"high":Q,z=q;if(O(z)||h(z))return S(q,w,{...Y,thinking:{enabled:!0,level:e(W,z)}});return S(q,w,{...Y,thinking:{enabled:!0,budgetTokens:t(z,W,J.thinkingBudgets)}})};function d(q,w,J,Y){return new H({vertexai:!0,project:w,location:J,apiVersion:b,httpOptions:f(q,Y)})}function u(q,w,J){return new H({vertexai:!0,apiKey:w,apiVersion:b,httpOptions:f(q,J)})}function f(q,w){let J={},Y=a(q.baseUrl);if(Y){if(J.baseUrl=Y,J.baseUrlResourceScope=y.COLLECTION,c(Y))J.apiVersion=""}if(q.headers||w)J.headers={...q.headers,...w};return Object.keys(J).length>0?J:void 0}function a(q){let w=q.trim();if(!w||w.includes("{location}"))return;return w}function c(q){try{return new URL(q).pathname.split("/").some((J)=>/^v\d+(?:beta\d*)?$/.test(J))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(q)}}function p(q){let w=q?.apiKey?.trim()||process.env.GOOGLE_CLOUD_API_KEY?.trim();if(!w||w===k||l(w))return;return w}function l(q){return/^<[^>]+>$/.test(q)}function r(q){let w=q?.project||process.env.GOOGLE_CLOUD_PROJECT||process.env.GCLOUD_PROJECT;if(!w)throw Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return w}function s(q){let w=q?.location||process.env.GOOGLE_CLOUD_LOCATION;if(!w)throw Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return w}function i(q,w,J={}){let Y=v(q,w),Q={};if(J.temperature!==void 0)Q.temperature=J.temperature;if(J.maxTokens!==void 0)Q.maxOutputTokens=J.maxTokens;let W={...Object.keys(Q).length>0&&Q,...w.systemPrompt&&{systemInstruction:P(w.systemPrompt)},...w.tools&&w.tools.length>0&&{tools:T(w.tools)}};if(w.tools&&w.tools.length>0&&J.toolChoice)W.toolConfig={functionCallingConfig:{mode:I(J.toolChoice)}};else W.toolConfig=void 0;if(J.thinking?.enabled&&q.reasoning){let N={includeThoughts:!0};if(J.thinking.level!==void 0)N.thinkingLevel=g[J.thinking.level];else if(J.thinking.budgetTokens!==void 0)N.thinkingBudget=J.thinking.budgetTokens;W.thinkingConfig=N}else if(q.reasoning&&J.thinking&&!J.thinking.enabled)W.thinkingConfig=n(q);if(J.signal){if(J.signal.aborted)throw Error("Request aborted");W.abortSignal=J.signal}return{model:q.id,contents:Y,config:W}}function O(q){return/gemini-3(?:\.\d+)?-pro/.test(q.id.toLowerCase())}function h(q){return/gemini-3(?:\.\d+)?-flash/.test(q.id.toLowerCase())}function n(q){let w=q;if(O(w))return{thinkingLevel:F.LOW};if(h(w))return{thinkingLevel:F.MINIMAL};return{thinkingBudget:0}}function e(q,w){if(O(w))switch(q){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}switch(q){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}function t(q,w,J){if(J?.[w]!==void 0)return J[w];if(q.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[w];if(q.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[w];return-1}export{Wq as streamSimpleGoogleVertex,S as streamGoogleVertex};
|
package/bin/chunk-2k4vp654.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{lb as T,mb as C,nb as L}from"./chunk-2vs3evc7.js";import"./chunk-dypsm6m2.js";import{pb as S}from"./chunk-9n0etqsy.js";import{qb as M}from"./chunk-7ddaxdpf.js";import{xb as D}from"./chunk-0at8vxt5.js";import"./chunk-22dje1f5.js";import"./chunk-wv4fe1fj.js";import{je as V,ke as f}from"./chunk-7rhjej0x.js";import{le as F}from"./chunk-n6jgyv4y.js";import{Cj as k}from"./chunk-w4y97tzy.js";import"./chunk-yhj8c5re.js";import"./chunk-kbzm1pwx.js";var B="v1",E=new Set(["openai","openai-codex","opencode","azure-openai-responses"]);function I(G){let Q=new Map;if(!G)return Q;for(let w of G.split(",")){let W=w.trim();if(!W)continue;let[X,J]=W.split("=",2);if(!X||!J)continue;Q.set(X.trim(),J.trim())}return Q}function P(G,Q){if(Q?.azureDeploymentName)return Q.azureDeploymentName;return I(process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(G.id)||G.id}function g(G){if(G instanceof Error){let Q=G.status,w=typeof Q==="number"?Q:void 0;if(w!==void 0)return`Azure OpenAI API error (${w}): ${G.message}`;return G.message}try{return JSON.stringify(G)}catch{return String(G)}}var O=(G,Q,w)=>{let W=new f;return(async()=>{let X=P(G,w),J={role:"assistant",content:[],api:"azure-openai-responses",provider:G.provider,model:G.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let Y=w?.apiKey||F(G.provider)||"",$=K(G,Y,w),q=N(G,Q,w,X),H=await w?.onPayload?.(q,G);if(H!==void 0)q=H;let _={...w?.signal?{signal:w.signal}:{},...w?.timeoutMs!==void 0?{timeout:w.timeoutMs}:{},...w?.maxRetries!==void 0?{maxRetries:w.maxRetries}:{}},{data:j,response:Z}=await $.responses.create(q,_).withResponse();if(await w?.onResponse?.({status:Z.status,headers:M(Z.headers)},G),W.push({type:"start",partial:J}),await L(j,J,W,G),w?.signal?.aborted)throw Error("Request was aborted");if(J.stopReason==="aborted"||J.stopReason==="error")throw Error("An unknown error occurred");W.push({type:"done",reason:J.stopReason,message:J}),W.end()}catch(Y){for(let $ of J.content)delete $.index,delete $.partialJson;J.stopReason=w?.signal?.aborted?"aborted":"error",J.errorMessage=g(Y),W.push({type:"error",reason:J.stopReason,error:J}),W.end()}})(),W},d=(G,Q,w)=>{let W=w?.apiKey||F(G.provider);if(!W)throw Error(`No API key for provider: ${G.provider}`);let X=D(G,w,W),J=w?.reasoning?V(G,w.reasoning):void 0;return O(G,Q,{...X,reasoningEffort:J==="off"?void 0:J})};function h(G){let Q=G.trim().replace(/\/+$/,""),w;try{w=new URL(Q)}catch{throw Error(`Invalid Azure OpenAI base URL: ${G}`)}let W=w.hostname.endsWith(".openai.azure.com")||w.hostname.endsWith(".cognitiveservices.azure.com"),X=w.pathname.replace(/\/+$/,"");if(W&&(X===""||X==="/"||X==="/openai"))w.pathname="/openai/v1",w.search="";return w.toString().replace(/\/+$/,"")}function z(G){return`https://${G}.openai.azure.com/openai/v1`}function b(G,Q){let w=Q?.azureApiVersion||process.env.AZURE_OPENAI_API_VERSION||B,W=Q?.azureBaseUrl?.trim()||process.env.AZURE_OPENAI_BASE_URL?.trim()||void 0,X=Q?.azureResourceName||process.env.AZURE_OPENAI_RESOURCE_NAME,J=W;if(!J&&X)J=z(X);if(!J&&G.baseUrl)J=G.baseUrl;if(!J)throw Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");return{baseUrl:h(J),apiVersion:w}}function K(G,Q,w){if(!Q){if(!process.env.AZURE_OPENAI_API_KEY)throw Error("Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.");Q=process.env.AZURE_OPENAI_API_KEY}let W={...G.headers};if(w?.headers)Object.assign(W,w.headers);let{baseUrl:X,apiVersion:J}=b(G,w);return new k({apiKey:Q,apiVersion:J,dangerouslyAllowBrowser:!0,defaultHeaders:W,baseURL:X})}function N(G,Q,w,W){let X=T(G,Q,E),J={model:W,input:X,stream:!0,prompt_cache_key:S(w?.sessionId)};if(w?.maxTokens)J.max_output_tokens=w?.maxTokens;if(w?.temperature!==void 0)J.temperature=w?.temperature;if(Q.tools&&Q.tools.length>0)J.tools=C(Q.tools);if(G.reasoning){if(w?.reasoningEffort||w?.reasoningSummary){let Y=w?.reasoningEffort?G.thinkingLevelMap?.[w.reasoningEffort]??w.reasoningEffort:"medium";J.reasoning={effort:Y,summary:w?.reasoningSummary||"auto"},J.include=["reasoning.encrypted_content"]}else if(G.thinkingLevelMap?.off!==null)J.reasoning={effort:G.thinkingLevelMap?.off??"none"}}return J}export{d as streamSimpleAzureOpenAIResponses,O as streamAzureOpenAIResponses};
|
package/bin/chunk-2s5a64nr.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as S}from"./chunk-dgx2zxze.js";import{Q as Jz,R as Xz,S as Yz,T as Zz,U as _z}from"./chunk-q4f5vvtx.js";import{Va as $z}from"./chunk-kpy0kpna.js";import{Xa as A}from"./chunk-ajqsprm0.js";import{nf as H}from"./chunk-8wv3kdz9.js";import{Jf as zz}from"./chunk-j8q688sx.js";import{$f as Hz,Dh as b,Eg as a,Ng as n,Pi as B,Wg as r,Yg as o,_h as e,ag as M,bg as z,bh as R,cg as J,ch as t,fg as c,hh as f,hj as Y,ij as Gz,mi as h,vi as s}from"./chunk-nwtb6dt1.js";import{Zj as Fz}from"./chunk-kbzm1pwx.js";var _=Fz(Hz(),1);function Sz({projectId:P,contextAssetId:v}){let{isHistoryMode:U,setIsHistoryMode:u,currentSessionId:qz,chatAssets:p,removeAsset:Kz,messages:D,historySessions:I,isStreaming:O,fetchHistorySessions:g,loadSession:Qz,deleteSession:Uz,startNewSession:Vz,sendMessage:Wz,abortActiveSession:Lz,selectedAgentId:E,setSelectedAgentId:T}=H(),{teamId:Z,ensureTeamIdForProject:l}=Gz();_.useEffect(()=>{if(P)l(P)},[P,l]);let{data:Nz=[]}=c({queryKey:["agents",Z],queryFn:async()=>{if(!Z)return[];let G=await a.api.teams[":teamId"].agents.$get({param:{teamId:Z}});if(!G.ok)throw Error("failed to fetch agents");return G.json()},enabled:!!Z}),C=Nz.filter((G)=>G.type==="chat"&&G.enabled);_.useEffect(()=>{if(C.length>0){if(!C.some((X)=>X.id===E))T(C[0].id)}},[C,E,T]);let[F,m]=_.useState(""),j=_.useRef(null),y=_.useRef(null),w=_.useRef(!0),k=_.useRef(!0);_.useEffect(()=>{k.current=!0,w.current=!0},[P,v,U]),_.useEffect(()=>{let G=y.current?.querySelector('[data-slot="scroll-area-viewport"]');if(!G)return;let{scrollTop:X,isAtBottom:$}=H.getState(),Q=setTimeout(()=>{if($)G.scrollTop=G.scrollHeight;else G.scrollTop=X;let L=setTimeout(()=>{k.current=!1},50);return()=>clearTimeout(L)},0);return()=>clearTimeout(Q)},[P,v,U]),_.useEffect(()=>{let G=y.current?.querySelector('[data-slot="scroll-area-viewport"]');if(!G)return;let X=()=>{if(k.current)return;let $=G.scrollTop,Q=G.scrollHeight-$-G.clientHeight<10;H.getState().setScrollState($,Q)};return G.addEventListener("scroll",X),()=>{G.removeEventListener("scroll",X)}},[P,v,U]);let{ref:Pz,isDropTarget:Oz}=$z({id:"chatbot-sidebar",data:{type:"chatbot-sidebar"}});_.useEffect(()=>{if(!U){let{isAtBottom:G}=H.getState();if(G||O){let X=w.current?"auto":"smooth";j.current?.scrollIntoView({behavior:X})}w.current=!1}},[D,O,U]),_.useEffect(()=>{if(U&&Z)g(Z)},[U,g,Z]);let d=()=>{if(!F.trim()||O||!Z)return;Wz(Z,F,P,v),m("")},Dz=(G)=>{if(G.nativeEvent.isComposing)return;if(G.key==="Enter"&&!G.shiftKey)G.preventDefault(),d()},i=(G)=>{if(typeof G==="string")return G;if(Array.isArray(G))return G.map((X)=>{if(typeof X==="string")return X;if(X&&typeof X==="object"&&"type"in X&&X.type==="text"&&"text"in X)return String(X.text);return""}).join("");return""},x=(G)=>{return G.replace(/<@([a-zA-Z0-9_-]+)>/g,"@$1").replace(/^\[([^\]]+)\]:/gm,"\\[$1\\]:")},Cz=(G)=>{switch(G.role){case"user":return z("div",{className:"flex justify-end w-full",children:z("div",{className:"bg-primary text-primary-foreground rounded-lg px-3 py-2 max-w-[85%] text-sm whitespace-pre-wrap shadow-xs break-words",children:i(G.content)})},G.id);case"assistant":{let $=G.content;if(!$)return null;let Q=[];if($.forEach((q,V)=>{if(!q||typeof q!=="object")return;let W=q;switch(W.type){case"text":{let K=W.text;if(typeof K!=="string"||!K.trim())return;Q.push(z("div",{className:"text-sm leading-[1.8] prose prose-sm dark:prose-invert max-w-none break-words",children:z(S,{components:{pre:({node:N,...Ez})=>z("pre",{className:"whitespace-pre-wrap break-all break-words bg-muted text-foreground p-4 rounded-md border border-border/50 font-mono text-sm",...Ez})},children:x(K)})},`txt-${V}`));break}case"thinking":{let K=W.thinking;if(typeof K!=="string"||!K.trim())return;Q.push(J("details",{className:"group border border-border/50 rounded-lg bg-muted/20 my-2 overflow-hidden",children:[J("summary",{className:"flex items-center gap-2 p-2.5 text-xs font-medium text-muted-foreground select-none cursor-pointer hover:bg-muted/40 transition-colors list-none [&::-webkit-details-marker]:hidden",children:[z(t,{className:"h-3.5 w-3.5 text-primary/70 animate-pulse"}),z("span",{children:Y.role_thinking()||"Thinking"}),z(f,{className:"h-3 w-3 ml-auto transition-transform group-open:rotate-180"})]}),z("div",{className:"p-3 pt-0 text-xs text-muted-foreground/90 border-t border-border/40 bg-muted/10 leading-relaxed prose prose-sm dark:prose-invert max-w-none whitespace-pre-wrap font-sans",children:z(S,{children:x(K)})})]},`think-${V}`));break}case"toolCall":{let K=String(W.name||W.toolName||Y.unknown()),N=W.arguments||W.args;Q.push(J("details",{className:"group border border-border/50 rounded-lg bg-violet-500/5 my-2 overflow-hidden",children:[J("summary",{className:"flex items-center gap-2 p-2.5 text-xs font-semibold text-violet-600 dark:text-violet-400 select-none cursor-pointer hover:bg-violet-500/10 transition-colors list-none [&::-webkit-details-marker]:hidden",children:[z(s,{className:"h-3.5 w-3.5"}),z("span",{children:Y.calling_tool()}),z("span",{className:"font-mono bg-violet-500/10 px-1.5 py-0.5 rounded text-[11px] text-violet-700 dark:text-violet-300",children:K}),z(f,{className:"h-3 w-3 ml-auto transition-transform group-open:rotate-180"})]}),!!N&&J("div",{className:"p-3 pt-0 text-[10px] text-muted-foreground/90 border-t border-border/40 bg-violet-500/5 font-sans",children:[z("div",{className:"text-[9px] text-muted-foreground/60 uppercase font-bold tracking-wider mb-1.5",children:Y.tool_arguments()||"Arguments"}),z("pre",{className:"font-mono bg-muted/30 p-2 rounded border border-border/30 overflow-x-auto max-h-32",children:JSON.stringify(N,null,2)})]})]},`tool-${V}`));break}case"image":{let K=String(W.mimeType||"image/png"),N=String(W.data||"");Q.push(z("div",{className:"my-2 max-w-full",children:N?z("img",{src:N.startsWith("data:")?N:`data:${K};base64,${N}`,alt:"Attached asset",className:"max-h-60 rounded border border-border/50 object-contain shadow-xs"}):z("div",{className:"text-xs text-muted-foreground italic flex items-center gap-1.5 py-1",children:Y.image_object()})},`img-${V}`));break}default:{let K=JSON.stringify(q,null,2);if(K==="{}")return;Q.push(z("pre",{className:"text-xs text-foreground/80 font-mono whitespace-pre-wrap break-words bg-muted/20 p-2 rounded",children:K},`other-${V}`))}}}),Q.length===0)return null;let L=!1;if($.length>0){let q=$[$.length-1];if(typeof q==="string"&&q.trim().length>0)L=!0;else if(q&&typeof q==="object"){let V=q;if(V.type==="text"&&typeof V.text==="string"&&V.text.trim().length>0)L=!0}}return J("div",{className:"flex flex-col w-full space-y-1",children:[z("div",{className:"space-y-2 w-full",children:Q}),L&&z("div",{className:"text-[10px] text-muted-foreground self-start italic pt-1",children:Y.created_by_agent()})]},G.id)}case"toolResult":return z("div",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-muted/40 p-2 rounded-md border border-border/50",children:z("span",{className:"font-semibold",children:Y.tool_result_with_name({name:G.toolName||"tool"})})},G.id);case"thinking_level_change":case"custom":{let X=G;if(X.customType==="context_display_info"){let L=X.details?.assets||[];if(L.length===0)return null;return J("div",{className:"text-xs text-muted-foreground bg-muted/40 p-2.5 rounded-lg border border-border/50 space-y-1 my-1",children:[z("div",{className:"font-semibold",children:Y.assets_added_to_context()}),z("ul",{className:"list-disc list-inside space-y-0.5",children:L.map((q)=>J("li",{className:"truncate",children:[q.name," ",J("span",{className:"text-muted-foreground/70",children:["(",q.type,")"]})]},q.id))})]},G.id)}let $=X.content||"";return z("div",{className:"text-center text-xs text-muted-foreground italic bg-muted/20 py-1.5 rounded",children:i($)},G.id)}default:return null}};return J("div",{ref:Pz,className:B("relative flex flex-col h-full bg-background transition-colors duration-200 min-h-0"),children:[Oz&&z("div",{className:"absolute inset-0 bg-accent/30 border-2 border-primary z-50 pointer-events-none flex items-center justify-center p-6 text-center animate-in fade-in duration-150",children:J("div",{className:"bg-background/95 text-foreground px-4 py-3 rounded-xl border border-border/80 flex flex-col items-center gap-2 shadow-lg max-w-[80%] animate-in zoom-in-95 duration-150",children:[z(R,{className:"h-6 w-6 text-primary animate-bounce"}),z("span",{className:"text-sm font-semibold text-foreground",children:Y.chatbot_drag_drop_hint()||"Drop assets here"})]})}),z("div",{className:"flex items-center justify-between p-4 pt-[0.7rem] flex-shrink-0",children:U?J(M,{children:[z("div",{className:"flex items-center gap-2 font-semibold",children:z("span",{children:Y.history()})}),z("button",{onClick:()=>u(!1),className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:"Close History",children:z(r,{className:"h-4 w-4"})})]}):J(M,{children:[z("div",{className:"flex items-center gap-2 font-semibold",children:z("span",{children:Y.shumai_agent()})}),J("div",{className:"flex items-center gap-1",children:[z("button",{onClick:Vz,className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:Y.new_chat(),children:z(e,{className:"h-4 w-4"})}),z("button",{onClick:()=>u(!0),className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:Y.history(),children:z(b,{className:"h-4 w-4"})})]})]})}),U?z(A,{className:"flex-1 p-4 min-h-0",children:I.length===0?J("div",{className:"flex flex-col items-center justify-center h-48 text-muted-foreground p-4 text-center",children:[z(b,{className:"h-8 w-8 mb-2 opacity-50 text-muted-foreground"}),z("p",{className:"text-sm",children:Y.no_history_sessions()})]}):z("div",{className:"space-y-2 pb-4",children:I.map((G)=>{let X=G.id===qz;return J("div",{className:B("group relative flex items-center justify-between p-3 border rounded-lg transition-all cursor-pointer bg-card",X?"border-primary":"border-border hover:bg-accent/30"),children:[J("div",{onClick:()=>Z&&Qz(Z,G.id),className:"flex-1 min-w-0 pr-6",children:[z("div",{className:"text-sm font-semibold text-foreground truncate",children:G.name||Y.new_chat()}),z("div",{className:"text-xs text-muted-foreground mt-0.5",children:zz(G.createdAt)})]}),z("button",{onClick:($)=>{if($.stopPropagation(),Z&&confirm(Y.delete_session_confirm()))Uz(Z,G.id)},className:"absolute right-3 opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity text-muted-foreground hover:text-destructive p-1 rounded hover:bg-muted",title:"Delete Session",children:z(h,{className:"h-4 w-4"})})]},G.id)})})}):J(M,{children:[z(A,{ref:y,className:"flex-1 p-4 min-h-0 [&>div>div]:!block",children:D.length===0?J("div",{className:"flex flex-col items-center justify-center h-48 border-2 border-dashed border-border rounded-lg text-muted-foreground p-4 text-center",children:[z(R,{className:"h-8 w-8 mb-2 opacity-50 text-muted-foreground"}),z("p",{className:"text-sm",children:Y.chatbot_drag_drop_hint()})]}):J("div",{className:"space-y-4 pb-4",children:[D.map(Cz),O&&D.length>0&&D[D.length-1].role==="user"&&J("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground italic",children:[z(n,{className:"h-3 w-3 animate-spin text-primary"}),z("span",{children:"Thinking..."})]}),z("div",{ref:j})]})}),z("div",{className:"p-2 flex-shrink-0 bg-background",children:J("div",{className:"relative flex flex-col w-full border border-foreground/20 rounded-2xl shadow-xs transition-all duration-200 focus-within:ring-2 focus-within:ring-primary focus-within:border-transparent bg-background overflow-hidden",children:[p.length>0&&z("div",{className:"flex flex-col gap-1.5 min-h-0 max-h-[160px] overflow-y-auto border-b border-border bg-muted/5 p-3 divide-y divide-border/50",children:p.map((G)=>J("div",{className:"flex items-center justify-between py-1.5 text-xs group",children:[J("div",{className:"flex items-baseline gap-1.5 min-w-0 pr-2",children:[z("span",{className:"truncate font-medium text-foreground",children:G.name}),z("span",{className:"text-[9px] text-muted-foreground uppercase flex-shrink-0",children:G.type})]}),z("button",{onClick:()=>Kz(G.id),className:"text-muted-foreground hover:text-destructive transition-colors p-0.5",title:Y.remove_from_context(),children:z(h,{className:"h-3.5 w-3.5"})})]},G.id))}),z("textarea",{value:F,onChange:(G)=>m(G.target.value),onKeyDown:Dz,placeholder:"Type a message...",rows:2,className:"w-full bg-transparent border-none focus:ring-0 focus:outline-hidden resize-none min-h-[44px] max-h-[120px] px-3 py-2 text-sm focus-visible:outline-hidden focus:ring-transparent focus:border-transparent focus-visible:ring-0",disabled:O}),J("div",{className:"flex justify-between items-center px-3 pb-2 pt-1",children:[z("div",{className:"flex items-center gap-1.5 min-w-0 max-w-[70%]",children:C.length>0?J(Jz,{value:E||"",onValueChange:(G)=>T(G),disabled:O,children:[z(Yz,{className:"h-8 border-none bg-transparent hover:bg-muted text-muted-foreground hover:text-foreground focus:ring-0 focus:ring-offset-0 px-2 py-0 gap-1.5 text-xs shrink-0 select-none shadow-none max-w-full",children:z(Xz,{placeholder:Y.select_agent()})}),z(Zz,{children:C.map((G)=>z(_z,{value:G.id,children:J("div",{className:"flex items-center gap-2",children:[G.avatar?z("img",{src:G.avatar,alt:G.name,className:"w-4 h-4 rounded-full object-cover"}):z(R,{className:"w-4 h-4 text-muted-foreground"}),z("span",{className:"text-xs",children:G.name})]})},G.id))})]}):z("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] text-muted-foreground/60 italic select-none",children:z("span",{children:Y.no_chat_agents_warning()})})}),O?z("button",{onClick:()=>{if(Z)Lz(Z)},className:"p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 shadow-sm bg-destructive text-destructive-foreground hover:bg-destructive/90 transform hover:-translate-y-0.5",title:"Stop generation",children:z("div",{className:"h-4 w-4 flex items-center justify-center",children:z("div",{className:"h-3 w-3 bg-current rounded-[2px] bg-white"})})}):z("button",{onClick:d,disabled:!F.trim()||!E,className:B("p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 shadow-sm",F.trim()&&E?"bg-primary text-primary-foreground hover:bg-primary/95 transform hover:-translate-y-0.5":"bg-muted text-muted-foreground cursor-not-allowed opacity-50"),children:z(o,{className:"h-4 w-4"})})]})]})})]})]})}
|
|
2
|
-
export{Sz as g};
|
package/bin/chunk-2tbya52d.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import"./chunk-xg9xscqz.js";import{Vb as I,lc as w}from"./chunk-ac2ky3q0.js";import"./chunk-kbzm1pwx.js";function R(q,$){if(typeof q==="string"&&typeof $==="string")return q.toLowerCase()===$.toLowerCase();return q===$}function y(q,$){if(typeof q!=="string")return $.includes(q);return $.some((E)=>typeof E==="string"&&q.toLowerCase()===E.toLowerCase())}function j(q,$){return!y(q,$)}function g(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().includes($.toLowerCase())}function f(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().startsWith($.toLowerCase())}function V(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().endsWith($.toLowerCase())}var v=(q,$)=>{let E=null,M=w({config:{adapterId:"memory",adapterName:"Memory Adapter",usePlural:!1,debugLogs:$?.debugLogs||!1,supportsArrays:!0,customTransformInput(P){if(P.options.advanced?.database?.generateId==="serial"&&P.field==="id"&&P.action==="create")return q[P.model].length+1;return P.data},transaction:async(P)=>{let A=structuredClone(q);try{return await P(M(E))}catch(_){throw Object.keys(q).forEach((S)=>{q[S]=A[S]}),_}}},adapter:({getFieldName:P,getDefaultFieldName:A,options:_,getModelName:S})=>{let N=(x,K,Y)=>{if(!K)return x;return x.sort((L,Z)=>{let z=P({model:Y,field:K.field}),D=L[z],X=Z[z],Q=0;if(D==null&&X==null)Q=0;else if(D==null)Q=-1;else if(X==null)Q=1;else if(typeof D==="string"&&typeof X==="string")Q=D.localeCompare(X);else if(D instanceof Date&&X instanceof Date)Q=D.getTime()-X.getTime();else if(typeof D==="number"&&typeof X==="number")Q=D-X;else if(typeof D==="boolean"&&typeof X==="boolean")Q=D===X?0:D?1:-1;else Q=String(D).localeCompare(String(X));return K.direction==="asc"?Q:-Q})};function F(x,K,Y,L){let Z=(()=>{let X=q[K];if(!X)throw I.error(`[MemoryAdapter] Model ${K} not found in the DB`,Object.keys(q)),Error(`Model ${K} not found`);let Q=(G,O)=>{let{field:J,value:H,operator:B,mode:k="sensitive"}=O,U=k==="insensitive"&&(typeof H==="string"||Array.isArray(H)&&H.every((W)=>typeof W==="string"));switch(B){case"in":if(!Array.isArray(H))throw Error("Value must be an array");if(U)return y(G[J],H);return H.includes(G[J]);case"not_in":if(!Array.isArray(H))throw Error("Value must be an array");if(U)return j(G[J],H);return!H.includes(G[J]);case"contains":if(U)return g(G[J],H);return G[J]?.includes(H);case"starts_with":if(U)return f(G[J],H);return G[J].startsWith(H);case"ends_with":if(U)return V(G[J],H);return G[J].endsWith(H);case"ne":return U?!R(G[J],H):G[J]!==H;case"gt":return H!=null&&Boolean(G[J]>H);case"gte":return H!=null&&Boolean(G[J]>=H);case"lt":return H!=null&&Boolean(G[J]<H);case"lte":return H!=null&&Boolean(G[J]<=H);default:if(U)return R(G[J],H);if(H===null)return G[J]==null;return G[J]===H}},T=X.filter((G)=>{if(!x.length||x.length===0)return!0;let O=Q(G,x[0]);for(let J of x){let H=Q(G,J);if(J.connector==="OR")O=O||H;else O=O&&H}return O});if(L?.length&&L.length>0)T=T.map((G)=>Object.fromEntries(Object.entries(G).filter(([O])=>L.includes(A({model:K,field:O})))));return T})();if(!Y)return Z;let z=new Map,D=new Map;for(let X of Z){let Q=String(X.id);if(!z.has(Q)){let G={...X};for(let[O,J]of Object.entries(Y)){let H=S(O);if(J.relation==="one-to-one")G[H]=null;else G[H]=[],D.set(`${Q}-${O}`,new Set)}z.set(Q,G)}let T=z.get(Q);for(let[G,O]of Object.entries(Y)){let J=S(G),H=q[J];if(!H)throw I.error(`[MemoryAdapter] JoinOption model ${J} not found in the DB`,Object.keys(q)),Error(`JoinOption model ${J} not found`);let B=H.filter((k)=>k[O.on.to]===X[O.on.from]);if(O.relation==="one-to-one")T[J]=B[0]||null;else{let k=D.get(`${Q}-${G}`),U=O.limit??100,W=0;for(let C of B){if(W>=U)break;if(!k.has(C.id))T[J].push(C),k.add(C.id),W++}}}}return Array.from(z.values())}return{create:async({model:x,data:K})=>{if(_.advanced?.database?.generateId==="serial")K.id=q[S(x)].length+1;if(!q[x])q[x]=[];return q[x].push(K),K},findOne:async({model:x,where:K,select:Y,join:L})=>{let Z=F(K,x,L,Y);if(L){let z=Z;if(!z.length)return null;return z[0]}return Z[0]||null},findMany:async({model:x,where:K,sortBy:Y,limit:L,select:Z,offset:z,join:D})=>{let X=F(K||[],x,D,Z);if(D){let T=X;if(!T.length)return[];N(T,Y,x);let G=T;if(z!==void 0)G=G.slice(z);if(L!==void 0)G=G.slice(0,L);return G}let Q=N(X,Y,x);if(z!==void 0)Q=Q.slice(z);if(L!==void 0)Q=Q.slice(0,L);return Q||[]},count:async({model:x,where:K})=>{if(K)return F(K,x).length;return q[x].length},update:async({model:x,where:K,update:Y})=>{let L=F(K,x);return L.forEach((Z)=>{Object.assign(Z,Y)}),L[0]||null},delete:async({model:x,where:K})=>{let Y=q[x],L=F(K,x);q[x]=Y.filter((Z)=>!L.includes(Z))},deleteMany:async({model:x,where:K})=>{let Y=q[x],L=F(K,x),Z=0;return q[x]=Y.filter((z)=>{if(L.includes(z))return Z++,!1;return!L.includes(z)}),Z},consumeOne:async({model:x,where:K})=>{let Y=q[x],L=F(K,x)[0];if(!L)return null;return q[x]=Y.filter((Z)=>Z!==L),L},updateMany({model:x,where:K,update:Y}){let L=F(K,x);return L.forEach((Z)=>{Object.assign(Z,Y)}),L[0]||null}}}});return(P)=>{return E=P,M(P)}};export{v as memoryAdapter};
|
package/bin/chunk-2vs3evc7.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{ob as f}from"./chunk-dypsm6m2.js";import{zb as j}from"./chunk-0at8vxt5.js";import{Ab as U}from"./chunk-22dje1f5.js";import{ge as H}from"./chunk-wv4fe1fj.js";import{ie as J}from"./chunk-7rhjej0x.js";function M(Q,E){let W={v:1,id:Q};if(E)W.phase=E;return JSON.stringify(W)}function R(Q){if(!Q)return;if(Q.startsWith("{"))try{let E=JSON.parse(Q);if(E.v===1&&typeof E.id==="string"){if(E.phase==="commentary"||E.phase==="final_answer")return{id:E.id,phase:E.phase};return{id:E.id}}}catch{}return{id:Q}}function b(Q,E,W,L){let D=[],N=(G)=>{let O=G.replace(/[^a-zA-Z0-9_-]/g,"_");return(O.length>64?O.slice(0,64):O).replace(/_+$/,"")},A=(G)=>{let O=`fc_${f(G)}`;return O.length>64?O.slice(0,64):O},w=(G,O,X)=>{if(!W.has(Q.provider))return N(G);if(!G.includes("|"))return N(G);let[V,F]=G.split("|"),$=N(V),Y=X.provider!==Q.provider||X.api!==Q.api?A(F):N(F);if(!Y.startsWith("fc_"))Y=N(`fc_${Y}`);return`${$}|${Y}`},Z=j(E.messages,Q,w);if((L?.includeSystemPrompt??!0)&&E.systemPrompt){let G=Q.reasoning?"developer":"system";D.push({role:G,content:U(E.systemPrompt)})}let q=0;for(let G of Z){if(G.role==="user")if(typeof G.content==="string")D.push({role:"user",content:[{type:"input_text",text:U(G.content)}]});else{let O=G.content.map((X)=>{if(X.type==="text")return{type:"input_text",text:U(X.text)};return{type:"input_image",detail:"auto",image_url:`data:${X.mimeType};base64,${X.data}`}});if(O.length===0)continue;D.push({role:"user",content:O})}else if(G.role==="assistant"){let O=[],X=G,V=X.model!==Q.id&&X.provider===Q.provider&&X.api===Q.api;for(let F of G.content)if(F.type==="thinking"){if(F.thinkingSignature){let $=JSON.parse(F.thinkingSignature);O.push($)}}else if(F.type==="text"){let $=F,_=R($.textSignature),Y=_?.id;if(!Y)Y=`msg_${q}`;else if(Y.length>64)Y=`msg_${f(Y)}`;O.push({type:"message",role:"assistant",content:[{type:"output_text",text:U($.text),annotations:[]}],status:"completed",id:Y,phase:_?.phase})}else if(F.type==="toolCall"){let $=F,[_,Y]=$.id.split("|"),y=Y;if(V&&y?.startsWith("fc_"))y=void 0;O.push({type:"function_call",id:y,call_id:_,name:$.name,arguments:JSON.stringify($.arguments)})}if(O.length===0)continue;D.push(...O)}else if(G.role==="toolResult"){let O=G.content.filter((_)=>_.type==="text").map((_)=>_.text).join(`
|
|
3
|
-
`),X=G.content.some((_)=>_.type==="image"),V=O.length>0,[F]=G.toolCallId.split("|"),$;if(X&&Q.input.includes("image")){let _=[];if(V)_.push({type:"input_text",text:U(O)});for(let Y of G.content)if(Y.type==="image")_.push({type:"input_image",detail:"auto",image_url:`data:${Y.mimeType};base64,${Y.data}`});$=_}else $=U(V?O:"(see attached image)");D.push({type:"function_call_output",call_id:F,output:$})}q++}return D}function x(Q,E){let W=E?.strict===void 0?!1:E.strict;return Q.map((L)=>({type:"function",name:L.name,description:L.description,parameters:L.parameters,strict:W}))}async function B(Q,E,W,L,D){let N=null,A=null,w=E.content,Z=()=>w.length-1;for await(let K of Q)if(K.type==="response.created")E.responseId=K.response.id;else if(K.type==="response.output_item.added"){let q=K.item;if(q.type==="reasoning")N=q,A={type:"thinking",thinking:""},E.content.push(A),W.push({type:"thinking_start",contentIndex:Z(),partial:E});else if(q.type==="message")N=q,A={type:"text",text:""},E.content.push(A),W.push({type:"text_start",contentIndex:Z(),partial:E});else if(q.type==="function_call")N=q,A={type:"toolCall",id:`${q.call_id}|${q.id}`,name:q.name,arguments:{},partialJson:q.arguments||""},E.content.push(A),W.push({type:"toolcall_start",contentIndex:Z(),partial:E})}else if(K.type==="response.reasoning_summary_part.added"){if(N&&N.type==="reasoning")N.summary=N.summary||[],N.summary.push(K.part)}else if(K.type==="response.reasoning_summary_text.delta"){if(N?.type==="reasoning"&&A?.type==="thinking"){N.summary=N.summary||[];let q=N.summary[N.summary.length-1];if(q)A.thinking+=K.delta,q.text+=K.delta,W.push({type:"thinking_delta",contentIndex:Z(),delta:K.delta,partial:E})}}else if(K.type==="response.reasoning_summary_part.done"){if(N?.type==="reasoning"&&A?.type==="thinking"){N.summary=N.summary||[];let q=N.summary[N.summary.length-1];if(q)A.thinking+=`
|
|
4
|
-
|
|
5
|
-
`,q.text+=`
|
|
6
|
-
|
|
7
|
-
`,W.push({type:"thinking_delta",contentIndex:Z(),delta:`
|
|
8
|
-
|
|
9
|
-
`,partial:E})}}else if(K.type==="response.reasoning_text.delta"){if(N?.type==="reasoning"&&A?.type==="thinking")A.thinking+=K.delta,W.push({type:"thinking_delta",contentIndex:Z(),delta:K.delta,partial:E})}else if(K.type==="response.content_part.added"){if(N?.type==="message"){if(N.content=N.content||[],K.part.type==="output_text"||K.part.type==="refusal")N.content.push(K.part)}}else if(K.type==="response.output_text.delta"){if(N?.type==="message"&&A?.type==="text"){if(!N.content||N.content.length===0)continue;let q=N.content[N.content.length-1];if(q?.type==="output_text")A.text+=K.delta,q.text+=K.delta,W.push({type:"text_delta",contentIndex:Z(),delta:K.delta,partial:E})}}else if(K.type==="response.refusal.delta"){if(N?.type==="message"&&A?.type==="text"){if(!N.content||N.content.length===0)continue;let q=N.content[N.content.length-1];if(q?.type==="refusal")A.text+=K.delta,q.refusal+=K.delta,W.push({type:"text_delta",contentIndex:Z(),delta:K.delta,partial:E})}}else if(K.type==="response.function_call_arguments.delta"){if(N?.type==="function_call"&&A?.type==="toolCall")A.partialJson+=K.delta,A.arguments=H(A.partialJson),W.push({type:"toolcall_delta",contentIndex:Z(),delta:K.delta,partial:E})}else if(K.type==="response.function_call_arguments.done"){if(N?.type==="function_call"&&A?.type==="toolCall"){let q=A.partialJson;if(A.partialJson=K.arguments,A.arguments=H(A.partialJson),K.arguments.startsWith(q)){let G=K.arguments.slice(q.length);if(G.length>0)W.push({type:"toolcall_delta",contentIndex:Z(),delta:G,partial:E})}}}else if(K.type==="response.output_item.done"){let q=K.item;if(q.type==="reasoning"&&A?.type==="thinking"){let G=q.summary?.map((X)=>X.text).join(`
|
|
10
|
-
|
|
11
|
-
`)||"",O=q.content?.map((X)=>X.text).join(`
|
|
12
|
-
|
|
13
|
-
`)||"";A.thinking=G||O||A.thinking,A.thinkingSignature=JSON.stringify(q),W.push({type:"thinking_end",contentIndex:Z(),content:A.thinking,partial:E}),A=null}else if(q.type==="message"&&A?.type==="text")A.text=q.content.map((G)=>G.type==="output_text"?G.text:G.refusal).join(""),A.textSignature=M(q.id,q.phase??void 0),W.push({type:"text_end",contentIndex:Z(),content:A.text,partial:E}),A=null;else if(q.type==="function_call"){let G=A?.type==="toolCall"&&A.partialJson?H(A.partialJson):H(q.arguments||"{}"),O;if(A?.type==="toolCall")A.arguments=G,delete A.partialJson,O=A;else O={type:"toolCall",id:`${q.call_id}|${q.id}`,name:q.name,arguments:G};A=null,W.push({type:"toolcall_end",contentIndex:Z(),toolCall:O,partial:E})}}else if(K.type==="response.completed"){let q=K.response;if(q?.id)E.responseId=q.id;if(q?.usage){let G=q.usage.input_tokens_details?.cached_tokens||0;E.usage={input:(q.usage.input_tokens||0)-G,output:q.usage.output_tokens||0,cacheRead:G,cacheWrite:0,totalTokens:q.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(J(L,E.usage),D?.applyServiceTierPricing){let G=D.resolveServiceTier?D.resolveServiceTier(q?.service_tier,D.serviceTier):q?.service_tier??D.serviceTier;D.applyServiceTierPricing(E.usage,G)}if(E.stopReason=C(q?.status),E.content.some((G)=>G.type==="toolCall")&&E.stopReason==="stop")E.stopReason="toolUse"}else if(K.type==="error")throw Error(`Error Code ${K.code}: ${K.message}`||"Unknown error");else if(K.type==="response.failed"){let q=K.response?.error,G=K.response?.incomplete_details,O=q?`${q.code||"unknown"}: ${q.message||"no message"}`:G?.reason?`incomplete: ${G.reason}`:"Unknown error (no error details in response)";throw Error(O)}}function C(Q){if(!Q)return"stop";switch(Q){case"completed":return"stop";case"incomplete":return"length";case"failed":case"cancelled":return"error";case"in_progress":case"queued":return"stop";default:throw Error(`Unhandled stop reason: ${Q}`)}}
|
|
14
|
-
export{b as lb,x as mb,B as nb};
|
package/bin/chunk-33169en9.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{lb as I,mb as s,nb as k}from"./chunk-2vs3evc7.js";import"./chunk-dypsm6m2.js";import{pb as o}from"./chunk-9n0etqsy.js";import{qb as b}from"./chunk-7ddaxdpf.js";import{xb as t}from"./chunk-0at8vxt5.js";import"./chunk-22dje1f5.js";import{Hb as e,Ib as f,Jb as NN,Kb as QN}from"./chunk-3rt9mnj3.js";import"./chunk-wv4fe1fj.js";import{je as r,ke as n}from"./chunk-7rhjej0x.js";import{le as g}from"./chunk-n6jgyv4y.js";import"./chunk-yhj8c5re.js";import"./chunk-kbzm1pwx.js";var zN=function(N,Q){if(typeof N==="string"&&/^\.\.?\//.test(N))return N.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(V,X,Y,Z,G){return X?Q?".jsx":".js":Y&&(!Z||!G)?V:Y+Z+"."+G.toLowerCase()+"js"});return N},B=null,VN=(N)=>import(zN(N)),RN="node:os";if(typeof process<"u"&&(process.versions?.node||process.versions?.bun))VN(RN).then((N)=>{B=N});var KN="https://chatgpt.com/backend-api",ON="https://api.openai.com/auth",x=3,l=1000,XN=new Set(["openai","openai-codex","opencode"]),_N=1009,UN=new Set(["completed","incomplete","failed","cancelled","queued","in_progress"]);function jN(N,Q){if(N===429||N===500||N===502||N===503||N===504)return!0;return/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(Q)}function p(N,Q){return new Promise((V,X)=>{if(Q?.aborted){X(Error("Request was aborted"));return}let Y=setTimeout(V,N);Q?.addEventListener("abort",()=>{clearTimeout(Y),X(Error("Request was aborted"))})})}var WN=(N,Q,V)=>{let X=new n;return(async()=>{let Y={role:"assistant",content:[],api:"openai-codex-responses",provider:N.provider,model:N.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let Z=V?.apiKey||g(N.provider)||"";if(!Z)throw Error(`No API key for provider: ${N.provider}`);let G=pN(Z),$=AN(N,Q,V),F=await V?.onPayload?.($,N);if(F!==void 0)$=F;let L=V?.sessionId||iN(),_=dN(N.headers,V?.headers,G,Z,V?.sessionId),j=aN(N.headers,V?.headers,G,Z,L),J=JSON.stringify($),O=V?.transport||"auto",P=O!=="sse"&&DN(V?.sessionId);if(P)i(V?.sessionId);if(O!=="sse"&&!P){let K=!1;try{if(await cN(HN(N.baseUrl),$,j,Y,X,N,()=>{K=!0},V),V?.signal?.aborted)throw Error("Request was aborted");X.push({type:"done",reason:Y.stopReason,message:Y}),X.end();return}catch(z){if(V?.signal?.aborted||qN(z))throw z;if(QN(Y,NN("provider_transport_failure",z,{configuredTransport:O,fallbackTransport:K?void 0:"sse",eventsEmitted:K,phase:K?"after_message_stream_start":"before_message_stream_start",requestBytes:new TextEncoder().encode(J).byteLength})),SN(V?.sessionId,z),K)throw z;i(V?.sessionId)}}let D,R;for(let K=0;K<=x;K++){if(V?.signal?.aborted)throw Error("Request was aborted");try{if(D=await fetch($N(N.baseUrl),{method:"POST",headers:_,body:J,signal:V?.signal}),await V?.onResponse?.({status:D.status,headers:b(D.headers)},N),D.ok)break;let z=await D.text();if(K<x&&jN(D.status,z)){let q=l*2**K,m=D.headers.get("retry-after-ms");if(m!==null){let A=Number(m);if(Number.isFinite(A))q=Math.max(0,A)}else{let A=D.headers.get("retry-after");if(A){let u=Number(A);if(Number.isFinite(u))q=Math.max(0,u*1000);else{let c=Date.parse(A);if(!Number.isNaN(c))q=Math.max(0,c-Date.now())}}}await p(q,V?.signal);continue}let M=new Response(z,{status:D.status,statusText:D.statusText}),y=await lN(M);throw Error(y.friendlyMessage||y.message)}catch(z){if(z instanceof Error){if(z.name==="AbortError"||z.message==="Request was aborted")throw Error("Request was aborted")}if(R=z instanceof Error?z:Error(String(z)),K<x&&!R.message.includes("usage limit")){let M=l*2**K;await p(M,V?.signal);continue}throw R}}if(!D?.ok)throw R??Error("Failed after retries");if(!D.body)throw Error("No response body");if(X.push({type:"start",partial:Y}),await MN(D,Y,X,N,V),V?.signal?.aborted)throw Error("Request was aborted");X.push({type:"done",reason:Y.stopReason,message:Y}),X.end()}catch(Z){for(let G of Y.content)delete G.partialJson;Y.stopReason=V?.signal?.aborted?"aborted":"error",Y.errorMessage=Z instanceof Error?Z.message:String(Z),X.push({type:"error",reason:Y.stopReason,error:Y}),X.end()}})(),X},XQ=(N,Q,V)=>{let X=V?.apiKey||g(N.provider);if(!X)throw Error(`No API key for provider: ${N.provider}`);let Y=t(N,V,X),Z=V?.reasoning?r(N,V.reasoning):void 0;return WN(N,Q,{...Y,reasoningEffort:Z==="off"?void 0:Z})};function AN(N,Q,V){let X=I(N,Q,XN,{includeSystemPrompt:!1}),Y={model:N.id,store:!1,stream:!0,instructions:Q.systemPrompt||"You are a helpful assistant.",input:X,text:{verbosity:V?.textVerbosity||"low"},include:["reasoning.encrypted_content"],prompt_cache_key:o(V?.sessionId),tool_choice:"auto",parallel_tool_calls:!0};if(V?.temperature!==void 0)Y.temperature=V.temperature;if(V?.serviceTier!==void 0)Y.service_tier=V.serviceTier;if(Q.tools&&Q.tools.length>0)Y.tools=s(Q.tools,{strict:null});if(V?.reasoningEffort!==void 0){let Z=V.reasoningEffort==="none"?N.thinkingLevelMap?.off??"none":N.thinkingLevelMap?.[V.reasoningEffort]??V.reasoningEffort;if(Z!==null)Y.reasoning={effort:Z,summary:V.reasoningSummary??"auto"}}return Y}function BN(N,Q){switch(Q){case"flex":return 0.5;case"priority":return N.id==="gpt-5.5"?2.5:2;default:return 1}}function YN(N,Q,V){let X=BN(V,Q);if(X===1)return;N.cost.input*=X,N.cost.output*=X,N.cost.cacheRead*=X,N.cost.cacheWrite*=X,N.cost.total=N.cost.input+N.cost.output+N.cost.cacheRead+N.cost.cacheWrite}function ZN(N,Q){if(N==="default"&&(Q==="flex"||Q==="priority"))return Q;return N??Q}function $N(N){let V=(N&&N.trim().length>0?N:KN).replace(/\/+$/,"");if(V.endsWith("/codex/responses"))return V;if(V.endsWith("/codex"))return`${V}/responses`;return`${V}/codex/responses`}function HN(N){let Q=new URL($N(N));if(Q.protocol==="https:")Q.protocol="wss:";if(Q.protocol==="http:")Q.protocol="ws:";return Q.toString()}async function MN(N,Q,V,X,Y){await k(GN(TN(N)),Q,V,X,{serviceTier:Y?.serviceTier,resolveServiceTier:ZN,applyServiceTierPricing:(Z,G)=>YN(Z,G,X)})}class C extends Error{code;payload;constructor(N,Q){super(N);this.name="CodexApiError",this.code=Q?.code,this.payload=Q?.payload,this.cause=Q?.cause}}class S extends Error{payload;constructor(N,Q){super(N);this.name="CodexProtocolError",this.payload=Q?.payload,this.cause=Q?.cause}}function qN(N){return N instanceof C||N instanceof S}async function*GN(N){for await(let Q of N){let V=typeof Q.type==="string"?Q.type:void 0;if(!V)continue;if(V==="error"){let X=Q.code||"",Y=Q.message||"";throw new C(`Codex error: ${Y||X||JSON.stringify(Q)}`,{code:X||void 0,payload:Q})}if(V==="response.failed"){let X=Q.response,Y=X?.error?.code,Z=X?.error?.message;throw new C(Z||"Codex response failed",{code:Y,payload:Q})}if(V==="response.done"||V==="response.completed"||V==="response.incomplete"){let X=Q.response,Y=X?{...X,status:wN(X.status)}:X;yield{...Q,type:"response.completed",response:Y};return}yield Q}}function wN(N){if(typeof N!=="string")return;return UN.has(N)?N:void 0}async function*TN(N){if(!N.body)return;let Q=N.body.getReader(),V=new TextDecoder,X="";try{while(!0){let{done:Y,value:Z}=await Q.read();if(Y)break;X+=V.decode(Z,{stream:!0});let G=X.indexOf(`
|
|
3
|
-
|
|
4
|
-
`);while(G!==-1){let $=X.slice(0,G);X=X.slice(G+2);let F=$.split(`
|
|
5
|
-
`).filter((L)=>L.startsWith("data:")).map((L)=>L.slice(5).trim());if(F.length>0){let L=F.join(`
|
|
6
|
-
`).trim();if(L&&L!=="[DONE]")try{yield JSON.parse(L)}catch(_){throw new S(`Invalid Codex SSE JSON: ${f(_)}`,{cause:_,payload:L})}}G=X.indexOf(`
|
|
7
|
-
|
|
8
|
-
`)}}}finally{try{await Q.cancel()}catch{}try{Q.releaseLock()}catch{}}}var CN="responses_websockets=2026-02-06",EN=300000,U=new Map,H=new Map,E=new Set;function v(N){let Q=H.get(N);if(!Q)Q={requests:0,connectionsCreated:0,connectionsReused:0,cachedContextRequests:0,storeTrueRequests:0,fullContextRequests:0,deltaRequests:0,lastInputItems:0,websocketFailures:0,sseFallbacks:0},H.set(N,Q);return Q}function YQ(N){let Q=H.get(N);return Q?{...Q}:void 0}function ZQ(N){if(N){H.delete(N),E.delete(N);return}H.clear(),E.clear()}function fN(N){let Q=(V)=>{if(V.idleTimer)clearTimeout(V.idleTimer);W(V.socket,1000,"debug_close")};if(N){let V=U.get(N);if(V)Q(V);U.delete(N);return}for(let V of U.values())Q(V);U.clear()}e(fN);function DN(N){return N?E.has(N):!1}function i(N){if(!N)return;let Q=v(N);Q.sseFallbacks++,Q.websocketFallbackActive=DN(N)}function SN(N,Q){if(!N)return;E.add(N);let V=v(N);V.websocketFailures++,V.lastWebSocketError=f(Q),V.websocketFallbackActive=!0}var w=null;async function xN(){if(w)return w;if(process?.versions?.bun&&(process.env.HTTP_PROXY||process.env.HTTPS_PROXY||process.env.http_proxy||process.env.https_proxy)){let V=(await VN("proxy-from-env")).getProxyForUrl;return w=class extends WebSocket{constructor(X,Y){let Z={};if(Array.isArray(Y)||typeof Y==="string")Z={protocols:Y};else Z={...Y};let G=V(X.toString().replace(/^wss:/,"https:").replace(/^ws:/,"http:"));super(X,{...Z,...G?{proxy:G}:{}})}},w}let N=globalThis.WebSocket;if(typeof N!=="function")return null;return N}class FN extends Error{code;reason;wasClean;constructor(N,Q){super(N);this.name="WebSocketCloseError",this.code=Q?.code,this.reason=Q?.reason,this.wasClean=Q?.wasClean}}function hN(N){let Q=N.readyState;return typeof Q==="number"?Q:void 0}function T(N){let Q=hN(N);return Q===void 0||Q===1}function W(N,Q=1000,V="done"){try{N.close(Q,V)}catch{}}function d(N,Q){if(Q.idleTimer)clearTimeout(Q.idleTimer);Q.idleTimer=setTimeout(()=>{if(Q.busy)return;W(Q.socket,1000,"idle_timeout"),U.delete(N)},EN)}async function h(N,Q,V){let X=await xN();if(!X)throw Error("WebSocket transport is not available in this runtime");let Y=b(Q);return delete Y["OpenAI-Beta"],new Promise((Z,G)=>{let $=!1,F;try{F=new X(N,{headers:Y})}catch(P){G(P instanceof Error?P:Error(String(P)));return}let L=()=>{if($)return;$=!0,O(),Z(F)},_=(P)=>{let D=LN(P);if($)return;$=!0,O(),G(D)},j=(P)=>{let D=JN(P);if($)return;$=!0,O(),G(D)},J=()=>{if($)return;$=!0,O(),F.close(1000,"aborted"),G(Error("Request was aborted"))},O=()=>{F.removeEventListener("open",L),F.removeEventListener("error",_),F.removeEventListener("close",j),V?.removeEventListener("abort",J)};F.addEventListener("open",L),F.addEventListener("error",_),F.addEventListener("close",j),V?.addEventListener("abort",J)})}async function gN(N,Q,V,X){if(!V){let $=await h(N,Q,X);return{socket:$,reused:!1,release:({keep:F}={})=>{if(F===!1){W($);return}W($)}}}let Y=U.get(V);if(Y){if(Y.idleTimer)clearTimeout(Y.idleTimer),Y.idleTimer=void 0;if(!Y.busy&&T(Y.socket))return Y.busy=!0,{socket:Y.socket,entry:Y,reused:!0,release:({keep:$}={})=>{if(!$||!T(Y.socket)){W(Y.socket),U.delete(V);return}Y.busy=!1,d(V,Y)}};if(Y.busy){let $=await h(N,Q,X);return{socket:$,reused:!1,release:()=>{W($)}}}if(!T(Y.socket))W(Y.socket),U.delete(V)}let Z=await h(N,Q,X),G={socket:Z,busy:!0};return U.set(V,G),{socket:Z,entry:G,reused:!1,release:({keep:$}={})=>{if(!$||!T(G.socket)){if(W(G.socket),G.idleTimer)clearTimeout(G.idleTimer);if(U.get(V)===G)U.delete(V);return}G.busy=!1,d(V,G)}}}function LN(N){if(N&&typeof N==="object"){let Q="message"in N?N.message:void 0;if(typeof Q==="string"&&Q.length>0)return Error(Q);let V="error"in N?N.error:void 0;if(V instanceof Error&&V.message.length>0)return V;if(V&&typeof V==="object"&&"message"in V){let X=V.message;if(typeof X==="string"&&X.length>0)return Error(X)}}return Error("WebSocket error")}function JN(N){if(N&&typeof N==="object"){let Q="code"in N?N.code:void 0,V="reason"in N?N.reason:void 0,X="wasClean"in N?N.wasClean:void 0,Y=typeof Q==="number"?` ${Q}`:"",Z=typeof V==="string"&&V.length>0?` ${V}`:"";if(!Z&&Q===_N)Z=" message too big";return new FN(`WebSocket closed${Y}${Z}`.trim(),{code:typeof Q==="number"?Q:void 0,reason:typeof V==="string"&&V.length>0?V:void 0,wasClean:typeof X==="boolean"?X:void 0})}return Error("WebSocket closed")}async function bN(N){if(typeof N==="string")return N;if(N instanceof ArrayBuffer)return new TextDecoder().decode(new Uint8Array(N));if(ArrayBuffer.isView(N)){let Q=N;return new TextDecoder().decode(new Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength))}if(N&&typeof N==="object"&&"arrayBuffer"in N){let V=await N.arrayBuffer();return new TextDecoder().decode(new Uint8Array(V))}return null}async function*IN(N,Q){let V=[],X=null,Y=!1,Z=null,G=!1,$=()=>{if(!X)return;let J=X;X=null,J()},F=(J)=>{(async()=>{let O=null;try{if(!J||typeof J!=="object"||!("data"in J))return;if(O=await bN(J.data),!O)return;let P=JSON.parse(O),D=typeof P.type==="string"?P.type:"";if(D==="response.completed"||D==="response.done"||D==="response.incomplete")G=!0,Y=!0;V.push(P),$()}catch(P){Z=new S(`Invalid Codex WebSocket JSON: ${f(P)}`,{cause:P,payload:O}),Y=!0,$()}})()},L=(J)=>{Z=LN(J),Y=!0,$()},_=(J)=>{if(G){Y=!0,$();return}if(!Z)Z=JN(J);Y=!0,$()},j=()=>{Z=Error("Request was aborted"),Y=!0,$()};N.addEventListener("message",F),N.addEventListener("error",L),N.addEventListener("close",_),Q?.addEventListener("abort",j);try{while(!0){if(Q?.aborted)throw Error("Request was aborted");if(V.length>0){yield V.shift();continue}if(Y)break;await new Promise((J)=>{X=J})}if(Z)throw Z;if(!G)throw Error("WebSocket stream closed before response.completed")}finally{N.removeEventListener("message",F),N.removeEventListener("error",L),N.removeEventListener("close",_),Q?.removeEventListener("abort",j)}}function a(N){let{input:Q,previous_response_id:V,...X}=N;return X}function kN(N,Q){return JSON.stringify(N??[])===JSON.stringify(Q??[])}function vN(N,Q){return JSON.stringify(a(N))===JSON.stringify(a(Q))}function yN(N,Q){if(!vN(N,Q.lastRequestBody))return;let V=N.input??[],X=[...Q.lastRequestBody.input??[],...Q.lastResponseItems];if(V.length<X.length)return;let Y=V.slice(0,X.length);if(!kN(Y,X))return;return V.slice(X.length)}function mN(N,Q){let V=N.continuation;if(!V)return Q;let X=yN(Q,V);if(!X||!V.lastResponseId)return N.continuation=void 0,Q;return{...Q,previous_response_id:V.lastResponseId,input:X}}async function*uN(N,Q,V,X){let Y=!1;for await(let Z of N){if(!Y)Y=!0,X(),V.push({type:"start",partial:Q});yield Z}}async function cN(N,Q,V,X,Y,Z,G,$){let{socket:F,entry:L,reused:_,release:j}=await gN(N,V,$?.sessionId,$?.signal),J=!0,O=$?.transport==="websocket-cached"||$?.transport==="auto",P=Q,D=O&&L?mN(L,P):P,R=$?.sessionId?v($.sessionId):void 0;if(R){if(R.requests++,_)R.connectionsReused++;else R.connectionsCreated++;if(O)R.cachedContextRequests++;if(D.store===!0)R.storeTrueRequests++;if(R.lastInputItems=D.input?.length??0,D.previous_response_id)R.deltaRequests++,R.lastDeltaInputItems=D.input?.length??0,R.lastPreviousResponseId=D.previous_response_id;else R.fullContextRequests++,R.lastDeltaInputItems=void 0,R.lastPreviousResponseId=void 0}try{if(F.send(JSON.stringify({type:"response.create",...D})),await k(uN(GN(IN(F,$?.signal)),X,Y,G),X,Y,Z,{serviceTier:$?.serviceTier,resolveServiceTier:ZN,applyServiceTierPricing:(K,z)=>YN(K,z,Z)}),$?.signal?.aborted)J=!1;else if(O&&L&&X.responseId){let K=I(Z,{messages:[X]},XN,{includeSystemPrompt:!1}).filter((z)=>z.type!=="function_call_output");L.continuation={lastRequestBody:P,lastResponseId:X.responseId,lastResponseItems:K}}}catch(K){if(L)L.continuation=void 0;throw J=!1,K}finally{j({keep:J})}}async function lN(N){let Q=await N.text(),V=Q||N.statusText||"Request failed",X;try{let Z=JSON.parse(Q)?.error;if(Z){let G=Z.code||Z.type||"";if(/usage_limit_reached|usage_not_included|rate_limit_exceeded/i.test(G)||N.status===429){let $=Z.plan_type?` (${Z.plan_type.toLowerCase()} plan)`:"",F=Z.resets_at?Math.max(0,Math.round((Z.resets_at*1000-Date.now())/60000)):void 0,L=F!==void 0?` Try again in ~${F} min.`:"";X=`You have hit your ChatGPT usage limit${$}.${L}`.trim()}V=Z.message||X||V}}catch{}return{message:V,friendlyMessage:X}}function pN(N){try{let Q=N.split(".");if(Q.length!==3)throw Error("Invalid token");let X=JSON.parse(atob(Q[1]))?.[ON]?.chatgpt_account_id;if(!X)throw Error("No account ID in token");return X}catch{throw Error("Failed to extract accountId from token")}}function iN(){if(typeof globalThis.crypto?.randomUUID==="function")return globalThis.crypto.randomUUID();return`codex_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function PN(N,Q,V,X){let Y=new Headers(N);for(let[G,$]of Object.entries(Q||{}))Y.set(G,$);Y.set("Authorization",`Bearer ${X}`),Y.set("chatgpt-account-id",V),Y.set("originator","pi");let Z=B?`pi (${B.platform()} ${B.release()}; ${B.arch()})`:"pi (browser)";return Y.set("User-Agent",Z),Y}function dN(N,Q,V,X,Y){let Z=PN(N,Q,V,X);if(Z.set("OpenAI-Beta","responses=experimental"),Z.set("accept","text/event-stream"),Z.set("content-type","application/json"),Y)Z.set("session_id",Y),Z.set("x-client-request-id",Y);return Z}function aN(N,Q,V,X,Y){let Z=PN(N,Q,V,X);return Z.delete("accept"),Z.delete("content-type"),Z.delete("OpenAI-Beta"),Z.delete("openai-beta"),Z.set("OpenAI-Beta",CN),Z.set("x-client-request-id",Y),Z.set("session_id",Y),Z}export{XQ as streamSimpleOpenAICodexResponses,WN as streamOpenAICodexResponses,ZQ as resetOpenAICodexWebSocketDebugStats,YQ as getOpenAICodexWebSocketDebugStats,fN as closeOpenAICodexWebSocketSessions};
|
package/bin/chunk-33ee1cvv.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Ta as BK,Va as gJ}from"./chunk-kpy0kpna.js";import{Xa as ZJ}from"./chunk-ajqsprm0.js";import{$a as _K,_a as ZK,ab as $K,bb as GK,cb as zK,db as QK,eb as HK,fb as UK}from"./chunk-4hnrd4qh.js";import{Wf as $J}from"./chunk-mnv6pj0k.js";import{$f as NK,Cg as z,Eg as U,Gh as kJ,Mg as zJ,Ng as p,Pi as O,Rg as nJ,Ri as N,Tg as aJ,Vi as QJ,Xi as HJ,Yi as UJ,Zi as w,_h as wJ,ag as iJ,ah as rJ,bg as J,bj as KK,cg as X,dg as lJ,ei as JK,hg as v,hh as oJ,hj as W,ig as _J,jh as sJ,jj as WK,kj as XK,lg as dJ,lh as XJ,lj as TJ,mg as h,mh as YJ,mi as uJ,mj as RJ,ng as GJ,nh as tJ,nj as SJ,oj as fJ,pj as hJ,qj as YK,th as DJ,zh as eJ}from"./chunk-nwtb6dt1.js";import{Zj as vK}from"./chunk-kbzm1pwx.js";var _=vK(NK(),1);function cK({teamId:B,projectId:Z,projectName:$,rootFolderId:P,dragState:b,onSelect:M,selectedFolderId:A,hideCollections:m,hideShares:C,ancestorFolders:D}){let q=GJ(),Q=lJ(),{canEdit:V}=WK(Z),j=dJ({from:"/projects/$projectId/recently-deleted",shouldThrow:!1}),[L,r]=_.useState(!0),[T,BJ]=_.useState(!0),[u,bJ]=_.useState(!0),{data:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:R}=_J({queryKey:["shares",Z],queryFn:async({pageParam:K})=>{let Y=await U.api.projects[":projectId"].shares.$get({param:{projectId:Z},query:{first:"20",after:K}});if(!Y.ok)throw Error(W.failed_fetch_share_links());return await Y.json()},initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0,enabled:!!Z}),{data:l,fetchNextPage:o,hasNextPage:d,isFetchingNextPage:n}=_J({queryKey:["collections",Z],queryFn:async({pageParam:K})=>{let Y=await U.api.projects[":projectId"].collections.$get({param:{projectId:Z},query:{first:"20",after:K}});if(!Y.ok)throw Error(W.failed_fetch_collections());return await Y.json()},initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0,enabled:!!Z}),{ref:qJ,inView:s}=$J(),{ref:VJ,inView:t}=$J();_.useEffect(()=>{if(s&&d&&!n)o()},[s,d,n,o]),_.useEffect(()=>{if(t&&g&&!R)i()},[t,g,R,i]);let AJ=_.useMemo(()=>l?.pages.flatMap((K)=>K.data)||[],[l]),OJ=_.useMemo(()=>c?.pages.flatMap((K)=>K.data)||[],[c]),{mutate:PJ}=v({mutationFn:async()=>{let K=await U.api.projects[":projectId"].collections.$post({param:{projectId:Z},json:{name:W.untitled_collection(),filter:{sourceFolderId:P,searchFilter:{conditions:[],recursively:!0}}}});if(!K.ok)throw Error(W.failed_create_collection());return await K.json()},onSuccess:(K)=>{Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_created()),q({to:"/projects/$projectId/collections/$collectionId",params:{projectId:Z,collectionId:K.id}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:MJ}=v({mutationFn:async()=>{let K=await U.api.projects[":projectId"].shares.$post({param:{projectId:Z},json:{name:new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}});if(!K.ok)throw Error(W.failed_create_share_link());return await K.json()},onSuccess:(K)=>{Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_created()),q({to:"/projects/$projectId/shares/$shareId",params:{projectId:Z,shareId:K.id}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),e=h({from:"/projects/$projectId/collections/$collectionId",shouldThrow:!1}),LJ=h({from:"/projects/$projectId/shares/$shareId",shouldThrow:!1}),G=h({from:"/projects/$projectId/folders/$folderId",shouldThrow:!1}),[y,yJ]=_.useState(null),[F,EJ]=_.useState("collection"),[E,JJ]=_.useState(""),[qK,k]=_.useState(!1),[vJ,NJ]=_.useState(null),[S,CJ]=_.useState("collection"),[VK,f]=_.useState(!1),{mutate:IJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.folders[":folderId"].$put({param:{folderId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_folder());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["search",B]}),Q.invalidateQueries({queryKey:["folders"]}),z.success(W.folder_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:AK}=v({mutationFn:async(K)=>{if(!(await U.api.folders.$delete({json:{ids:[K]}})).ok)throw Error(W.failed_delete_folder());return K},onSuccess:(K)=>{if(Q.invalidateQueries({queryKey:["search",B]}),Q.invalidateQueries({queryKey:["folders"]}),z.success(W.folder_deleted()),f(!1),G?.folderId===K)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),[OK,a]=_.useState(!1),[KJ,xJ]=_.useState(!1),[FJ,pJ]=_.useState([]),PK=async(K)=>{a(!0),xJ(!0),pJ([]);try{let Y=await U.api.files["download-links"].$post({json:{ids:[K]}});if(!Y.ok)throw Error(W.failed_to_prepare_download_links());let H=await Y.json();pJ(H.files)}catch(Y){z.error(W.failed_to_prepare_download_links()),a(!1),console.error(Y)}finally{xJ(!1)}},MK=()=>{let K=[...FJ];if(a(!1),K.length===0)return;z.info(W.starting_download_files({count:K.length}),{duration:5000});let Y=(WJ)=>new Promise((I)=>setTimeout(I,WJ));(async()=>{for(let I=0;I<K.length;I+=5){let EK=K.slice(I,I+5);for(let cJ of EK){let x=document.createElement("a");x.href=cJ.url,x.download=cJ.name,x.target="_blank",document.body.appendChild(x),x.click(),x.remove()}await Y(1000)}})().catch((WJ)=>{console.error("Background downloads failed:",WJ),z.error(W.some_downloads_failed())})},{mutate:mJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.collections[":collectionId"].$patch({param:{collectionId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_collection());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:LK}=v({mutationFn:async(K)=>{let Y=await U.api.collections[":collectionId"].$delete({param:{collectionId:K}});if(!Y.ok)throw Error(W.failed_delete_collection());return await Y.json()},onSuccess:(K,Y)=>{if(Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_deleted()),f(!1),e?.collectionId===Y)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:jJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.shares[":shareId"].$put({param:{shareId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_share_link());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:yK}=v({mutationFn:async(K)=>{if(!(await U.api.shares[":shareId"].$delete({param:{shareId:K}})).ok)throw Error(W.failed_delete_share_link());return K},onSuccess:(K)=>{if(Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_deleted()),f(!1),LJ?.shareId===K)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}});return X("div",{className:"flex flex-col h-full overflow-hidden p-3 gap-4 bg-background",children:[X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4",L?"flex-1 min-h-[50%] h-full":"flex-none h-[44px] max-h-[44px]"),children:[J("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>r(!L),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.folder_tree_assets()}),L?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]})}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",L?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[J(bK,{teamId:B,projectId:Z,folder:{id:P,name:$,type:"folder",sizeByte:0,fileCount:0,status:"processed",createdAt:"",updatedAt:""},level:0,isRoot:!0,dragState:b,onSelect:M,selectedFolderId:A,canEdit:V,onRenameTrigger:(K,Y)=>{yJ(K),EJ("folder"),JJ(Y),k(!0)},onDeleteTrigger:(K)=>{NJ(K),CJ("folder"),f(!0)},onDownloadTrigger:(K)=>{PK(K)},ancestorFolders:D},P),V&&X("div",{className:O("group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",j&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>q({to:"/projects/$projectId/recently-deleted",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(uJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.recently_deleted()})]})]})})]}),!m&&X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4",T?"flex-1 min-h-0 h-full":"flex-none h-[44px] max-h-[44px]"),children:[X("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:[X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>BJ(!T),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.collections()}),T?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]}),V&&J("button",{onClick:()=>PJ(),className:"text-muted-foreground hover:text-foreground flex-none",children:J(wJ,{className:"h-3.5 w-3.5"})})]}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",T?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[X("div",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>q({to:"/projects/$projectId/collections",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(kJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.all_collections_count({count:l?.pages[0]?.pageInfo?.total||0})})]}),AJ.map((K)=>{let Y=e?.collectionId===K.id;return X("div",{className:O("group flex cursor-pointer items-center justify-between rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",Y&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>q({to:"/projects/$projectId/collections/$collectionId",params:{projectId:Z,collectionId:K.id}}),children:[X("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[J("div",{className:"flex h-4 w-4 items-center justify-center shrink-0",children:J(rJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"truncate text-sidebar-foreground flex-1",children:K.name})]}),V&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(H)=>H.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[J(w,{onClick:()=>{yJ(K.id),EJ("collection"),JJ(K.name),k(!0)},children:W.rename()}),J(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{NJ(K.id),CJ("collection"),f(!0)},children:W.delete()})]})]})})]},K.id)}),J("div",{ref:qJ,className:"h-1"}),n&&J("div",{className:"flex justify-center p-2",children:J(p,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]})})]}),!C&&X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out",u?"flex-1 min-h-0 h-full":"flex-none h-[44px] max-h-[44px]"),children:[X("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:[X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>bJ(!u),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.share_links()}),u?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]}),V&&J("div",{className:"flex items-center gap-1 flex-none",children:J("button",{onClick:()=>MJ(),className:"text-muted-foreground hover:text-foreground",children:J(wJ,{className:"h-3.5 w-3.5"})})})]}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",u?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[X("div",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>q({to:"/projects/$projectId/shares",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(kJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.all_share_links_count({count:c?.pages[0]?.pageInfo?.total||0})})]}),OJ.map((K)=>J(CK,{link:K,projectId:Z,dragState:b,canEdit:V,onRenameTrigger:(Y,H)=>{yJ(Y),EJ("share"),JJ(H),k(!0)},onDeleteTrigger:(Y)=>{NJ(Y),CJ("share"),f(!0)}},K.id)),J("div",{ref:VJ,className:"h-1"}),R&&J("div",{className:"flex justify-center p-2",children:J(p,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]})})]}),J(TJ,{open:qK,onOpenChange:k,children:X(RJ,{onClick:(K)=>K.stopPropagation(),children:[J(SJ,{children:J(hJ,{children:F==="collection"?W.rename_collection():F==="share"?W.rename_share_link():W.rename_folder()})}),J("div",{className:"py-4",children:J(XK,{value:E,onChange:(K)=>JJ(K.target.value),placeholder:W.enter_new_name(),onKeyDown:(K)=>{if(K.key==="Enter"&&E.trim()){if(F==="collection")mJ({id:y,name:E});else if(F==="share")jJ({id:y,name:E});else if(F==="folder")IJ({id:y,name:E})}}})}),X(fJ,{children:[J(N,{variant:"ghost",onClick:()=>k(!1),children:W.cancel()}),J(N,{disabled:!E.trim(),onClick:()=>{if(F==="collection")mJ({id:y,name:E});else if(F==="share")jJ({id:y,name:E});else if(F==="folder")IJ({id:y,name:E})},children:W.rename()})]})]})}),J(ZK,{open:VK,onOpenChange:f,children:X(_K,{onClick:(K)=>K.stopPropagation(),children:[X($K,{children:[J(zK,{children:S==="collection"?W.delete_collection_confirm():S==="share"?W.delete_share_link_confirm():W.delete_folder_confirm()}),J(QK,{children:W.delete_confirm_description({type:S==="collection"?W.collection():S==="share"?W.share_link():W.folder().toLowerCase()})})]}),X(GK,{children:[J(UK,{children:W.cancel()}),J(HK,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{if(S==="collection")LK(vJ);else if(S==="share")yK(vJ);else if(S==="folder")AK(vJ)},children:W.delete()})]})]})}),J(TJ,{open:OK,onOpenChange:a,children:X(RJ,{className:"sm:max-w-md",children:[X(SJ,{children:[J(hJ,{children:KJ?W.preparing_download():W.confirm_download()}),J(YK,{children:KJ?W.resolving_files_wait():W.folder_files_download_description()})]}),KJ?X("div",{className:"space-y-4 py-6 flex flex-col items-center justify-center",children:[J(p,{className:"h-8 w-8 animate-spin text-primary"}),J("span",{className:"text-sm font-medium text-muted-foreground mt-2",children:W.preparing_download_links()})]}):X("div",{className:"space-y-4 py-2",children:[J("div",{className:"text-sm text-muted-foreground",children:W.download_includes_files({count:FJ.length})}),X("div",{className:"flex items-start gap-3 p-3 text-sm rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 border border-amber-200 dark:border-amber-900/30",children:[J(aJ,{className:"h-5 w-5 shrink-0 mt-0.5"}),X("div",{children:[J("p",{className:"font-semibold",children:W.no_folder_structure()}),J("p",{className:"mt-0.5 text-xs text-amber-700/90 dark:text-amber-400/90",children:W.folder_structure_warning()})]})]})]}),J(fJ,{children:!KJ?X(iJ,{children:[J(N,{variant:"outline",onClick:()=>a(!1),children:W.cancel()}),X(N,{onClick:MK,className:"gap-2",disabled:FJ.length===0,children:[J(DJ,{className:"h-4 w-4"}),W.start_download()]})]}):J(N,{disabled:!0,variant:"outline",children:W.cancel()})})]})})]})}function CK({link:B,projectId:Z,dragState:$,canEdit:P,onRenameTrigger:b,onDeleteTrigger:M}){let A=GJ(),C=h({from:"/projects/$projectId/shares/$shareId",shouldThrow:!1})?.shareId===B.id,{ref:D,isDropTarget:q}=gJ({id:`share:${B.id}`,data:{type:"share-link",id:B.id}}),Q=!!$?.isActive;return X("div",{ref:D,className:O("group flex cursor-pointer items-center justify-between rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",C&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium",q&&Q&&"bg-sidebar-accent ring-2 ring-primary ring-inset"),onClick:()=>A({to:"/projects/$projectId/shares/$shareId",params:{projectId:Z,shareId:B.id}}),children:[X("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[J("div",{className:"flex h-4 w-4 items-center justify-center shrink-0",children:J(JK,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"truncate text-sidebar-foreground flex-1",children:B.name})]}),P&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(V)=>V.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[J(w,{onClick:()=>{b(B.id,B.name)},children:W.rename()}),J(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{M(B.id)},children:W.delete()})]})]})})]})}function bK({teamId:B,projectId:Z,folder:$,level:P,isRoot:b,dragState:M,onSelect:A,selectedFolderId:m,canEdit:C,onRenameTrigger:D,onDeleteTrigger:q,onDownloadTrigger:Q,ancestorFolders:V}){let j=_.useMemo(()=>{return V?.some((G)=>G.id===$.id)??!1},[V,$.id]),[L,r]=_.useState(b||j);_.useEffect(()=>{if(j)r(!0)},[j]);let T=GJ(),BJ=h({from:"/projects/$projectId/folders/$folderId",select:(G)=>({folderId:G.folderId}),shouldThrow:!1}),u=h({from:"/projects/$projectId/",shouldThrow:!1}),bJ=b?!!u:BJ?.folderId===$.id,{data:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:R,isLoading:l}=_J({queryKey:["folders",$.id,"children",{assetType:"folder"}],queryFn:async({pageParam:G})=>{let y=await U.api.folders[":folderId"].children.$get({param:{folderId:$.id},query:{assetType:"folder",after:G,first:"20"}});if(!y.ok)throw Error(W.failed_to_fetch_folder_children());return await y.json()},initialPageParam:"",getNextPageParam:(G)=>{return G.pageInfo?.cursor||void 0},enabled:L||!!b}),{ref:o,inView:d}=$J();_.useEffect(()=>{if(d&&g&&!R)i()},[d,g,R,i]);let n=c?.pages.flatMap((G)=>G.data??[])??[],qJ=(G)=>{G.stopPropagation(),r(!L)},s=()=>{if(A){A($);return}if(b)T({to:"/projects/$projectId",params:{projectId:Z}});else T({to:"/projects/$projectId/folders/$folderId",params:{projectId:Z,folderId:$.id}})},{ref:VJ,isDragging:t}=BK({id:`tree:${$.id}`,data:{type:"folder",item:$},disabled:!!b||!!A||!C}),{ref:AJ,isDropTarget:OJ}=gJ({id:`tree:${$.id}`,data:{type:"folder",item:$},disabled:M?.draggedIds.has($.id)||!!A||!C}),PJ=(G)=>{VJ(G),AJ(G)},MJ=_.useMemo(()=>{if(A)return!1;if(!M?.isActive)return!1;if(M.draggedIds.has($.id))return!1;return!0},[M,$.id,A]),e=OJ&&MJ,LJ=m===$.id;return X("div",{children:[X("div",{ref:PJ,className:O("group flex cursor-pointer items-center gap-1 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",(bJ||LJ)&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium",t&&"opacity-50",e&&"bg-sidebar-accent ring-2 ring-primary ring-inset"),style:{...b?{}:{paddingLeft:`${P*12+8}px`}},onClick:s,children:[!b&&J("button",{onClick:qJ,className:"flex h-4 w-4 items-center justify-center shrink-0",children:L?J(oJ,{className:"h-3 w-3"}):J(sJ,{className:"h-3 w-3"})}),b?J(tJ,{className:"h-4 w-4 text-sidebar-primary shrink-0"}):J(eJ,{className:"h-4 w-4 text-sidebar-primary shrink-0"}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:$.name}),C&&!b&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(G)=>G.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[X(w,{onClick:()=>{D($.id,$.name)},children:[J(nJ,{className:"mr-2 h-4 w-4"}),W.rename()]}),X(w,{onClick:()=>{Q($.id)},children:[J(DJ,{className:"mr-2 h-4 w-4"}),W.download()]}),J(KK,{}),X(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{q($.id)},children:[J(uJ,{className:"mr-2 h-4 w-4"}),W.delete()]})]})]})})]}),L&&X("div",{children:[l&&J("div",{className:"flex items-center justify-center p-2",style:{paddingLeft:`${(P+1)*12+8}px`},children:J(p,{className:"h-4 w-4 animate-spin"})}),n.map((G)=>J(bK,{teamId:B,projectId:Z,folder:G,level:P+1,dragState:M,onSelect:A,selectedFolderId:m,canEdit:C,onRenameTrigger:D,onDeleteTrigger:q,onDownloadTrigger:Q,ancestorFolders:V},G.id)),g&&J("div",{ref:o,className:"flex items-center justify-center p-2",style:{paddingLeft:`${(P+1)*12+8}px`},children:R&&J(p,{className:"h-4 w-4 animate-spin"})})]})]})}
|
|
2
|
-
export{cK as ga};
|
package/bin/chunk-3m39v371.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as V}from"./chunk-vgvmt2m1.js";import"./chunk-49ej1y67.js";import"./chunk-2s5a64nr.js";import"./chunk-ps4h3387.js";import"./chunk-dgx2zxze.js";import"./chunk-axx5bh38.js";import"./chunk-e5833tbd.js";import"./chunk-q4f5vvtx.js";import"./chunk-33ee1cvv.js";import"./chunk-kpy0kpna.js";import"./chunk-ajqsprm0.js";import"./chunk-xpqcvxej.js";import"./chunk-4hnrd4qh.js";import{Ee as U}from"./chunk-m7jfszqt.js";import"./chunk-fwf8yne2.js";import"./chunk-cp18trqb.js";import"./chunk-8wv3kdz9.js";import"./chunk-j8q688sx.js";import"./chunk-6r9w7z15.js";import"./chunk-pf8edn5x.js";import"./chunk-5a2maxwp.js";import"./chunk-4kk5g619.js";import{Uf as N}from"./chunk-5tmf3c0g.js";import"./chunk-mnv6pj0k.js";import{$f as Z,Eg as J,bg as q,fg as B,gg as G,ij as K,sg as H}from"./chunk-nwtb6dt1.js";import{Zj as Y}from"./chunk-kbzm1pwx.js";var W=Y(Z(),1);function _(){let{projectId:h}=$.useParams(),{teamId:v,ensureTeamIdForProject:w}=K();W.useEffect(()=>{w(h)},[h,w]);let{data:A}=G(U(h)),b=A?.rootFolder,{data:X}=B({queryKey:["folders",b],queryFn:()=>(async()=>{return await(await J.api.folders[":folderId"].$get({param:{folderId:b}})).json()})(),enabled:!!b});if(!v||!b||!X)return q(N,{});return q(V,{teamId:v,projectId:h,projectName:A.name??"",assetId:"recently-deleted",rootFolderId:b})}var $=H("/projects/$projectId/recently-deleted")({component:_});export{$ as Route};
|
package/bin/chunk-4hnrd4qh.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Ci as o,Pi as l,Ri as n,bg as e,cg as d}from"./chunk-nwtb6dt1.js";function u({...t}){return e(o.Root,{"data-slot":"alert-dialog",...t})}function s({...t}){return e(o.Portal,{"data-slot":"alert-dialog-portal",...t})}function g({className:t,...a}){return e(o.Overlay,{"data-slot":"alert-dialog-overlay",className:l("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",t),...a})}function f({className:t,size:a="default",...i}){return d(s,{children:[e(g,{}),e(o.Content,{"data-slot":"alert-dialog-content","data-size":a,className:l("group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[size=default]:sm:max-w-lg",t),...i})]})}function P({className:t,...a}){return e("div",{"data-slot":"alert-dialog-header",className:l("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),...a})}function A({className:t,...a}){return e("div",{"data-slot":"alert-dialog-footer",className:l("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),...a})}function D({className:t,...a}){return e(o.Title,{"data-slot":"alert-dialog-title",className:l("text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),...a})}function v({className:t,...a}){return e(o.Description,{"data-slot":"alert-dialog-description",className:l("text-sm text-muted-foreground",t),...a})}function z({className:t,variant:a="default",size:i="default",...r}){return e(n,{variant:a,size:i,asChild:!0,children:e(o.Action,{"data-slot":"alert-dialog-action",className:l(t),...r})})}function C({className:t,variant:a="outline",size:i="default",...r}){return e(n,{variant:a,size:i,asChild:!0,children:e(o.Cancel,{"data-slot":"alert-dialog-cancel",className:l(t),...r})})}
|
|
2
|
-
export{u as _a,f as $a,P as ab,A as bb,D as cb,v as db,z as eb,C as fb};
|
package/bin/chunk-6c4c7t0n.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as q}from"./chunk-gk7158n4.js";import"./chunk-hb5v9ees.js";import"./chunk-ps4h3387.js";import"./chunk-dgx2zxze.js";import"./chunk-axx5bh38.js";import"./chunk-e5833tbd.js";import"./chunk-q4f5vvtx.js";import"./chunk-33ee1cvv.js";import"./chunk-kpy0kpna.js";import"./chunk-ajqsprm0.js";import"./chunk-xpqcvxej.js";import"./chunk-4hnrd4qh.js";import"./chunk-twzgpwst.js";import"./chunk-6mn3jqm9.js";import"./chunk-fwf8yne2.js";import"./chunk-cp18trqb.js";import"./chunk-8wv3kdz9.js";import"./chunk-j8q688sx.js";import"./chunk-pf8edn5x.js";import"./chunk-5a2maxwp.js";import"./chunk-4kk5g619.js";import"./chunk-mnv6pj0k.js";import{bg as f,sg as k}from"./chunk-nwtb6dt1.js";import"./chunk-kbzm1pwx.js";function w(){let{shareId:v}=A.useParams();return f(q,{shareId:v})}var A=k("/share/$shareId/")({component:w});export{A as Route};
|
package/bin/chunk-6frqqxkv.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as V}from"./chunk-vgvmt2m1.js";import"./chunk-49ej1y67.js";import"./chunk-2s5a64nr.js";import"./chunk-ps4h3387.js";import"./chunk-dgx2zxze.js";import"./chunk-axx5bh38.js";import"./chunk-e5833tbd.js";import"./chunk-q4f5vvtx.js";import"./chunk-33ee1cvv.js";import"./chunk-kpy0kpna.js";import"./chunk-ajqsprm0.js";import"./chunk-xpqcvxej.js";import"./chunk-4hnrd4qh.js";import{we as U}from"./chunk-yk3k5g5w.js";import"./chunk-fwf8yne2.js";import"./chunk-cp18trqb.js";import"./chunk-8wv3kdz9.js";import"./chunk-j8q688sx.js";import"./chunk-6r9w7z15.js";import"./chunk-pf8edn5x.js";import"./chunk-5a2maxwp.js";import"./chunk-4kk5g619.js";import{Uf as N}from"./chunk-5tmf3c0g.js";import"./chunk-mnv6pj0k.js";import{$f as Z,Eg as J,bg as q,fg as D,gg as G,ij as K,sg as H}from"./chunk-nwtb6dt1.js";import{Zj as Y}from"./chunk-kbzm1pwx.js";var W=Y(Z(),1);function _(){let{projectId:h}=$.useParams(),{teamId:v,ensureTeamIdForProject:w}=K();W.useEffect(()=>{w(h)},[h,w]);let{data:A}=G(U(h)),b=A?.rootFolder,{data:X}=D({queryKey:["folders",b],queryFn:async()=>{let B=await J.api.folders[":folderId"].$get({param:{folderId:b}});if(!B.ok)throw Error("failed to fetch folder");return await B.json()},enabled:!!b});if(!v||!b||!X)return q(N,{});return q(V,{teamId:v,projectId:h,projectName:A.name??"",assetId:b,rootFolderId:b})}var $=H("/projects/$projectId/")({component:_});export{$ as Route};
|