@codmir/contracts 0.1.0 → 0.1.1

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 CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var zod = require('zod');
4
+
3
5
  // src/schema.ts
4
6
  var DURATION_SYNC_THRESHOLDS = {
5
7
  instant: 5e3,
@@ -1443,6 +1445,153 @@ Respond in JSON format with an "issues" array containing objects with:
1443
1445
  tags: ["github", "pr-analysis", "ai-review", "automation", "webhook"],
1444
1446
  author: "codmir-team"
1445
1447
  };
1448
+ var NODE_CAPABILITIES = [
1449
+ "llm.chat",
1450
+ "llm.completion",
1451
+ "embeddings.encode",
1452
+ "repo.index",
1453
+ "tools.run",
1454
+ "build.compile",
1455
+ "build.test",
1456
+ "vision.detect",
1457
+ "audio.transcribe",
1458
+ "audio.tts"
1459
+ ];
1460
+ var JOB_TYPES = [
1461
+ "chat",
1462
+ "embed",
1463
+ "patch",
1464
+ "build",
1465
+ "test",
1466
+ "index",
1467
+ "transcribe",
1468
+ "custom"
1469
+ ];
1470
+ var NodeCapabilitySchema = zod.z.enum(NODE_CAPABILITIES);
1471
+ var NodeHardwareSchema = zod.z.object({
1472
+ arch: zod.z.enum(["arm64", "x86_64", "aarch64"]),
1473
+ gpuType: zod.z.string().optional(),
1474
+ gpuMemoryMb: zod.z.number().int().nonnegative().optional(),
1475
+ ramMb: zod.z.number().int().positive(),
1476
+ cpuCores: zod.z.number().int().positive(),
1477
+ cudaCores: zod.z.number().int().nonnegative().optional(),
1478
+ tensorCores: zod.z.number().int().nonnegative().optional()
1479
+ });
1480
+ var NodeStatusSchema = zod.z.enum([
1481
+ "online",
1482
+ "offline",
1483
+ "draining",
1484
+ "error"
1485
+ ]);
1486
+ var NodeSchema = zod.z.object({
1487
+ id: zod.z.string().min(1),
1488
+ name: zod.z.string().min(1),
1489
+ capabilities: zod.z.array(NodeCapabilitySchema).min(1),
1490
+ labels: zod.z.array(zod.z.string()).default([]),
1491
+ hardware: NodeHardwareSchema,
1492
+ modelsAvailable: zod.z.array(zod.z.string()).default([]),
1493
+ status: NodeStatusSchema.default("offline"),
1494
+ maxConcurrency: zod.z.number().int().positive().default(2),
1495
+ runningJobs: zod.z.number().int().nonnegative().default(0),
1496
+ lastHeartbeatAt: zod.z.string().datetime().optional(),
1497
+ registeredAt: zod.z.string().datetime(),
1498
+ endpoint: zod.z.string().url()
1499
+ });
1500
+ var RegisterNodeSchema = zod.z.object({
1501
+ name: zod.z.string().min(1),
1502
+ capabilities: zod.z.array(NodeCapabilitySchema).min(1),
1503
+ labels: zod.z.array(zod.z.string()).default([]),
1504
+ hardware: NodeHardwareSchema,
1505
+ modelsAvailable: zod.z.array(zod.z.string()).default([]),
1506
+ maxConcurrency: zod.z.number().int().positive().default(2),
1507
+ endpoint: zod.z.string().url()
1508
+ });
1509
+ var HeartbeatSchema = zod.z.object({
1510
+ runningJobs: zod.z.number().int().nonnegative(),
1511
+ modelsAvailable: zod.z.array(zod.z.string()).optional(),
1512
+ load: zod.z.object({
1513
+ cpuPercent: zod.z.number().min(0).max(100).optional(),
1514
+ gpuPercent: zod.z.number().min(0).max(100).optional(),
1515
+ ramUsedMb: zod.z.number().nonnegative().optional()
1516
+ }).optional()
1517
+ });
1518
+ var JobTypeSchema = zod.z.enum(JOB_TYPES);
1519
+ var JobStatusSchema = zod.z.enum([
1520
+ "queued",
1521
+ "assigned",
1522
+ "running",
1523
+ "succeeded",
1524
+ "failed",
1525
+ "canceled"
1526
+ ]);
1527
+ var JobPrioritySchema = zod.z.enum(["critical", "high", "normal", "low"]);
1528
+ var SubmitJobSchema = zod.z.object({
1529
+ workspaceId: zod.z.string().min(1),
1530
+ type: JobTypeSchema,
1531
+ priority: JobPrioritySchema.default("normal"),
1532
+ requiredCapabilities: zod.z.array(NodeCapabilitySchema).min(1),
1533
+ preferredModel: zod.z.string().optional(),
1534
+ payload: zod.z.record(zod.z.unknown()),
1535
+ timeoutMs: zod.z.number().int().positive().default(12e4),
1536
+ idempotencyKey: zod.z.string().optional()
1537
+ });
1538
+ var JobResultSchema = zod.z.object({
1539
+ success: zod.z.boolean(),
1540
+ output: zod.z.record(zod.z.unknown()).optional(),
1541
+ error: zod.z.string().optional(),
1542
+ artifactRefs: zod.z.array(zod.z.string()).default([]),
1543
+ durationMs: zod.z.number().int().nonnegative().optional()
1544
+ });
1545
+ var JobSchema = zod.z.object({
1546
+ id: zod.z.string().min(1),
1547
+ workspaceId: zod.z.string().min(1),
1548
+ type: JobTypeSchema,
1549
+ priority: JobPrioritySchema,
1550
+ status: JobStatusSchema,
1551
+ requiredCapabilities: zod.z.array(NodeCapabilitySchema),
1552
+ preferredModel: zod.z.string().optional(),
1553
+ payload: zod.z.record(zod.z.unknown()),
1554
+ timeoutMs: zod.z.number().int().positive(),
1555
+ assignedNodeId: zod.z.string().optional(),
1556
+ result: JobResultSchema.optional(),
1557
+ createdAt: zod.z.string().datetime(),
1558
+ startedAt: zod.z.string().datetime().optional(),
1559
+ completedAt: zod.z.string().datetime().optional()
1560
+ });
1561
+ var WorkspaceSchema = zod.z.object({
1562
+ id: zod.z.string().min(1),
1563
+ projectId: zod.z.string().min(1),
1564
+ repoUrl: zod.z.string().url(),
1565
+ defaultBranch: zod.z.string().default("main"),
1566
+ allowedCapabilities: zod.z.array(NodeCapabilitySchema).optional(),
1567
+ createdAt: zod.z.string().datetime()
1568
+ });
1569
+ var RegisterWorkspaceSchema = zod.z.object({
1570
+ projectId: zod.z.string().min(1),
1571
+ repoUrl: zod.z.string().url(),
1572
+ defaultBranch: zod.z.string().default("main"),
1573
+ allowedCapabilities: zod.z.array(NodeCapabilitySchema).optional()
1574
+ });
1575
+ var JobEventTypeSchema = zod.z.enum([
1576
+ "job.queued",
1577
+ "job.assigned",
1578
+ "job.started",
1579
+ "job.token",
1580
+ "job.log",
1581
+ "job.progress",
1582
+ "job.artifact",
1583
+ "job.succeeded",
1584
+ "job.failed",
1585
+ "job.canceled"
1586
+ ]);
1587
+ var JobEventSchema = zod.z.object({
1588
+ type: JobEventTypeSchema,
1589
+ jobId: zod.z.string().min(1),
1590
+ nodeId: zod.z.string().optional(),
1591
+ timestamp: zod.z.string().datetime(),
1592
+ data: zod.z.record(zod.z.unknown()).default({})
1593
+ });
1594
+ var ProviderModeSchema = zod.z.enum(["local", "cloud", "auto"]);
1446
1595
 
