@lota-sdk/shared 0.4.1 → 0.4.3

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.4.1",
3
+ "version": "0.4.3",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,7 +1,7 @@
1
1
  export const OPENAI_REASONING_MODEL_ID = 'openai/gpt-5.4' as const
2
2
 
3
3
  export const OPENROUTER_GEMINI_FLASH_MODEL_ID = 'openrouter/google/gemini-3-flash-preview' as const
4
- export const OPENROUTER_TEAM_AGENT_MODEL_ID = 'openrouter/google/gemini-3.1-pro-preview' as const
4
+ export const OPENROUTER_TEAM_AGENT_MODEL_ID = 'openrouter/google/gemini-3-flash-preview' as const
5
5
  export const OPENROUTER_WEB_RESEARCH_MODEL_ID = 'openrouter/stepfun/step-3.5-flash' as const
6
6
  export const OPENROUTER_FAST_REASONING_MODEL_ID = 'openrouter/qwen/qwen3.5-flash-02-23' as const
7
7
  export const OPENROUTER_STRUCTURED_REASONING_MODEL_ID = 'openrouter/google/gemini-3.1-pro-preview' as const
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export * from './runtime/agent-types'
5
5
  export * from './runtime/chat-message-metadata'
6
6
  export * from './runtime/execution-plan-result'
7
7
  export * from './schemas/agent-plan-draft'
8
+ export * from './schemas/artifact'
8
9
  export * from './schemas/chat-api'
9
10
  export * from './schemas/chat-message'
10
11
  export * from './schemas/common'
@@ -3,6 +3,7 @@ import type {
3
3
  Output,
4
4
  PrepareStepFunction,
5
5
  StopCondition,
6
+ ToolCallRepairFunction,
6
7
  ToolLoopAgentOnFinishCallback,
7
8
  ToolSet,
8
9
  } from 'ai'
