@lota-sdk/shared 0.1.19 → 0.1.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lota-sdk/shared",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -25,7 +25,7 @@
25
25
  "registry": "https://registry.npmjs.org/"
26
26
  },
27
27
  "dependencies": {
28
- "ai": "^6.0.137",
28
+ "ai": "^6.0.141",
29
29
  "zod": "^4.3.6"
30
30
  }
31
31
  }
package/src/index.ts CHANGED
@@ -9,12 +9,14 @@ export * from './schemas/common'
9
9
  export * from './schemas/confidence'
10
10
  export * from './schemas/document'
11
11
  export * from './schemas/error'
12
+ export * from './schemas/autonomous-job'
12
13
  export * from './schemas/execution-plan'
13
14
  export * from './schemas/graph-designer'
14
15
  export * from './schemas/organization'
15
16
  export * from './schemas/organization-api'
16
17
  export * from './schemas/playbook'
17
18
  export * from './schemas/plugin-coordination'
19
+ export * from './schemas/queue-job'
18
20
  export * from './schemas/recent-activity'
19
21
  export * from './schemas/repository-structure'
20
22
  export * from './schemas/tools'
@@ -0,0 +1,102 @@
1
+ import { z } from 'zod'
2
+
3
+ import { QueueJobErrorSchema } from './queue-job'
4
+
5
+ const apiDateTimeSchema = z.string().datetime({ offset: true })
6
+
7
+ export const AutonomousJobScheduleSchema = z.discriminatedUnion('kind', [
8
+ z
9
+ .object({
10
+ kind: z.literal('cron'),
11
+ cron: z.string().trim().min(1).max(200),
12
+ immediately: z.boolean().default(false),
13
+ })
14
+ .strict(),
15
+ z
16
+ .object({
17
+ kind: z.literal('every'),
18
+ intervalMs: z.number().int().min(60_000),
19
+ immediately: z.boolean().default(false),
20
+ })
21
+ .strict(),
22
+ z.object({ kind: z.literal('at'), at: apiDateTimeSchema }).strict(),
23
+ ])
24
+ export type AutonomousJobSchedule = z.infer<typeof AutonomousJobScheduleSchema>
25
+
26
+ export const AutonomousJobStatusSchema = z.enum(['active', 'paused', 'completed', 'failed', 'cancelled'])
27
+ export type AutonomousJobStatus = z.infer<typeof AutonomousJobStatusSchema>
28
+
29
+ export const AutonomousJobRunStatusSchema = z.enum(['queued', 'running', 'completed', 'failed', 'awaiting-human'])
30
+ export type AutonomousJobRunStatus = z.infer<typeof AutonomousJobRunStatusSchema>
31
+
32
+ export const AutonomousJobSchema = z
33
+ .object({
34
+ id: z.string(),
35
+ organizationId: z.string(),
36
+ ownerUserId: z.string(),
37
+ ownerUserName: z.string().optional(),
38
+ workstreamId: z.string(),
39
+ agentId: z.string(),
40
+ title: z.string(),
41
+ prompt: z.string(),
42
+ schedule: AutonomousJobScheduleSchema,
43
+ status: AutonomousJobStatusSchema,
44
+ autoPauseThreshold: z.number().int().positive(),
45
+ consecutiveErrorCount: z.number().int().nonnegative(),
46
+ lastRunStatus: AutonomousJobRunStatusSchema.optional(),
47
+ lastRunAt: apiDateTimeSchema.optional(),
48
+ nextRunAt: apiDateTimeSchema.optional(),
49
+ linkedPlanSpecId: z.string().optional(),
50
+ linkedPlanRunId: z.string().optional(),
51
+ lastError: QueueJobErrorSchema.optional(),
52
+ createdAt: apiDateTimeSchema,
53
+ updatedAt: apiDateTimeSchema,
54
+ })
55
+ .strict()
56
+ export type AutonomousJob = z.infer<typeof AutonomousJobSchema>
57
+
58
+ export const AutonomousJobRunSchema = z
59
+ .object({
60
+ id: z.string(),
61
+ autonomousJobId: z.string(),
62
+ workstreamId: z.string(),
63
+ queueJobId: z.string().optional(),
64
+ status: AutonomousJobRunStatusSchema,
65
+ inputMessageId: z.string().optional(),
66
+ assistantMessageIds: z.array(z.string()).default([]),
67
+ summary: z.string().optional(),
68
+ error: QueueJobErrorSchema.optional(),
69
+ linkedPlanSpecId: z.string().optional(),
70
+ linkedPlanRunId: z.string().optional(),
71
+ startedAt: apiDateTimeSchema.optional(),
72
+ completedAt: apiDateTimeSchema.optional(),
73
+ createdAt: apiDateTimeSchema,
74
+ updatedAt: apiDateTimeSchema,
75
+ })
76
+ .strict()
77
+ export type AutonomousJobRun = z.infer<typeof AutonomousJobRunSchema>
78
+
79
+ export const CreateAutonomousJobInputSchema = z
80
+ .object({
81
+ organizationId: z.string().trim().min(1),
82
+ ownerUserId: z.string().trim().min(1),
83
+ ownerUserName: z.string().trim().min(1).max(200).optional(),
84
+ agentId: z.string().trim().min(1).max(200),
85
+ title: z.string().trim().min(1).max(300),
86
+ prompt: z.string().trim().min(1).max(10_000),
87
+ schedule: AutonomousJobScheduleSchema,
88
+ autoPauseThreshold: z.number().int().positive().default(3),
89
+ workstreamTitle: z.string().trim().min(1).max(300).optional(),
90
+ })
91
+ .strict()
92
+ export type CreateAutonomousJobInput = z.infer<typeof CreateAutonomousJobInputSchema>
93
+
94
+ export const UpdateAutonomousJobInputSchema = z
95
+ .object({
96
+ title: z.string().trim().min(1).max(300).optional(),
97
+ prompt: z.string().trim().min(1).max(10_000).optional(),
98
+ schedule: AutonomousJobScheduleSchema.optional(),
99
+ autoPauseThreshold: z.number().int().positive().optional(),
100
+ })
101
+ .strict()
102
+ export type UpdateAutonomousJobInput = z.infer<typeof UpdateAutonomousJobInputSchema>
@@ -0,0 +1,64 @@
1
+ import { z } from 'zod'
2
+
3
+ export const QueueJobStatusSchema = z.enum(['waiting', 'delayed', 'active', 'completed', 'failed'])
4
+ export type QueueJobStatus = z.infer<typeof QueueJobStatusSchema>
5
+
6
+ export const QueueJobAttemptStatusSchema = z.enum(['active', 'completed', 'failed'])
7
+ export type QueueJobAttemptStatus = z.infer<typeof QueueJobAttemptStatusSchema>
8
+
9
+ export const QueueJobErrorSchema = z
10
+ .object({
11
+ name: z.string().optional(),
12
+ message: z.string(),
13
+ stack: z.string().optional(),
14
+ code: z.string().optional(),
15
+ details: z.record(z.string(), z.unknown()).optional(),
16
+ })
17
+ .strict()
18
+ export type QueueJobError = z.infer<typeof QueueJobErrorSchema>
19
+
20
+ export const QueueJobContextSchema = z.record(z.string(), z.unknown())
21
+ export type QueueJobContext = z.infer<typeof QueueJobContextSchema>
22
+
23
+ export const QueueJobSchema = z
24
+ .object({
25
+ id: z.string(),
26
+ queueName: z.string(),
27
+ jobName: z.string(),
28
+ bullmqJobId: z.string(),
29
+ status: QueueJobStatusSchema,
30
+ data: z.unknown().optional(),
31
+ options: QueueJobContextSchema.optional(),
32
+ context: QueueJobContextSchema.optional(),
33
+ deduplicationId: z.string().optional(),
34
+ schedulerId: z.string().optional(),
35
+ maxAttempts: z.number().int().nonnegative().optional(),
36
+ attemptCount: z.number().int().nonnegative().default(0),
37
+ result: z.unknown().optional(),
38
+ lastError: QueueJobErrorSchema.optional(),
39
+ queuedAt: z.string().datetime({ offset: true }),
40
+ startedAt: z.string().datetime({ offset: true }).optional(),
41
+ completedAt: z.string().datetime({ offset: true }).optional(),
42
+ failedAt: z.string().datetime({ offset: true }).optional(),
43
+ createdAt: z.string().datetime({ offset: true }),
44
+ updatedAt: z.string().datetime({ offset: true }),
45
+ })
46
+ .strict()
47
+ export type QueueJob = z.infer<typeof QueueJobSchema>
48
+
49
+ export const QueueJobAttemptSchema = z
50
+ .object({
51
+ id: z.string(),
52
+ queueJobId: z.string(),
53
+ attemptNumber: z.number().int().positive(),
54
+ status: QueueJobAttemptStatusSchema,
55
+ result: z.unknown().optional(),
56
+ error: QueueJobErrorSchema.optional(),
57
+ startedAt: z.string().datetime({ offset: true }),
58
+ completedAt: z.string().datetime({ offset: true }).optional(),
59
+ durationMs: z.number().int().nonnegative().optional(),
60
+ createdAt: z.string().datetime({ offset: true }),
61
+ updatedAt: z.string().datetime({ offset: true }),
62
+ })
63
+ .strict()
64
+ export type QueueJobAttempt = z.infer<typeof QueueJobAttemptSchema>