@agentrix/shared 2.0.2 → 2.0.5

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
@@ -207,6 +207,8 @@ const StartTaskRequestSchema = zod.z.object({
207
207
  // base64 sealed-box payload for local machines
208
208
  cwd: zod.z.string().optional(),
209
209
  // For local mode: current working directory
210
+ forceUserCwd: zod.z.boolean().optional(),
211
+ // For local mode: force using user-provided cwd (no worktree)
210
212
  machineId: zod.z.string().optional(),
211
213
  // For local mode: specific machine
212
214
  cloudId: zod.z.string().optional(),
@@ -247,6 +249,7 @@ const StartTaskResponseSchema = zod.z.object({
247
249
  baseBranch: zod.z.string().nullable(),
248
250
  title: zod.z.string().nullable(),
249
251
  userCwd: zod.z.string().nullable(),
252
+ forceUserCwd: zod.z.boolean().nullable(),
250
253
  createdAt: DateSchema,
251
254
  updatedAt: DateSchema
252
255
  });
@@ -272,6 +275,8 @@ const TaskItemSchema = zod.z.object({
272
275
  // Current working directory from CLI worker
273
276
  userCwd: zod.z.string().nullable(),
274
277
  // User-provided working directory for local mode
278
+ forceUserCwd: zod.z.boolean().nullable(),
279
+ // Force using user-provided cwd (no worktree)
275
280
  repositorySourceType: zod.z.enum(["temporary", "directory", "git-server"]).nullable(),
276
281
  // Repository source type
277
282
  pullRequestNumber: zod.z.number().nullable(),
@@ -388,9 +393,11 @@ const ProjectDirectoryResponseSchema = zod.z.object({
388
393
  const QueryEventsRequestSchema = zod.z.object({
389
394
  limit: zod.z.coerce.number().min(1).max(100).optional(),
390
395
  offset: zod.z.coerce.number().min(0).optional(),
391
- before: zod.z.string().datetime().optional(),
392
- after: zod.z.string().datetime().optional(),
393
- eventType: zod.z.enum(["task-message", "task-artifacts-updated"]).optional()
396
+ before: zod.z.coerce.number().int().min(0).optional(),
397
+ after: zod.z.coerce.number().int().min(0).optional()
398
+ });
399
+ const FillEventsRequestSchema = zod.z.object({
400
+ sequences: zod.z.array(zod.z.coerce.number().int().min(0)).min(1)
394
401
  });
395
402
  const CreateMergeRequestSchema = zod.z.object({
396
403
  taskId: zod.z.string(),
@@ -487,8 +494,16 @@ const CreateChatRequestSchema = zod.z.object({
487
494
  members: zod.z.array(ChatMemberInputSchema)
488
495
  });
489
496
  const CreateChatResponseSchema = ChatWithMembersSchema;
497
+ const ListChatsQuerySchema = zod.z.object({
498
+ before: zod.z.string().optional(),
499
+ // ISO 8601 string
500
+ after: zod.z.string().optional(),
501
+ // ISO 8601 string
502
+ limit: zod.z.coerce.number().min(1).max(200).optional()
503
+ });
490
504
  const ListChatsResponseSchema = zod.z.object({
491
- chats: zod.z.array(ChatWithMembersSchema)
505
+ chats: zod.z.array(ChatWithMembersSchema),
506
+ hasMore: zod.z.boolean()
492
507
  });
493
508
  const GetChatResponseSchema = ChatWithMembersSchema;
494
509
  const ListChatMembersResponseSchema = zod.z.object({
@@ -536,8 +551,8 @@ const AgentCustomConfigSchema = zod.z.object({
536
551
  const AgentPermissionsSchema = zod.z.object({
537
552
  role: zod.z.string(),
538
553
  // "all" | "low"
539
- path: zod.z.string()
540
- // URL/path pattern
554
+ paths: zod.z.array(zod.z.string()).optional()
555
+ // URL/path patterns
541
556
  });
542
557
  const AgentSchema = zod.z.object({
543
558
  id: IdSchema,
@@ -591,23 +606,20 @@ const DeleteAgentResponseSchema = zod.z.object({
591
606
  message: zod.z.string(),
592
607
  agentId: IdSchema
593
608
  });
594
- const DeploymentVariableSchema = zod.z.object({
609
+ const EnvironmentVariableSchema = zod.z.object({
595
610
  name: zod.z.string(),
596
611
  type: zod.z.enum(["string", "number", "boolean", "secret"]),
597
612
  description: zod.z.string().optional(),
598
613
  required: zod.z.boolean().default(false),
599
614
  defaultValue: zod.z.string().optional()
600
615
  });
601
- const AgentBuilderConfigSchema = zod.z.object({
602
- // UI messages (moved from top-level Agent fields)
603
- guildMsg: zod.z.string().default("what can I do for you today?"),
604
- placeholderMsg: zod.z.string().default("Ask me anything..."),
605
- // Deployment configuration (from CLI envVars)
606
- deploymentSchema: zod.z.array(DeploymentVariableSchema).optional(),
616
+ const DraftAgentConfigSchema = zod.z.object({
617
+ // environment configuration (from CLI envVars)
618
+ environmentSchema: zod.z.array(EnvironmentVariableSchema).optional(),
607
619
  // Display configuration (same as AgentCustomConfig)
608
620
  displayConfig: DisplayConfigSchema.optional()
609
621
  });
610
- const CreateAgentBuilderRequestSchema = zod.z.object({
622
+ const CreateDraftAgentRequestSchema = zod.z.object({
611
623
  name: zod.z.string().min(1, "Name is required"),
612
624
  agentDir: zod.z.string().min(1, "Agent directory is required"),
613
625
  type: AgentTypeSchema.default("claude"),
@@ -615,10 +627,21 @@ const CreateAgentBuilderRequestSchema = zod.z.object({
615
627
  description: zod.z.string().optional(),
616
628
  userId: zod.z.string(),
617
629
  taskId: zod.z.string(),
618
- envVars: zod.z.array(DeploymentVariableSchema).optional()
630
+ envVars: zod.z.array(EnvironmentVariableSchema).optional(),
619
631
  // From CLI tool
632
+ isUpdate: zod.z.boolean().optional().default(false).describe("Whether is agent updated")
620
633
  });
621
- const AgentBuilderSchema = zod.z.object({
634
+ const SetEnvironmentVariablesRequestSchema = zod.z.object({
635
+ ownerType: zod.z.enum(["draft-agent", "agent", "machine", "cloud"]),
636
+ ownerId: zod.z.string(),
637
+ variables: zod.z.record(zod.z.string(), zod.z.string())
638
+ // { name: value }
639
+ });
640
+ const GetEnvironmentVariablesResponseSchema = zod.z.object({
641
+ variables: zod.z.record(zod.z.string(), zod.z.string())
642
+ // { name: value }
643
+ });
644
+ const DraftAgentSchema = zod.z.object({
622
645
  id: IdSchema,
623
646
  name: zod.z.string(),
624
647
  displayName: zod.z.string(),
@@ -628,7 +651,7 @@ const AgentBuilderSchema = zod.z.object({
628
651
  userId: zod.z.string(),
629
652
  description: zod.z.string().nullable(),
630
653
  enable: zod.z.boolean(),
631
- config: AgentBuilderConfigSchema.nullable(),
654
+ config: DraftAgentConfigSchema.nullable(),
632
655
  permissions: AgentPermissionsSchema.nullable(),
633
656
  publishedAgentId: zod.z.string().nullable(),
634
657
  sourceTaskId: zod.z.string().nullable(),
@@ -638,8 +661,8 @@ const AgentBuilderSchema = zod.z.object({
638
661
  const GetUserAgentsResponseSchema = zod.z.object({
639
662
  agents: zod.z.array(AgentSchema),
640
663
  // Published agents
641
- builders: zod.z.array(AgentBuilderSchema)
642
- // Draft agent-builders
664
+ draftAgents: zod.z.array(DraftAgentSchema)
665
+ // Draft agents
643
666
  });
644
667
 
645
668
  const LocalMachineSchema = zod.z.object({
@@ -1004,7 +1027,7 @@ const RpcCallEventSchema = zod.z.object({
1004
1027
  taskId: zod.z.string(),
1005
1028
  method: zod.z.enum(["GET", "POST", "PATCH", "DELETE"]),
1006
1029
  path: zod.z.string(),
1007
- // API path, e.g., "/v1/agent-builder"
1030
+ // API path, e.g., "/v1/draft-agent"
1008
1031
  query: zod.z.record(zod.z.any()).optional(),
1009
1032
  // Query params for GET requests
1010
1033
  body: zod.z.any().optional()
@@ -1042,10 +1065,24 @@ const AskUserMessageSchema = zod.z.object({
1042
1065
  questions: zod.z.array(AskUserQuestionSchema).min(1).max(4)
1043
1066
  // 1-4 questions
1044
1067
  });
1068
+ const AskUserResponseStatusSchema = zod.z.enum(["answered", "cancelled", "timeout"]);
1069
+ const AskUserResponseReasonSchema = zod.z.enum(["user", "timeout", "system"]);
1045
1070
  const AskUserResponseMessageSchema = zod.z.object({
1046
1071
  type: zod.z.literal("ask_user_response"),
1047
- answers: zod.z.array(zod.z.string())
1072
+ answers: zod.z.array(zod.z.string()),
1048
1073
  // Array of answers (labels), one per question
1074
+ status: AskUserResponseStatusSchema.optional(),
1075
+ reason: AskUserResponseReasonSchema.optional()
1076
+ });
1077
+ const TaskArtifactsMessageSchema = zod.z.object({
1078
+ type: zod.z.literal("task_artifacts_updated"),
1079
+ commitHash: zod.z.string(),
1080
+ timestamp: zod.z.string(),
1081
+ stats: zod.z.object({
1082
+ totalInsertions: zod.z.number(),
1083
+ totalDeletions: zod.z.number(),
1084
+ files: zod.z.array(FileStatsSchema)
1085
+ })
1049
1086
  });
1050
1087
  function isAskUserMessage(message) {
1051
1088
  return typeof message === "object" && message !== null && "type" in message && message.type === "ask_user";
@@ -1053,8 +1090,11 @@ function isAskUserMessage(message) {
1053
1090
  function isAskUserResponseMessage(message) {
1054
1091
  return typeof message === "object" && message !== null && "type" in message && message.type === "ask_user_response";
1055
1092
  }
1093
+ function isTaskArtifactsMessage(message) {
1094
+ return typeof message === "object" && message !== null && "type" in message && message.type === "task_artifacts_updated";
1095
+ }
1056
1096
  function isSDKMessage(message) {
1057
- return typeof message === "object" && message !== null && "type" in message && message.type !== "ask_user" && message.type !== "ask_user_response";
1097
+ return typeof message === "object" && message !== null && "type" in message && message.type !== "ask_user" && message.type !== "ask_user_response" && message.type !== "task_artifacts_updated";
1058
1098
  }
1059
1099
  const EventBaseSchema = zod.z.object({
1060
1100
  eventId: zod.z.string()
@@ -1131,13 +1171,15 @@ const baseTaskSchema = EventBaseSchema.extend({
1131
1171
  agentId: zod.z.string(),
1132
1172
  agentType: zod.z.string().optional().default("claude"),
1133
1173
  agentDir: zod.z.string().optional(),
1134
- // Absolute path to agent directory (only for agent-builders)
1174
+ // Absolute path to agent directory (only for draft agents)
1135
1175
  gitUrl: zod.z.string().optional(),
1136
1176
  baseBranch: zod.z.string().optional(),
1137
1177
  cwd: zod.z.string().optional(),
1138
1178
  // Current working directory for the task, only used under 'local' mode
1139
1179
  userCwd: zod.z.string().optional(),
1140
1180
  // User-provided working directory for local mode
1181
+ forceUserCwd: zod.z.boolean().optional(),
1182
+ // Force using user-provided cwd (no worktree)
1141
1183
  dataEncryptionKey: zod.z.string().optional(),
1142
1184
  // User's public key for encrypting sensitive data
1143
1185
  model: zod.z.string().optional(),
@@ -1152,8 +1194,10 @@ const baseTaskSchema = EventBaseSchema.extend({
1152
1194
  // Maximum number of turns for the agent (default: 50)
1153
1195
  repositoryId: zod.z.string().optional(),
1154
1196
  // Existing repository ID (used to skip auto-association)
1155
- repositorySourceType: zod.z.enum(["temporary", "directory", "git-server"]).optional()
1197
+ repositorySourceType: zod.z.enum(["temporary", "directory", "git-server"]).optional(),
1156
1198
  // Repository source type (determines workspace mode)
1199
+ environmentVariables: zod.z.record(zod.z.string(), zod.z.string()).optional()
1200
+ // Environment variables for task execution
1157
1201
  });
1158
1202
  const createTaskSchema = baseTaskSchema.extend({
1159
1203
  message: zod.z.custom(
@@ -1202,9 +1246,11 @@ const StopTaskSchema = EventBaseSchema.extend({
1202
1246
  });
1203
1247
  const TaskMessageSchema = EventBaseSchema.extend({
1204
1248
  taskId: zod.z.string(),
1249
+ chatId: zod.z.string().optional(),
1205
1250
  from: zod.z.enum(["app", "api-server", "machine", "worker"]),
1206
1251
  opCode: zod.z.string().optional(),
1207
1252
  // eventId of the message this is responding to (e.g., ask_user_response → ask_user)
1253
+ sequence: zod.z.number().int().min(0).optional(),
1208
1254
  message: zod.z.custom(
1209
1255
  (data) => {
1210
1256
  return typeof data === "object" && data !== null && "type" in data;
@@ -1225,14 +1271,21 @@ const TaskMessageSchema = EventBaseSchema.extend({
1225
1271
  );
1226
1272
  const TaskArtifactsUpdatedEventSchema = EventBaseSchema.extend({
1227
1273
  taskId: zod.z.string(),
1228
- commitHash: zod.z.string(),
1229
- timestamp: zod.z.string(),
1230
1274
  stats: zod.z.object({
1231
1275
  totalInsertions: zod.z.number(),
1232
- totalDeletions: zod.z.number(),
1233
- files: zod.z.array(FileStatsSchema)
1276
+ totalDeletions: zod.z.number()
1234
1277
  })
1235
1278
  });
1279
+ const ShowModalEventDataSchema = EventBaseSchema.extend({
1280
+ taskId: zod.z.string(),
1281
+ chatId: zod.z.string().optional(),
1282
+ sequence: zod.z.number().int().min(0).optional(),
1283
+ timestamp: zod.z.string(),
1284
+ modalName: zod.z.string(),
1285
+ // e.g., "configure-env-vars"
1286
+ modalData: zod.z.record(zod.z.any())
1287
+ // Modal-specific data
1288
+ });
1236
1289
  const ChangeTaskTitleEventSchema = EventBaseSchema.extend({
1237
1290
  taskId: zod.z.string(),
1238
1291
  title: zod.z.string()
@@ -1385,7 +1438,8 @@ const SystemMessageSchema = EventBaseSchema.extend({
1385
1438
  "chat-member-removed",
1386
1439
  "repo-added",
1387
1440
  "repo-removed",
1388
- "pr-state-changed"
1441
+ "pr-state-changed",
1442
+ "draft-agent-added"
1389
1443
  ]),
1390
1444
  data: zod.z.union([
1391
1445
  IdOnlySchema,
@@ -1398,8 +1452,10 @@ const SystemMessageSchema = EventBaseSchema.extend({
1398
1452
  // chat-member-removed (array)
1399
1453
  RepositorySchema,
1400
1454
  // repo-added
1401
- PrStateChangedSchema
1455
+ PrStateChangedSchema,
1402
1456
  // pr-state-changed
1457
+ DraftAgentSchema
1458
+ // draft-agent-added
1403
1459
  ]),
1404
1460
  timestamp: zod.z.string()
1405
1461
  });
@@ -1429,6 +1485,8 @@ const EventSchemaMap = {
1429
1485
  "task-info-update": TaskInfoUpdateEventDataSchema,
1430
1486
  // Artifacts events
1431
1487
  "task-artifacts-updated": TaskArtifactsUpdatedEventSchema,
1488
+ // Modal events
1489
+ "show-modal": ShowModalEventDataSchema,
1432
1490
  // Merge request events
1433
1491
  "merge-request": MergeRequestEventSchema,
1434
1492
  "merge-pr": MergePullRequestEventSchema,
@@ -2040,8 +2098,6 @@ function splitRtcChunkFrame(data) {
2040
2098
 
2041
2099
  exports.AddChatMemberRequestSchema = AddChatMemberRequestSchema;
2042
2100
  exports.AddChatMemberResponseSchema = AddChatMemberResponseSchema;
2043
- exports.AgentBuilderConfigSchema = AgentBuilderConfigSchema;
2044
- exports.AgentBuilderSchema = AgentBuilderSchema;
2045
2101
  exports.AgentConfigValidationError = AgentConfigValidationError;
2046
2102
  exports.AgentCustomConfigSchema = AgentCustomConfigSchema;
2047
2103
  exports.AgentError = AgentError;
@@ -2063,6 +2119,8 @@ exports.AskUserMessageSchema = AskUserMessageSchema;
2063
2119
  exports.AskUserOptionSchema = AskUserOptionSchema;
2064
2120
  exports.AskUserQuestionSchema = AskUserQuestionSchema;
2065
2121
  exports.AskUserResponseMessageSchema = AskUserResponseMessageSchema;
2122
+ exports.AskUserResponseReasonSchema = AskUserResponseReasonSchema;
2123
+ exports.AskUserResponseStatusSchema = AskUserResponseStatusSchema;
2066
2124
  exports.AssociateRepoEventDataSchema = AssociateRepoEventDataSchema;
2067
2125
  exports.BillingStatsResponseSchema = BillingStatsResponseSchema;
2068
2126
  exports.BranchSchema = BranchSchema;
@@ -2085,13 +2143,13 @@ exports.CloudSchema = CloudSchema;
2085
2143
  exports.ConfirmUploadRequestSchema = ConfirmUploadRequestSchema;
2086
2144
  exports.ConfirmUploadResponseSchema = ConfirmUploadResponseSchema;
2087
2145
  exports.ConsumeTransactionSchema = ConsumeTransactionSchema;
2088
- exports.CreateAgentBuilderRequestSchema = CreateAgentBuilderRequestSchema;
2089
2146
  exports.CreateAgentRequestSchema = CreateAgentRequestSchema;
2090
2147
  exports.CreateAgentResponseSchema = CreateAgentResponseSchema;
2091
2148
  exports.CreateChatRequestSchema = CreateChatRequestSchema;
2092
2149
  exports.CreateChatResponseSchema = CreateChatResponseSchema;
2093
2150
  exports.CreateCloudRequestSchema = CreateCloudRequestSchema;
2094
2151
  exports.CreateCloudResponseSchema = CreateCloudResponseSchema;
2152
+ exports.CreateDraftAgentRequestSchema = CreateDraftAgentRequestSchema;
2095
2153
  exports.CreateMergeRequestResponseSchema = CreateMergeRequestResponseSchema;
2096
2154
  exports.CreateMergeRequestSchema = CreateMergeRequestSchema;
2097
2155
  exports.CreateOAuthServerRequestSchema = CreateOAuthServerRequestSchema;
@@ -2103,18 +2161,22 @@ exports.CreditsPackageSchema = CreditsPackageSchema;
2103
2161
  exports.DateSchema = DateSchema;
2104
2162
  exports.DeleteAgentResponseSchema = DeleteAgentResponseSchema;
2105
2163
  exports.DeleteOAuthServerResponseSchema = DeleteOAuthServerResponseSchema;
2106
- exports.DeploymentVariableSchema = DeploymentVariableSchema;
2107
2164
  exports.DisplayConfigKeysSchema = DisplayConfigKeysSchema;
2108
2165
  exports.DisplayConfigSchema = DisplayConfigSchema;
2166
+ exports.DraftAgentConfigSchema = DraftAgentConfigSchema;
2167
+ exports.DraftAgentSchema = DraftAgentSchema;
2168
+ exports.EnvironmentVariableSchema = EnvironmentVariableSchema;
2109
2169
  exports.EventAckSchema = EventAckSchema;
2110
2170
  exports.EventSchemaMap = EventSchemaMap;
2111
2171
  exports.FRAMEWORK_TYPES = FRAMEWORK_TYPES;
2112
2172
  exports.FileItemSchema = FileItemSchema;
2113
2173
  exports.FileStatsSchema = FileStatsSchema;
2114
2174
  exports.FileVisibilitySchema = FileVisibilitySchema;
2175
+ exports.FillEventsRequestSchema = FillEventsRequestSchema;
2115
2176
  exports.FrameworkNotSupportedError = FrameworkNotSupportedError;
2116
2177
  exports.GetAgentResponseSchema = GetAgentResponseSchema;
2117
2178
  exports.GetChatResponseSchema = GetChatResponseSchema;
2179
+ exports.GetEnvironmentVariablesResponseSchema = GetEnvironmentVariablesResponseSchema;
2118
2180
  exports.GetGitServerResponseSchema = GetGitServerResponseSchema;
2119
2181
  exports.GetGitUrlQuerySchema = GetGitUrlQuerySchema;
2120
2182
  exports.GetGitUrlResponseSchema = GetGitUrlResponseSchema;
@@ -2132,6 +2194,7 @@ exports.ListAgentsResponseSchema = ListAgentsResponseSchema;
2132
2194
  exports.ListBranchesResponseSchema = ListBranchesResponseSchema;
2133
2195
  exports.ListChatMembersResponseSchema = ListChatMembersResponseSchema;
2134
2196
  exports.ListChatTasksResponseSchema = ListChatTasksResponseSchema;
2197
+ exports.ListChatsQuerySchema = ListChatsQuerySchema;
2135
2198
  exports.ListChatsResponseSchema = ListChatsResponseSchema;
2136
2199
  exports.ListFilesQuerySchema = ListFilesQuerySchema;
2137
2200
  exports.ListFilesResponseSchema = ListFilesResponseSchema;
@@ -2193,8 +2256,10 @@ exports.RtcIceServerSchema = RtcIceServerSchema;
2193
2256
  exports.RtcIceServersRequestSchema = RtcIceServersRequestSchema;
2194
2257
  exports.RtcIceServersResponseSchema = RtcIceServersResponseSchema;
2195
2258
  exports.RtcSignalSchema = RtcSignalSchema;
2259
+ exports.SetEnvironmentVariablesRequestSchema = SetEnvironmentVariablesRequestSchema;
2196
2260
  exports.ShareAuthQuerySchema = ShareAuthQuerySchema;
2197
2261
  exports.ShareAuthResponseSchema = ShareAuthResponseSchema;
2262
+ exports.ShowModalEventDataSchema = ShowModalEventDataSchema;
2198
2263
  exports.ShutdownMachineSchema = ShutdownMachineSchema;
2199
2264
  exports.SignatureAuthRequestSchema = SignatureAuthRequestSchema;
2200
2265
  exports.SignatureAuthResponseSchema = SignatureAuthResponseSchema;
@@ -2209,6 +2274,7 @@ exports.SyncCloudMachineResponseSchema = SyncCloudMachineResponseSchema;
2209
2274
  exports.SyncLocalMachineResponseSchema = SyncLocalMachineResponseSchema;
2210
2275
  exports.SyncMachineRequestSchema = SyncMachineRequestSchema;
2211
2276
  exports.SystemMessageSchema = SystemMessageSchema;
2277
+ exports.TaskArtifactsMessageSchema = TaskArtifactsMessageSchema;
2212
2278
  exports.TaskArtifactsUpdatedEventSchema = TaskArtifactsUpdatedEventSchema;
2213
2279
  exports.TaskInfoUpdateEventDataSchema = TaskInfoUpdateEventDataSchema;
2214
2280
  exports.TaskItemSchema = TaskItemSchema;
@@ -2276,6 +2342,7 @@ exports.getRandomBytes = getRandomBytes;
2276
2342
  exports.isAskUserMessage = isAskUserMessage;
2277
2343
  exports.isAskUserResponseMessage = isAskUserResponseMessage;
2278
2344
  exports.isSDKMessage = isSDKMessage;
2345
+ exports.isTaskArtifactsMessage = isTaskArtifactsMessage;
2279
2346
  exports.loadAgentConfig = loadAgentConfig;
2280
2347
  exports.machineAuth = machineAuth;
2281
2348
  exports.permissionResponseRequestSchema = permissionResponseRequestSchema;