@@ -16,6 +17,7 @@ export interface CreateRoutedAgentOptions<TTools extends ToolSet = ToolSet> {
16
17
  headers?: Record<string, string>
17
18
  stopWhen?: StopCondition<TTools> | Array<StopCondition<TTools>>
18
19
  prepareStep?: PrepareStepFunction<TTools>
20
+ repairToolCall?: ToolCallRepairFunction<TTools>
19
21
  maxRetries?: number
20
22
  output?: Output.Output
21
23
  modelOverride?: { model: LanguageModel; providerOptions?: Record<string, unknown> }
@@ -0,0 +1,99 @@
1
+ import { z } from 'zod'
2
+
3
+ import { recordIdSchema } from './common'
4
+
5
+ const dbDateTimeSchema = z.coerce.date()
6
+ const apiDateTimeSchema = z.string().datetime({ offset: true })
7
+
8
+ export const ArtifactKindSchema = z
9
+ .enum(['document', 'plan', 'brief', 'report', 'analysis', 'spec'])
10
+ .meta({ id: 'ArtifactKindSchema' })
11
+ export type ArtifactKind = z.infer<typeof ArtifactKindSchema>
12
+
13
+ export const ArtifactStatusSchema = z.enum(['active', 'superseded', 'archived']).meta({ id: 'ArtifactStatusSchema' })
14
+ export type ArtifactStatus = z.infer<typeof ArtifactStatusSchema>
15
+
16
+ export const ArtifactReferenceTargetSchema = z
17
+ .enum(['artifact', 'document'])
18
+ .meta({ id: 'ArtifactReferenceTargetSchema' })
19
+ export type ArtifactReferenceTarget = z.infer<typeof ArtifactReferenceTargetSchema>
20
+
21
+ export const ArtifactReferenceSchema = z
22
+ .object({
23
+ uri: z.string().trim().min(1).max(1000),
24
+ targetType: ArtifactReferenceTargetSchema,
25
+ targetId: z.string().trim().min(1).max(255),
26
+ })
27
+ .strict()
28
+ .meta({ id: 'ArtifactReferenceSchema' })
29
+ export type ArtifactReference = z.infer<typeof ArtifactReferenceSchema>
30
+
31
+ export const ArtifactRecordSchema = z
32
+ .object({
33
+ id: recordIdSchema,
34
+ organizationId: recordIdSchema,
35
+ authorAgentId: z.string(),
36
+ title: z.string(),
37
+ artifactKind: ArtifactKindSchema,
38
+ templateId: z.string(),
39
+ canonicalKey: z.string(),
40
+ version: z.number().int().positive(),
41
+ status: ArtifactStatusSchema,
42
+ supersededBy: recordIdSchema.optional(),
43
+ storageKey: z.string(),
44
+ description: z.string().optional(),
45
+ tags: z.array(z.string()).default([]),
46
+ references: z.array(ArtifactReferenceSchema).default([]),
47
+ sourceThreadId: recordIdSchema.optional(),
48
+ sourcePlanRunId: recordIdSchema.optional(),
49
+ sourcePlanNodeId: z.string().optional(),
50
+ createdAt: dbDateTimeSchema,
51
+ updatedAt: dbDateTimeSchema.optional(),
52
+ })
53
+ .meta({ id: 'ArtifactRecordSchema' })
54
+ export type ArtifactRecord = z.infer<typeof ArtifactRecordSchema>
55
+
56
+ export const ArtifactVersionSummarySchema = z
57
+ .object({
58
+ id: z.string(),
59
+ title: z.string(),
60
+ version: z.number().int().positive(),
61
+ status: ArtifactStatusSchema,
62
+ createdAt: apiDateTimeSchema,
63
+ })
64
+ .strict()
65
+ .meta({ id: 'ArtifactVersionSummarySchema' })
66
+ export type ArtifactVersionSummary = z.infer<typeof ArtifactVersionSummarySchema>
67
+
68
+ export const PublishArtifactArgsSchema = z
69
+ .object({
70
+ organizationId: z.string().trim().min(1).max(255),
71
+ authorAgentId: z.string().trim().min(1).max(255),
72
+ title: z.string().trim().min(1).max(300),
73
+ artifactKind: ArtifactKindSchema,
74
+ templateId: z.string().trim().min(1).max(255),
75
+ content: z
76
+ .string()
77
+ .min(1)
78
+ .refine((value) => value.trim().length > 0, 'Content is required.'),
79
+ canonicalKey: z.string().trim().min(1).max(255).optional(),
80
+ description: z.string().trim().min(1).max(1000).optional(),
81
+ tags: z.array(z.string().trim().min(1).max(100)).optional().default([]),
82
+ sourceThreadId: z.string().trim().min(1).max(255).optional(),
83
+ sourcePlanRunId: z.string().trim().min(1).max(255).optional(),
84
+ sourcePlanNodeId: z.string().trim().min(1).max(255).optional(),
85
+ deliverableName: z.string().trim().min(1).max(200).optional(),
86
+ })
87
+ .strict()
88
+ .meta({ id: 'PublishArtifactArgsSchema' })
89
+ export type PublishArtifactArgs = z.infer<typeof PublishArtifactArgsSchema>
90
+
91
+ export const GetArtifactResultSchema = z
92
+ .object({
93
+ artifact: ArtifactRecordSchema,
94
+ content: z.string(),
95
+ versions: z.array(ArtifactVersionSummarySchema),
96
+ backlinks: z.array(ArtifactRecordSchema),
97
+ })
98
+ .meta({ id: 'GetArtifactResultSchema' })
99
+ export type GetArtifactResult = z.infer<typeof GetArtifactResultSchema>
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod'
2
2
 
3
+ import { ArtifactKindSchema } from './artifact'
3
4
  import { recordIdSchema } from './common'
4
5
 
5
6
  /** For DB record schemas — accepts Date objects from SurrealDB and coerces strings */
@@ -220,6 +221,14 @@ export const PlanArtifactSpecSchema = z
220
221
  required: z.boolean().default(true),
221
222
  schemaRef: z.string().trim().min(1).max(200).optional(),
222
223
  description: z.string().trim().min(1).max(1000),
224
+ publishAs: z
225
+ .object({
226
+ artifactKind: ArtifactKindSchema,
227
+ templateId: z.string().trim().min(1).max(255),
228
+ canonicalKey: z.string().trim().min(1).max(255).optional(),
229
+ })
230
+ .strict()
231
+ .optional(),
223
232
  })
224
233
  .strict()
225
234
  export type PlanArtifactSpec = z.infer<typeof PlanArtifactSpecSchema>
@@ -419,7 +428,13 @@ export const PlanArtifactSubmissionSchema = z
419
428
  name: z.string().trim().min(1).max(200),
420
429
  kind: PlanArtifactKindSchema,
421
430
  description: z.string().trim().max(1000).optional(),
431
+ content: z
432
+ .string()
433
+ .min(1)
434
+ .refine((value) => value.trim().length > 0, 'Content is required.')
435
+ .optional(),
422
436
  payload: planStructuredPayloadSchema.optional(),
437
+ publishedArtifactId: z.string().trim().min(1).max(255).optional(),
423
438
  })
424
439
  .strict()
425
440
  export type PlanArtifactSubmission = z.infer<typeof PlanArtifactSubmissionSchema>
