@agentrix/shared 2.0.9 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +383 -18
- package/dist/index.d.cts +1063 -82
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -195,6 +195,7 @@ const ShareAuthResponseSchema = zod.z.object({
|
|
|
195
195
|
|
|
196
196
|
const StartTaskRequestSchema = zod.z.object({
|
|
197
197
|
chatId: zod.z.string(),
|
|
198
|
+
customTitle: zod.z.string().min(1).max(200).optional(),
|
|
198
199
|
message: zod.z.custom(
|
|
199
200
|
(data) => {
|
|
200
201
|
return typeof data === "object" && data !== null && "type" in data;
|
|
@@ -221,12 +222,17 @@ const StartTaskRequestSchema = zod.z.object({
|
|
|
221
222
|
dataEncryptionKey: zod.z.string().optional(),
|
|
222
223
|
// base64 sealed-box: app public key encrypted by machine public key
|
|
223
224
|
// Multi-agent collaboration fields
|
|
225
|
+
agentId: zod.z.string().optional(),
|
|
226
|
+
// Agent ID to execute the task (overrides chat's first agent)
|
|
224
227
|
parentTaskId: zod.z.string().optional()
|
|
225
|
-
// Parent task ID (for creating child tasks)
|
|
226
|
-
}).refine((data) => data.machineId || data.cloudId, {
|
|
227
|
-
message: "Must provide either machineId or
|
|
228
|
+
// Parent task ID (for creating child tasks, machineId/cloudId inherited from parent)
|
|
229
|
+
}).refine((data) => data.machineId || data.cloudId || data.parentTaskId, {
|
|
230
|
+
message: "Must provide either machineId, cloudId, or parentTaskId (for sub-tasks)"
|
|
228
231
|
}).refine(
|
|
229
232
|
(data) => {
|
|
233
|
+
if (data.parentTaskId) {
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
230
236
|
if (data.machineId) {
|
|
231
237
|
return !!data.encryptedMessage && !!data.dataEncryptionKey && !data.message;
|
|
232
238
|
}
|
|
@@ -251,6 +257,7 @@ const StartTaskResponseSchema = zod.z.object({
|
|
|
251
257
|
repositoryId: zod.z.string().nullable(),
|
|
252
258
|
baseBranch: zod.z.string().nullable(),
|
|
253
259
|
title: zod.z.string().nullable(),
|
|
260
|
+
customTitle: zod.z.string().nullable(),
|
|
254
261
|
userCwd: zod.z.string().nullable(),
|
|
255
262
|
forceUserCwd: zod.z.boolean().nullable(),
|
|
256
263
|
createdAt: DateSchema,
|
|
@@ -258,6 +265,8 @@ const StartTaskResponseSchema = zod.z.object({
|
|
|
258
265
|
});
|
|
259
266
|
const TaskItemSchema = zod.z.object({
|
|
260
267
|
id: IdSchema,
|
|
268
|
+
type: zod.z.enum(["chat", "work"]).default("work"),
|
|
269
|
+
// Task type: "chat" (virtual task for chat events) | "work" (real work task)
|
|
261
270
|
chatId: IdSchema,
|
|
262
271
|
userId: zod.z.string(),
|
|
263
272
|
state: zod.z.string(),
|
|
@@ -524,8 +533,13 @@ const ChatSchema = zod.z.object({
|
|
|
524
533
|
title: zod.z.string().nullable().optional(),
|
|
525
534
|
createdAt: zod.z.string(),
|
|
526
535
|
// ISO 8601 string
|
|
527
|
-
updatedAt: zod.z.string()
|
|
536
|
+
updatedAt: zod.z.string(),
|
|
528
537
|
// ISO 8601 string
|
|
538
|
+
// Default context for creating sub-tasks
|
|
539
|
+
defaultMachineId: zod.z.string().nullable().optional(),
|
|
540
|
+
defaultCloudId: zod.z.string().nullable().optional(),
|
|
541
|
+
defaultRepositoryId: zod.z.string().nullable().optional(),
|
|
542
|
+
defaultBaseBranch: zod.z.string().nullable().optional()
|
|
529
543
|
});
|
|
530
544
|
const ChatWithMembersSchema = ChatSchema.extend({
|
|
531
545
|
members: zod.z.array(ChatMemberSchema)
|
|
@@ -567,6 +581,13 @@ const RemoveChatMemberRequestSchema = zod.z.object({
|
|
|
567
581
|
const ListChatTasksResponseSchema = zod.z.object({
|
|
568
582
|
tasks: zod.z.array(TaskItemSchema)
|
|
569
583
|
});
|
|
584
|
+
const UpdateChatContextRequestSchema = zod.z.object({
|
|
585
|
+
defaultMachineId: zod.z.string().nullable().optional(),
|
|
586
|
+
defaultCloudId: zod.z.string().nullable().optional(),
|
|
587
|
+
defaultRepositoryId: zod.z.string().nullable().optional(),
|
|
588
|
+
defaultBaseBranch: zod.z.string().nullable().optional()
|
|
589
|
+
});
|
|
590
|
+
const UpdateChatContextResponseSchema = ChatSchema;
|
|
570
591
|
|
|
571
592
|
const AgentTypeSchema = zod.z.enum(["claude", "codex"]);
|
|
572
593
|
const DisplayConfigKeysSchema = zod.z.object({
|
|
@@ -1248,6 +1269,19 @@ const WorkerStatusRequestSchema = EventBaseSchema.extend({
|
|
|
1248
1269
|
taskId: zod.z.string(),
|
|
1249
1270
|
timestamp: zod.z.string()
|
|
1250
1271
|
});
|
|
1272
|
+
const WorkerStatusValueSchema = zod.z.enum([
|
|
1273
|
+
"worker-initializing",
|
|
1274
|
+
"worker-ready",
|
|
1275
|
+
"worker-running"
|
|
1276
|
+
]);
|
|
1277
|
+
const ChatWorkersStatusRequestSchema = EventBaseSchema.extend({
|
|
1278
|
+
chatId: zod.z.string()
|
|
1279
|
+
});
|
|
1280
|
+
const ChatWorkersStatusResponseSchema = EventBaseSchema.extend({
|
|
1281
|
+
chatId: zod.z.string(),
|
|
1282
|
+
workers: zod.z.record(zod.z.string(), WorkerStatusValueSchema)
|
|
1283
|
+
// { taskId: status }
|
|
1284
|
+
});
|
|
1251
1285
|
const baseTaskSchema = EventBaseSchema.extend({
|
|
1252
1286
|
taskId: zod.z.string(),
|
|
1253
1287
|
userId: zod.z.string(),
|
|
@@ -1287,8 +1321,12 @@ const baseTaskSchema = EventBaseSchema.extend({
|
|
|
1287
1321
|
// Root task ID of the task tree
|
|
1288
1322
|
parentTaskId: zod.z.string().optional(),
|
|
1289
1323
|
// Parent task ID (for sub tasks)
|
|
1290
|
-
chatAgents: zod.z.record(zod.z.string(), zod.z.string()).optional()
|
|
1324
|
+
chatAgents: zod.z.record(zod.z.string(), zod.z.string()).optional(),
|
|
1291
1325
|
// All agents in chat: { displayName: agentId }
|
|
1326
|
+
taskType: zod.z.enum(["chat", "work"]).optional().default("work"),
|
|
1327
|
+
// Task type: 'chat' for main chat, 'work' for task execution
|
|
1328
|
+
customTitle: zod.z.string().min(1).max(200).optional()
|
|
1329
|
+
// Custom task title (set by user/tool)
|
|
1292
1330
|
});
|
|
1293
1331
|
const createTaskSchema = baseTaskSchema.extend({
|
|
1294
1332
|
message: zod.z.custom(
|
|
@@ -1335,6 +1373,41 @@ const StopTaskSchema = EventBaseSchema.extend({
|
|
|
1335
1373
|
taskId: zod.z.string(),
|
|
1336
1374
|
reason: zod.z.string().optional()
|
|
1337
1375
|
});
|
|
1376
|
+
const SubTaskGitStatsSchema = zod.z.object({
|
|
1377
|
+
additions: zod.z.number(),
|
|
1378
|
+
deletions: zod.z.number(),
|
|
1379
|
+
fileCount: zod.z.number()
|
|
1380
|
+
});
|
|
1381
|
+
const PreviewProjectTypeSchema = zod.z.enum([
|
|
1382
|
+
"html",
|
|
1383
|
+
"react",
|
|
1384
|
+
"vue",
|
|
1385
|
+
"vite",
|
|
1386
|
+
"nextjs",
|
|
1387
|
+
"unknown"
|
|
1388
|
+
]);
|
|
1389
|
+
const PreviewMethodSchema = zod.z.enum([
|
|
1390
|
+
"simple",
|
|
1391
|
+
"bundled",
|
|
1392
|
+
"gallery",
|
|
1393
|
+
"none"
|
|
1394
|
+
]);
|
|
1395
|
+
const PreviewMetadataSchema = zod.z.object({
|
|
1396
|
+
projectType: PreviewProjectTypeSchema,
|
|
1397
|
+
previewMethod: PreviewMethodSchema,
|
|
1398
|
+
entryFile: zod.z.string().nullable(),
|
|
1399
|
+
projectPath: zod.z.string(),
|
|
1400
|
+
// "" for single project, "apps/web" for monorepo
|
|
1401
|
+
dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional(),
|
|
1402
|
+
tailwindVersion: zod.z.union([zod.z.literal(3), zod.z.literal(4), zod.z.null()]).optional(),
|
|
1403
|
+
isStaticFileCollection: zod.z.boolean().optional()
|
|
1404
|
+
});
|
|
1405
|
+
const SubTaskArtifactsSummarySchema = zod.z.object({
|
|
1406
|
+
commitHash: zod.z.string(),
|
|
1407
|
+
gitStats: SubTaskGitStatsSchema,
|
|
1408
|
+
preview: PreviewMetadataSchema.nullable()
|
|
1409
|
+
// Preview metadata computed by CLI
|
|
1410
|
+
});
|
|
1338
1411
|
const TaskMessageSchema = EventBaseSchema.extend({
|
|
1339
1412
|
taskId: zod.z.string(),
|
|
1340
1413
|
chatId: zod.z.string().optional(),
|
|
@@ -1355,8 +1428,10 @@ const TaskMessageSchema = EventBaseSchema.extend({
|
|
|
1355
1428
|
// Multi-agent collaboration fields
|
|
1356
1429
|
agentId: zod.z.string().optional(),
|
|
1357
1430
|
// Agent ID for message attribution
|
|
1358
|
-
rootTaskId: zod.z.string().optional()
|
|
1431
|
+
rootTaskId: zod.z.string().optional(),
|
|
1359
1432
|
// Root task ID for event routing
|
|
1433
|
+
// Artifacts summary - attached to result messages for sub-task completion
|
|
1434
|
+
artifacts: SubTaskArtifactsSummarySchema.optional()
|
|
1360
1435
|
}).refine(
|
|
1361
1436
|
(data) => {
|
|
1362
1437
|
return !!data.message !== !!data.encryptedMessage;
|
|
@@ -1500,21 +1575,27 @@ const MergeRequestEventSchema = EventBaseSchema.extend({
|
|
|
1500
1575
|
const TaskStoppedEventSchema = EventBaseSchema.extend({
|
|
1501
1576
|
taskId: zod.z.string()
|
|
1502
1577
|
});
|
|
1503
|
-
const
|
|
1578
|
+
const SubTaskResultUpdatedEventSchema = EventBaseSchema.extend({
|
|
1504
1579
|
taskId: zod.z.string(),
|
|
1505
|
-
//
|
|
1580
|
+
// Sub task ID
|
|
1506
1581
|
parentTaskId: zod.z.string(),
|
|
1507
1582
|
// Parent task ID
|
|
1508
1583
|
rootTaskId: zod.z.string(),
|
|
1509
1584
|
// Root task ID
|
|
1585
|
+
agentId: zod.z.string(),
|
|
1586
|
+
// Agent ID that executed the task
|
|
1510
1587
|
agentName: zod.z.string(),
|
|
1511
|
-
// Agent display name
|
|
1588
|
+
// Agent display name
|
|
1512
1589
|
taskName: zod.z.string().optional(),
|
|
1513
|
-
// Task title
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1590
|
+
// Task title
|
|
1591
|
+
// Complete result message from SDK
|
|
1592
|
+
resultMessage: zod.z.object({
|
|
1593
|
+
type: zod.z.literal("result"),
|
|
1594
|
+
result: zod.z.string(),
|
|
1595
|
+
is_error: zod.z.boolean().optional()
|
|
1596
|
+
}),
|
|
1597
|
+
// Optional artifacts summary (for displaying in parent task chat)
|
|
1598
|
+
artifacts: SubTaskArtifactsSummarySchema.optional()
|
|
1518
1599
|
});
|
|
1519
1600
|
const MergePullRequestEventSchema = EventBaseSchema.extend({
|
|
1520
1601
|
taskId: zod.z.string(),
|
|
@@ -1594,7 +1675,8 @@ const SystemMessageSchema = EventBaseSchema.extend({
|
|
|
1594
1675
|
"repo-added",
|
|
1595
1676
|
"repo-removed",
|
|
1596
1677
|
"pr-state-changed",
|
|
1597
|
-
"draft-agent-added"
|
|
1678
|
+
"draft-agent-added",
|
|
1679
|
+
"task-added"
|
|
1598
1680
|
]),
|
|
1599
1681
|
data: zod.z.union([
|
|
1600
1682
|
IdOnlySchema,
|
|
@@ -1609,8 +1691,10 @@ const SystemMessageSchema = EventBaseSchema.extend({
|
|
|
1609
1691
|
// repo-added
|
|
1610
1692
|
PrStateChangedSchema,
|
|
1611
1693
|
// pr-state-changed
|
|
1612
|
-
DraftAgentSchema
|
|
1694
|
+
DraftAgentSchema,
|
|
1613
1695
|
// draft-agent-added
|
|
1696
|
+
TaskItemSchema
|
|
1697
|
+
// task-added
|
|
1614
1698
|
]),
|
|
1615
1699
|
timestamp: zod.z.string()
|
|
1616
1700
|
});
|
|
@@ -1628,6 +1712,9 @@ const EventSchemaMap = {
|
|
|
1628
1712
|
"worker-exit": WorkerExitSchema,
|
|
1629
1713
|
"worker-running": WorkerRunningSchema,
|
|
1630
1714
|
"worker-status-request": WorkerStatusRequestSchema,
|
|
1715
|
+
// Chat workers status events
|
|
1716
|
+
"chat-workers-status-request": ChatWorkersStatusRequestSchema,
|
|
1717
|
+
"chat-workers-status-response": ChatWorkersStatusResponseSchema,
|
|
1631
1718
|
// Task events
|
|
1632
1719
|
"create-task": createTaskSchema,
|
|
1633
1720
|
"resume-task": resumeTaskSchema,
|
|
@@ -1650,7 +1737,7 @@ const EventSchemaMap = {
|
|
|
1650
1737
|
"deploy-agent-complete": DeployAgentCompleteEventSchema,
|
|
1651
1738
|
// Multi-agent collaboration events
|
|
1652
1739
|
"task-stopped": TaskStoppedEventSchema,
|
|
1653
|
-
"sub-task-
|
|
1740
|
+
"sub-task-result-updated": SubTaskResultUpdatedEventSchema,
|
|
1654
1741
|
// Repository association events
|
|
1655
1742
|
"associate-repo": AssociateRepoEventDataSchema,
|
|
1656
1743
|
// System message events
|
|
@@ -2257,6 +2344,268 @@ function splitRtcChunkFrame(data) {
|
|
|
2257
2344
|
return { header, payload };
|
|
2258
2345
|
}
|
|
2259
2346
|
|
|
2347
|
+
const STATIC_FILE_EXTENSIONS = {
|
|
2348
|
+
images: [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".svg", ".ico"],
|
|
2349
|
+
videos: [".mp4", ".mov", ".avi", ".webm", ".mkv", ".m4v", ".flv", ".wmv"],
|
|
2350
|
+
documents: [".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx"],
|
|
2351
|
+
text: [".txt", ".md", ".markdown", ".json", ".yaml", ".yml", ".csv", ".xml"],
|
|
2352
|
+
html: [".html", ".htm"]
|
|
2353
|
+
};
|
|
2354
|
+
const IGNORED_DIRECTORIES = [
|
|
2355
|
+
"node_modules",
|
|
2356
|
+
".git",
|
|
2357
|
+
"dist",
|
|
2358
|
+
"build",
|
|
2359
|
+
".next",
|
|
2360
|
+
"out",
|
|
2361
|
+
"coverage",
|
|
2362
|
+
"__pycache__",
|
|
2363
|
+
".cache",
|
|
2364
|
+
".parcel-cache",
|
|
2365
|
+
".turbo"
|
|
2366
|
+
];
|
|
2367
|
+
const ENTRY_FILE_PATTERNS = {
|
|
2368
|
+
html: ["index.html", "src/index.html"],
|
|
2369
|
+
react: [
|
|
2370
|
+
"index.html",
|
|
2371
|
+
// Vite/CRA
|
|
2372
|
+
"public/index.html",
|
|
2373
|
+
// Create React App
|
|
2374
|
+
"src/index.tsx",
|
|
2375
|
+
"src/index.jsx",
|
|
2376
|
+
"src/index.ts",
|
|
2377
|
+
"src/index.js",
|
|
2378
|
+
"src/main.tsx",
|
|
2379
|
+
// Vite-specific
|
|
2380
|
+
"src/main.ts",
|
|
2381
|
+
"src/main.jsx",
|
|
2382
|
+
"src/main.js",
|
|
2383
|
+
"src/App.tsx",
|
|
2384
|
+
"src/App.jsx",
|
|
2385
|
+
"index.tsx",
|
|
2386
|
+
// Root-level
|
|
2387
|
+
"index.jsx",
|
|
2388
|
+
"index.js",
|
|
2389
|
+
"App.tsx",
|
|
2390
|
+
"App.jsx"
|
|
2391
|
+
],
|
|
2392
|
+
vue: [
|
|
2393
|
+
"index.html",
|
|
2394
|
+
// Vite
|
|
2395
|
+
"src/main.ts",
|
|
2396
|
+
"src/main.js",
|
|
2397
|
+
"src/index.ts",
|
|
2398
|
+
"src/index.js",
|
|
2399
|
+
"src/App.vue",
|
|
2400
|
+
"App.vue"
|
|
2401
|
+
],
|
|
2402
|
+
vite: [
|
|
2403
|
+
"index.html",
|
|
2404
|
+
"src/main.tsx",
|
|
2405
|
+
"src/main.ts",
|
|
2406
|
+
"src/main.jsx",
|
|
2407
|
+
"src/main.js",
|
|
2408
|
+
"src/index.tsx",
|
|
2409
|
+
"src/index.ts",
|
|
2410
|
+
"src/App.tsx",
|
|
2411
|
+
"src/App.jsx"
|
|
2412
|
+
],
|
|
2413
|
+
nextjs: [
|
|
2414
|
+
"pages/index.tsx",
|
|
2415
|
+
"pages/index.jsx",
|
|
2416
|
+
"app/page.tsx",
|
|
2417
|
+
"src/pages/index.tsx",
|
|
2418
|
+
"src/app/page.tsx"
|
|
2419
|
+
]
|
|
2420
|
+
};
|
|
2421
|
+
const CONFIG_FILES = {
|
|
2422
|
+
vite: ["vite.config.js", "vite.config.ts", "vite.config.mjs"],
|
|
2423
|
+
nextjs: ["next.config.js", "next.config.mjs", "next.config.ts"]
|
|
2424
|
+
};
|
|
2425
|
+
const RELEVANT_DEPENDENCIES = [
|
|
2426
|
+
"react",
|
|
2427
|
+
"react-dom",
|
|
2428
|
+
"vue",
|
|
2429
|
+
"vite",
|
|
2430
|
+
"next",
|
|
2431
|
+
"tailwindcss",
|
|
2432
|
+
"@vitejs/plugin-react",
|
|
2433
|
+
"@vitejs/plugin-vue"
|
|
2434
|
+
];
|
|
2435
|
+
|
|
2436
|
+
async function detectPreview(fs) {
|
|
2437
|
+
try {
|
|
2438
|
+
const files = await fs.listFiles(3);
|
|
2439
|
+
if (files.length === 0) {
|
|
2440
|
+
return null;
|
|
2441
|
+
}
|
|
2442
|
+
const dependencies = await parsePackageJson(fs);
|
|
2443
|
+
const projectType = await detectProjectType(files, dependencies, fs);
|
|
2444
|
+
const isStaticFileCollection = detectStaticFileCollection(files, projectType);
|
|
2445
|
+
const previewMethod = getPreviewMethod(projectType, isStaticFileCollection);
|
|
2446
|
+
if (previewMethod === "none" && !isStaticFileCollection) {
|
|
2447
|
+
return null;
|
|
2448
|
+
}
|
|
2449
|
+
const entryFile = await findEntryFile(files, projectType, fs);
|
|
2450
|
+
const tailwindVersion = detectTailwindVersion(dependencies);
|
|
2451
|
+
return {
|
|
2452
|
+
projectType,
|
|
2453
|
+
previewMethod,
|
|
2454
|
+
entryFile,
|
|
2455
|
+
projectPath: "",
|
|
2456
|
+
dependencies: filterRelevantDependencies(dependencies),
|
|
2457
|
+
tailwindVersion,
|
|
2458
|
+
isStaticFileCollection
|
|
2459
|
+
};
|
|
2460
|
+
} catch (error) {
|
|
2461
|
+
console.warn("[preview/detector] Failed to detect preview:", error);
|
|
2462
|
+
return null;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
async function parsePackageJson(fs) {
|
|
2466
|
+
try {
|
|
2467
|
+
const content = await fs.readFile("package.json");
|
|
2468
|
+
if (!content) {
|
|
2469
|
+
return {};
|
|
2470
|
+
}
|
|
2471
|
+
const pkg = JSON.parse(content);
|
|
2472
|
+
return {
|
|
2473
|
+
...pkg.dependencies || {},
|
|
2474
|
+
...pkg.devDependencies || {}
|
|
2475
|
+
};
|
|
2476
|
+
} catch {
|
|
2477
|
+
return {};
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
async function detectProjectType(files, dependencies, fs) {
|
|
2481
|
+
const rootFiles = files.filter((f) => !f.includes("/"));
|
|
2482
|
+
const hasNextConfig = CONFIG_FILES.nextjs.some((config) => rootFiles.includes(config));
|
|
2483
|
+
if (dependencies.next || hasNextConfig) {
|
|
2484
|
+
return "nextjs";
|
|
2485
|
+
}
|
|
2486
|
+
const hasViteConfig = CONFIG_FILES.vite.some((config) => rootFiles.includes(config));
|
|
2487
|
+
if (dependencies.vite || hasViteConfig) {
|
|
2488
|
+
const isVue = dependencies.vue || files.some((f) => f.endsWith(".vue"));
|
|
2489
|
+
const isReact = dependencies.react || files.some((f) => f.endsWith(".jsx") || f.endsWith(".tsx"));
|
|
2490
|
+
if (isVue) return "vue";
|
|
2491
|
+
if (isReact) return "react";
|
|
2492
|
+
return "vite";
|
|
2493
|
+
}
|
|
2494
|
+
if (dependencies.react || files.some((f) => f.endsWith(".jsx") || f.endsWith(".tsx"))) {
|
|
2495
|
+
return "react";
|
|
2496
|
+
}
|
|
2497
|
+
if (dependencies.vue || files.some((f) => f.endsWith(".vue"))) {
|
|
2498
|
+
return "vue";
|
|
2499
|
+
}
|
|
2500
|
+
if (files.some((f) => f === "index.html" || f === "src/index.html")) {
|
|
2501
|
+
return "html";
|
|
2502
|
+
}
|
|
2503
|
+
return "unknown";
|
|
2504
|
+
}
|
|
2505
|
+
function detectStaticFileCollection(files, projectType) {
|
|
2506
|
+
if (projectType !== "unknown") {
|
|
2507
|
+
return false;
|
|
2508
|
+
}
|
|
2509
|
+
const allExtensions = [
|
|
2510
|
+
...STATIC_FILE_EXTENSIONS.images,
|
|
2511
|
+
...STATIC_FILE_EXTENSIONS.videos,
|
|
2512
|
+
...STATIC_FILE_EXTENSIONS.documents,
|
|
2513
|
+
...STATIC_FILE_EXTENSIONS.text,
|
|
2514
|
+
...STATIC_FILE_EXTENSIONS.html
|
|
2515
|
+
];
|
|
2516
|
+
return files.some((file) => {
|
|
2517
|
+
const ext = getFileExtension(file);
|
|
2518
|
+
return allExtensions.includes(ext);
|
|
2519
|
+
});
|
|
2520
|
+
}
|
|
2521
|
+
function getPreviewMethod(projectType, isStaticFileCollection) {
|
|
2522
|
+
if (isStaticFileCollection) {
|
|
2523
|
+
return "gallery";
|
|
2524
|
+
}
|
|
2525
|
+
switch (projectType) {
|
|
2526
|
+
case "html":
|
|
2527
|
+
return "simple";
|
|
2528
|
+
case "react":
|
|
2529
|
+
case "vue":
|
|
2530
|
+
case "vite":
|
|
2531
|
+
return "bundled";
|
|
2532
|
+
case "nextjs":
|
|
2533
|
+
return "none";
|
|
2534
|
+
case "unknown":
|
|
2535
|
+
return "none";
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
async function findEntryFile(files, projectType, fs) {
|
|
2539
|
+
if ((projectType === "react" || projectType === "vite") && files.includes("index.html")) {
|
|
2540
|
+
try {
|
|
2541
|
+
const content = await fs.readFile("index.html");
|
|
2542
|
+
if (content) {
|
|
2543
|
+
const scriptMatch = content.match(
|
|
2544
|
+
/<script[^>]*type=["']module["'][^>]*src=["']([^"']+)["']/
|
|
2545
|
+
);
|
|
2546
|
+
if (scriptMatch) {
|
|
2547
|
+
const jsxPath = scriptMatch[1];
|
|
2548
|
+
const normalizedPath = jsxPath.startsWith("/") ? jsxPath.substring(1) : jsxPath;
|
|
2549
|
+
if (files.includes(normalizedPath)) {
|
|
2550
|
+
return normalizedPath;
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
} catch {
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
const possiblePaths = getPossibleEntryPaths(projectType);
|
|
2558
|
+
for (const path of possiblePaths) {
|
|
2559
|
+
if (files.includes(path)) {
|
|
2560
|
+
return path;
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
return null;
|
|
2564
|
+
}
|
|
2565
|
+
function getPossibleEntryPaths(projectType) {
|
|
2566
|
+
switch (projectType) {
|
|
2567
|
+
case "html":
|
|
2568
|
+
return ENTRY_FILE_PATTERNS.html;
|
|
2569
|
+
case "react":
|
|
2570
|
+
return ENTRY_FILE_PATTERNS.react;
|
|
2571
|
+
case "vue":
|
|
2572
|
+
return ENTRY_FILE_PATTERNS.vue;
|
|
2573
|
+
case "vite":
|
|
2574
|
+
return ENTRY_FILE_PATTERNS.vite;
|
|
2575
|
+
case "nextjs":
|
|
2576
|
+
return ENTRY_FILE_PATTERNS.nextjs;
|
|
2577
|
+
case "unknown":
|
|
2578
|
+
return [];
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
function detectTailwindVersion(dependencies) {
|
|
2582
|
+
const tailwindVersion = dependencies.tailwindcss;
|
|
2583
|
+
if (!tailwindVersion) {
|
|
2584
|
+
return null;
|
|
2585
|
+
}
|
|
2586
|
+
const versionMatch = tailwindVersion.match(/^[\^~]?(\d+)/);
|
|
2587
|
+
const majorVersion = versionMatch ? parseInt(versionMatch[1]) : null;
|
|
2588
|
+
if (majorVersion === 4) return 4;
|
|
2589
|
+
if (majorVersion === 3) return 3;
|
|
2590
|
+
return null;
|
|
2591
|
+
}
|
|
2592
|
+
function filterRelevantDependencies(dependencies) {
|
|
2593
|
+
const filtered = {};
|
|
2594
|
+
for (const [name, version] of Object.entries(dependencies)) {
|
|
2595
|
+
if (RELEVANT_DEPENDENCIES.includes(name)) {
|
|
2596
|
+
filtered[name] = version;
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
return filtered;
|
|
2600
|
+
}
|
|
2601
|
+
function getFileExtension(filePath) {
|
|
2602
|
+
const lastDot = filePath.lastIndexOf(".");
|
|
2603
|
+
if (lastDot === -1 || lastDot === filePath.length - 1) {
|
|
2604
|
+
return "";
|
|
2605
|
+
}
|
|
2606
|
+
return filePath.substring(lastDot).toLowerCase();
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2260
2609
|
exports.AddChatMemberRequestSchema = AddChatMemberRequestSchema;
|
|
2261
2610
|
exports.AddChatMemberResponseSchema = AddChatMemberResponseSchema;
|
|
2262
2611
|
exports.AgentConfigValidationError = AgentConfigValidationError;
|
|
@@ -2285,6 +2634,7 @@ exports.AskUserResponseStatusSchema = AskUserResponseStatusSchema;
|
|
|
2285
2634
|
exports.AssociateRepoEventDataSchema = AssociateRepoEventDataSchema;
|
|
2286
2635
|
exports.BillingStatsResponseSchema = BillingStatsResponseSchema;
|
|
2287
2636
|
exports.BranchSchema = BranchSchema;
|
|
2637
|
+
exports.CONFIG_FILES = CONFIG_FILES;
|
|
2288
2638
|
exports.CancelTaskRequestSchema = CancelTaskRequestSchema;
|
|
2289
2639
|
exports.CancelTaskResponseSchema = CancelTaskResponseSchema;
|
|
2290
2640
|
exports.ChangeTaskTitleEventSchema = ChangeTaskTitleEventSchema;
|
|
@@ -2294,6 +2644,8 @@ exports.ChatMemberSchema = ChatMemberSchema;
|
|
|
2294
2644
|
exports.ChatSchema = ChatSchema;
|
|
2295
2645
|
exports.ChatTypeSchema = ChatTypeSchema;
|
|
2296
2646
|
exports.ChatWithMembersSchema = ChatWithMembersSchema;
|
|
2647
|
+
exports.ChatWorkersStatusRequestSchema = ChatWorkersStatusRequestSchema;
|
|
2648
|
+
exports.ChatWorkersStatusResponseSchema = ChatWorkersStatusResponseSchema;
|
|
2297
2649
|
exports.ClaudeConfigSchema = ClaudeConfigSchema;
|
|
2298
2650
|
exports.CloudJoinApprovalRequestSchema = CloudJoinApprovalRequestSchema;
|
|
2299
2651
|
exports.CloudJoinRequestSchema = CloudJoinRequestSchema;
|
|
@@ -2328,6 +2680,7 @@ exports.DisplayConfigKeysSchema = DisplayConfigKeysSchema;
|
|
|
2328
2680
|
exports.DisplayConfigSchema = DisplayConfigSchema;
|
|
2329
2681
|
exports.DraftAgentConfigSchema = DraftAgentConfigSchema;
|
|
2330
2682
|
exports.DraftAgentSchema = DraftAgentSchema;
|
|
2683
|
+
exports.ENTRY_FILE_PATTERNS = ENTRY_FILE_PATTERNS;
|
|
2331
2684
|
exports.EnvironmentVariableSchema = EnvironmentVariableSchema;
|
|
2332
2685
|
exports.EventAckSchema = EventAckSchema;
|
|
2333
2686
|
exports.EventSchemaMap = EventSchemaMap;
|
|
@@ -2355,6 +2708,7 @@ exports.GetUserAgentsResponseSchema = GetUserAgentsResponseSchema;
|
|
|
2355
2708
|
exports.GitHubIssueListItemSchema = GitHubIssueListItemSchema;
|
|
2356
2709
|
exports.GitHubIssueSchema = GitHubIssueSchema;
|
|
2357
2710
|
exports.GitServerSchema = GitServerSchema;
|
|
2711
|
+
exports.IGNORED_DIRECTORIES = IGNORED_DIRECTORIES;
|
|
2358
2712
|
exports.IdSchema = IdSchema;
|
|
2359
2713
|
exports.ListAgentsResponseSchema = ListAgentsResponseSchema;
|
|
2360
2714
|
exports.ListBranchesResponseSchema = ListBranchesResponseSchema;
|
|
@@ -2404,11 +2758,15 @@ exports.OAuthUnbindResponseSchema = OAuthUnbindResponseSchema;
|
|
|
2404
2758
|
exports.PaginatedResponseSchema = PaginatedResponseSchema;
|
|
2405
2759
|
exports.PermissionResponseRequestSchema = PermissionResponseRequestSchema;
|
|
2406
2760
|
exports.PermissionResponseResponseSchema = PermissionResponseResponseSchema;
|
|
2761
|
+
exports.PreviewMetadataSchema = PreviewMetadataSchema;
|
|
2762
|
+
exports.PreviewMethodSchema = PreviewMethodSchema;
|
|
2763
|
+
exports.PreviewProjectTypeSchema = PreviewProjectTypeSchema;
|
|
2407
2764
|
exports.ProjectDirectoryResponseSchema = ProjectDirectoryResponseSchema;
|
|
2408
2765
|
exports.ProjectEntrySchema = ProjectEntrySchema;
|
|
2409
2766
|
exports.PublishDraftAgentRequestSchema = PublishDraftAgentRequestSchema;
|
|
2410
2767
|
exports.PublishDraftAgentResponseSchema = PublishDraftAgentResponseSchema;
|
|
2411
2768
|
exports.QueryEventsRequestSchema = QueryEventsRequestSchema;
|
|
2769
|
+
exports.RELEVANT_DEPENDENCIES = RELEVANT_DEPENDENCIES;
|
|
2412
2770
|
exports.RTC_CHUNK_HEADER_SIZE = RTC_CHUNK_HEADER_SIZE;
|
|
2413
2771
|
exports.RechargeResponseSchema = RechargeResponseSchema;
|
|
2414
2772
|
exports.RemoveChatMemberRequestSchema = RemoveChatMemberRequestSchema;
|
|
@@ -2424,6 +2782,7 @@ exports.RtcIceServerSchema = RtcIceServerSchema;
|
|
|
2424
2782
|
exports.RtcIceServersRequestSchema = RtcIceServersRequestSchema;
|
|
2425
2783
|
exports.RtcIceServersResponseSchema = RtcIceServersResponseSchema;
|
|
2426
2784
|
exports.RtcSignalSchema = RtcSignalSchema;
|
|
2785
|
+
exports.STATIC_FILE_EXTENSIONS = STATIC_FILE_EXTENSIONS;
|
|
2427
2786
|
exports.SendTaskMessageRequestSchema = SendTaskMessageRequestSchema;
|
|
2428
2787
|
exports.SendTaskMessageResponseSchema = SendTaskMessageResponseSchema;
|
|
2429
2788
|
exports.SetEnvironmentVariablesRequestSchema = SetEnvironmentVariablesRequestSchema;
|
|
@@ -2442,7 +2801,9 @@ exports.StatsQuerySchema = StatsQuerySchema;
|
|
|
2442
2801
|
exports.StopTaskRequestSchema = StopTaskRequestSchema;
|
|
2443
2802
|
exports.StopTaskResponseSchema = StopTaskResponseSchema;
|
|
2444
2803
|
exports.StopTaskSchema = StopTaskSchema;
|
|
2445
|
-
exports.
|
|
2804
|
+
exports.SubTaskArtifactsSummarySchema = SubTaskArtifactsSummarySchema;
|
|
2805
|
+
exports.SubTaskGitStatsSchema = SubTaskGitStatsSchema;
|
|
2806
|
+
exports.SubTaskResultUpdatedEventSchema = SubTaskResultUpdatedEventSchema;
|
|
2446
2807
|
exports.SyncCloudMachineResponseSchema = SyncCloudMachineResponseSchema;
|
|
2447
2808
|
exports.SyncLocalMachineResponseSchema = SyncLocalMachineResponseSchema;
|
|
2448
2809
|
exports.SyncMachineRequestSchema = SyncMachineRequestSchema;
|
|
@@ -2463,6 +2824,8 @@ exports.UnarchiveTaskRequestSchema = UnarchiveTaskRequestSchema;
|
|
|
2463
2824
|
exports.UnarchiveTaskResponseSchema = UnarchiveTaskResponseSchema;
|
|
2464
2825
|
exports.UpdateAgentRequestSchema = UpdateAgentRequestSchema;
|
|
2465
2826
|
exports.UpdateAgentResponseSchema = UpdateAgentResponseSchema;
|
|
2827
|
+
exports.UpdateChatContextRequestSchema = UpdateChatContextRequestSchema;
|
|
2828
|
+
exports.UpdateChatContextResponseSchema = UpdateChatContextResponseSchema;
|
|
2466
2829
|
exports.UpdateDraftAgentRequestSchema = UpdateDraftAgentRequestSchema;
|
|
2467
2830
|
exports.UpdateDraftAgentResponseSchema = UpdateDraftAgentResponseSchema;
|
|
2468
2831
|
exports.UpdateOAuthServerRequestSchema = UpdateOAuthServerRequestSchema;
|
|
@@ -2482,6 +2845,7 @@ exports.WorkerInitializingSchema = WorkerInitializingSchema;
|
|
|
2482
2845
|
exports.WorkerReadySchema = WorkerReadySchema;
|
|
2483
2846
|
exports.WorkerRunningSchema = WorkerRunningSchema;
|
|
2484
2847
|
exports.WorkerStatusRequestSchema = WorkerStatusRequestSchema;
|
|
2848
|
+
exports.WorkerStatusValueSchema = WorkerStatusValueSchema;
|
|
2485
2849
|
exports.WorkspaceFileRequestSchema = WorkspaceFileRequestSchema;
|
|
2486
2850
|
exports.WorkspaceFileResponseSchema = WorkspaceFileResponseSchema;
|
|
2487
2851
|
exports.assertAgentExists = assertAgentExists;
|
|
@@ -2502,6 +2866,7 @@ exports.decryptFileContent = decryptFileContent;
|
|
|
2502
2866
|
exports.decryptMachineEncryptionKey = decryptMachineEncryptionKey;
|
|
2503
2867
|
exports.decryptSdkMessage = decryptSdkMessage;
|
|
2504
2868
|
exports.decryptWithEphemeralKey = decryptWithEphemeralKey;
|
|
2869
|
+
exports.detectPreview = detectPreview;
|
|
2505
2870
|
exports.discoverPlugins = discoverPlugins;
|
|
2506
2871
|
exports.encodeBase64 = encodeBase64;
|
|
2507
2872
|
exports.encodeBase64Url = encodeBase64Url;
|