1447
1596
  // src/voice/create-ticket.ts
1448
1597
  var voiceCreateTicketContract = {
@@ -1925,7 +2074,26 @@ exports.ContractValidationError = ContractValidationError;
1925
2074
  exports.DEFAULT_GRACE_EXTENSIONS = DEFAULT_GRACE_EXTENSIONS;
1926
2075
  exports.DURATION_SYNC_THRESHOLDS = DURATION_SYNC_THRESHOLDS;
1927
2076
  exports.GRACE_PRINCIPLES = GRACE_PRINCIPLES;
2077
+ exports.HeartbeatSchema = HeartbeatSchema;
2078
+ exports.JOB_TYPES = JOB_TYPES;
2079
+ exports.JobEventSchema = JobEventSchema;
2080
+ exports.JobEventTypeSchema = JobEventTypeSchema;
2081
+ exports.JobPrioritySchema = JobPrioritySchema;
2082
+ exports.JobResultSchema = JobResultSchema;
2083
+ exports.JobSchema = JobSchema;
2084
+ exports.JobStatusSchema = JobStatusSchema;
2085
+ exports.JobTypeSchema = JobTypeSchema;
2086
+ exports.NODE_CAPABILITIES = NODE_CAPABILITIES;
2087
+ exports.NodeCapabilitySchema = NodeCapabilitySchema;
2088
+ exports.NodeHardwareSchema = NodeHardwareSchema;
2089
+ exports.NodeSchema = NodeSchema;
2090
+ exports.NodeStatusSchema = NodeStatusSchema;
2091
+ exports.ProviderModeSchema = ProviderModeSchema;
2092
+ exports.RegisterNodeSchema = RegisterNodeSchema;
2093
+ exports.RegisterWorkspaceSchema = RegisterWorkspaceSchema;
2094
+ exports.SubmitJobSchema = SubmitJobSchema;
1928
2095
  exports.VOICE_CONTRACTS = VOICE_CONTRACTS;
2096
+ exports.WorkspaceSchema = WorkspaceSchema;
1929
2097
  exports.and = and;
1930
2098
  exports.calculateRiskScore = calculateRiskScore;
1931
2099
  exports.cloneJson = cloneJson;