@@ -471,7 +486,7 @@ export const PlanDependencyTriggerModeSchema = z.enum(['block', 'notify', 'best-
471
486
  export type PlanDependencyTriggerMode = z.infer<typeof PlanDependencyTriggerModeSchema>
472
487
 
473
488
  export const PlanDependencySchema = z.object({
474
- sourcePlanTitle: z.string().trim().min(1).max(200),
489
+ sourcePlanSpecId: z.string().trim().min(1).max(255),
475
490
  sourceNodeId: z.string().trim().min(1).max(200),
476
491
  artifactName: z.string().trim().min(1).max(200),
477
492
  triggerMode: PlanDependencyTriggerModeSchema.default('block'),
@@ -685,7 +700,9 @@ export const PlanArtifactSchema = z.object({
685
700
  pointer: z.string(),
686
701
  schemaRef: z.string().optional(),
687
702
  description: z.string().optional(),
703
+ content: z.string().optional(),
688
704
  payload: planStructuredPayloadSchema.optional(),
705
+ publishedArtifactId: recordIdSchema.optional(),
689
706
  createdAt: dbDateTimeSchema,
690
707
  })
691
708
  export type PlanArtifactRecord = z.infer<typeof PlanArtifactSchema>
@@ -796,7 +813,9 @@ export const SerializablePlanArtifactSchema = z.object({
796
813
  pointer: z.string(),
797
814
  schemaRef: z.string().nullish(),
798
815
  description: z.string().nullish(),
816
+ content: z.string().nullish(),
799
817
  payload: planStructuredPayloadSchema.nullish(),
818
+ publishedArtifactId: z.string().nullish(),
800
819
  createdAt: z.iso.datetime(),
801
820
  })
802
821
  export type SerializablePlanArtifact = z.infer<typeof SerializablePlanArtifactSchema>
@@ -908,18 +927,28 @@ export const SerializableExecutionPlanSchema = z.object({
908
927
  })
909
928
  export type SerializableExecutionPlan = z.infer<typeof SerializableExecutionPlanSchema>
910
929
 
911
- export const PlanTemplateRecordSchema = z.object({
912
- id: recordIdSchema,
913
- organizationId: recordIdSchema,
914
- name: z.string(),
915
- description: z.string().optional(),
916
- draft: PlanDraftSchema,
917
- tags: z.array(z.string()).default([]),
918
- source: PlanTemplateSourceSchema,
919
- sourceRef: z.string().optional(),
920
- createdAt: dbDateTimeSchema,
921
- updatedAt: dbDateTimeSchema.optional(),
922
- })
930
+ export const PlanTemplateRecordSchema = z
931
+ .object({
932
+ id: recordIdSchema,
933
+ organizationId: recordIdSchema,
934
+ name: z.string(),
935
+ description: z.string().optional(),
936
+ draft: PlanDraftSchema,
937
+ tags: z.array(z.string()).default([]),
938
+ source: PlanTemplateSourceSchema,
939
+ sourceRef: z.string().optional(),
940
+ createdAt: dbDateTimeSchema,
941
+ updatedAt: dbDateTimeSchema.optional(),
942
+ })
943
+ .superRefine((value, ctx) => {
944
+ if (value.source !== 'user' && (!value.sourceRef || value.sourceRef.trim().length === 0)) {
945
+ ctx.addIssue({
946
+ code: z.ZodIssueCode.custom,
947
+ path: ['sourceRef'],
948
+ message: `sourceRef is required when source is "${value.source}".`,
949
+ })
950
+ }
951
+ })
923
952
  export type PlanTemplateRecord = z.infer<typeof PlanTemplateRecordSchema>
924
953
 
925
954
  export const PlanCycleRecordSchema = z.object({
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod'
2
2
 
3
- import { PlanArtifactKindSchema, PlanDraftSchema } from './execution-plan'
3
+ import { ArtifactKindSchema } from './artifact'
4
+ import { PlanDraftSchema } from './execution-plan'
4
5
 
5
6
  export const GraphDesignRequestSchema = z.object({
6
7
  objective: z.string().trim().min(1).max(4000),
@@ -8,7 +9,7 @@ export const GraphDesignRequestSchema = z.object({
8
9
  availableAgents: z.array(z.object({ agentId: z.string(), capabilities: z.array(z.string()) })),
9
10
  availablePlugins: z.array(z.object({ pluginRef: z.string(), operations: z.array(z.string()) })),
10
11
  contextArtifacts: z
11
- .array(z.object({ name: z.string(), kind: PlanArtifactKindSchema, summary: z.string().optional() }))
12
+ .array(z.object({ name: z.string(), kind: ArtifactKindSchema, summary: z.string().optional() }))
12
13
  .default([]),
13
14
  })
14
15
  export type GraphDesignRequest = z.infer<typeof GraphDesignRequestSchema>
@@ -188,6 +188,13 @@ export const ExecutionPlanArgsSchema = ExecutionPlanBaseArgsSchema.superRefine((
188
188
  addUnexpectedExecutionPlanFieldIssue(ctx, path, `${path} is not allowed when action is "create-project".`)
189
189
  }
190
190
  }
191
+ if (value.projectTitle === undefined && value.targetThreadId === undefined) {
192
+ addMissingExecutionPlanFieldIssue(
193
+ ctx,
194
+ 'projectTitle',
195
+ 'Either projectTitle or targetThreadId is required for create-project.',
196
+ )
197
+ }
191
198
  }
192
199
 
193
200
  if (value.action === 'replace') {