@lota-sdk/shared 0.1.24 → 0.1.26

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.24",
3
+ "version": "0.1.26",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,5 +1,9 @@
1
1
  export const SILENT_EXECUTION_VISIBILITY = 'silent' as const
2
2
 
3
+ export const HUMAN_NODE_TYPES = ['human-input', 'human-approval', 'human-review-edit', 'human-decision'] as const
4
+
5
+ export const STRUCTURAL_NODE_TYPES = ['switch', 'join', 'deliberation-fork'] as const
6
+
3
7
  export const PROJECT_PLAN_ROUTING_PROMPT = `<project-plan-routing>
4
8
  - Use createExecutionPlan for small inline work inside the current workstream.
5
9
  - Use createProjectWithPlan when the work needs a dedicated project workstream, should stay visible in the sidebar or board, or needs 3 or more meaningful execution nodes.
@@ -1,34 +1,22 @@
1
1
  export const OPENAI_REASONING_MODEL_ID = 'openai/gpt-5.4' as const
2
2
 
3
+ export const OPENROUTER_GEMINI_FLASH_MODEL_ID = 'openrouter/google/gemini-3-flash-preview' as const
3
4
  export const OPENROUTER_TEAM_AGENT_MODEL_ID = 'openrouter/google/gemini-3.1-pro-preview' as const
4
- export const OPENROUTER_STRUCTURED_HELPER_MODEL_ID = 'openrouter/google/gemini-3-flash-preview' as const
5
- export const OPENROUTER_DELEGATED_REASONING_MODEL_ID = 'openrouter/google/gemini-3-flash-preview' as const
6
5
  export const OPENROUTER_WEB_RESEARCH_MODEL_ID = 'openrouter/stepfun/step-3.5-flash' as const
7
6
  export const OPENROUTER_FAST_REASONING_MODEL_ID = 'openrouter/qwen/qwen3.5-flash-02-23' as const
8
7
  export const OPENROUTER_STRUCTURED_REASONING_MODEL_ID = 'openrouter/google/gemini-3.1-pro-preview' as const
9
8
 
10
9
  export const AI_GATEWAY_REASONING_SUMMARY_LEVEL = 'detailed' as const
11
10
 
12
- export const OPENAI_HIGH_REASONING_PROVIDER_OPTIONS = {
13
- openai: { forceReasoning: true, reasoningEffort: 'high', reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
14
- } as const
15
-
16
- export const OPENROUTER_HIGH_REASONING_PROVIDER_OPTIONS = {
17
- openai: { forceReasoning: true, reasoningEffort: 'high', reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
18
- } as const
19
-
20
- export const OPENROUTER_XHIGH_REASONING_PROVIDER_OPTIONS = {
21
- openai: { forceReasoning: true, reasoningEffort: 'xhigh', reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
22
- } as const
23
-
24
- export const OPENROUTER_MEDIUM_REASONING_PROVIDER_OPTIONS = {
25
- openai: { forceReasoning: true, reasoningEffort: 'medium', reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
26
- } as const
27
-
28
- export const OPENROUTER_LOW_REASONING_PROVIDER_OPTIONS = {
29
- openai: { forceReasoning: true, reasoningEffort: 'low', reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
30
- } as const
31
-
32
- export const OPENROUTER_MINIMAL_REASONING_PROVIDER_OPTIONS = {
33
- openai: { forceReasoning: true, reasoningEffort: 'minimal', reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
34
- } as const
11
+ export function makeOpenRouterReasoningOptions(effort: string) {
12
+ return {
13
+ openai: { forceReasoning: true, reasoningEffort: effort, reasoningSummary: AI_GATEWAY_REASONING_SUMMARY_LEVEL },
14
+ } as const
15
+ }
16
+
17
+ export const OPENAI_HIGH_REASONING_PROVIDER_OPTIONS = makeOpenRouterReasoningOptions('high')
18
+ export const OPENROUTER_HIGH_REASONING_PROVIDER_OPTIONS = makeOpenRouterReasoningOptions('high')
19
+ export const OPENROUTER_XHIGH_REASONING_PROVIDER_OPTIONS = makeOpenRouterReasoningOptions('xhigh')
20
+ export const OPENROUTER_MEDIUM_REASONING_PROVIDER_OPTIONS = makeOpenRouterReasoningOptions('medium')
21
+ export const OPENROUTER_LOW_REASONING_PROVIDER_OPTIONS = makeOpenRouterReasoningOptions('low')
22
+ export const OPENROUTER_MINIMAL_REASONING_PROVIDER_OPTIONS = makeOpenRouterReasoningOptions('minimal')
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod'
2
2
 
3
- import { SILENT_EXECUTION_VISIBILITY } from '../constants/execution-plan'
3
+ import { SILENT_EXECUTION_VISIBILITY, STRUCTURAL_NODE_TYPES } from '../constants/execution-plan'
4
4
  import type { PlanArtifactSpec, PlanCompletionCheck, PlanDraft, PlanNodeOwner, PlanNodeType } from './execution-plan'
5
5
  import {
6
6
  ExecutionModeSchema,
@@ -16,7 +16,7 @@ import {
16
16
  PlanToolPolicySchema,
17
17
  } from './execution-plan'
18
18
 
19
- const STRUCTURAL_NODE_TYPES = new Set<PlanNodeType>(['switch', 'join', 'deliberation-fork'])
19
+ const STRUCTURAL_NODE_TYPE_SET = new Set<PlanNodeType>(STRUCTURAL_NODE_TYPES)
20
20
 
21
21
  const agentPlanOwnerStringSchema = z.string().trim().min(1).max(200)
22
22
 
@@ -86,7 +86,7 @@ function toDeliverableName(value: string, fallback: string): string {
86
86
  }
87
87
 
88
88
  function isStructuralNodeType(type: PlanNodeType): boolean {
89
- return STRUCTURAL_NODE_TYPES.has(type)
89
+ return STRUCTURAL_NODE_TYPE_SET.has(type)
90
90
  }
91
91
 
92
92
  function buildDefaultDeliverables(node: AgentPlanNodeDraft): PlanArtifactSpec[] {
@@ -223,9 +223,9 @@ export function expandAgentPlanDraft(draft: AgentPlanDraft): PlanDraft {
223
223
  title: draft.title,
224
224
  objective: draft.objective,
225
225
  schemas: {},
226
- defaultExecutionVisibility: SILENT_EXECUTION_VISIBILITY,
226
+ defaultExecutionVisibility: 'auto',
227
227
  nodes: expandedNodes,
228
- edges: draft.edges.map((edge) => PlanEdgeSpecSchema.parse({ ...edge, map: {} })),
228
+ edges: (draft.edges ?? []).map((edge) => PlanEdgeSpecSchema.parse({ ...edge, map: {} })),
229
229
  entryNodeIds: draft.entryNodeIds ? [...draft.entryNodeIds] : undefined,
230
230
  executionMode: draft.executionMode,
231
231
  }
@@ -54,7 +54,6 @@ export const PlanNodeTypeSchema = z
54
54
  'human-decision',
55
55
  'switch',
56
56
  'join',
57
- 'subgraph',
58
57
  'monitoring',
59
58
  'deliberation-fork',
60
59
  ])
@@ -112,7 +111,7 @@ export const PlanSpecStatusSchema = z.enum(['compiled', 'superseded']).meta({ id
112
111
  export type PlanSpecStatus = z.infer<typeof PlanSpecStatusSchema>
113
112
 
114
113
  export const PlanRunStatusSchema = z
115
- .enum(['running', 'awaiting-human', 'blocked', 'completed', 'failed', 'aborted', 'scheduled'])
114
+ .enum(['running', 'awaiting-human', 'blocked', 'completed', 'failed', 'aborted'])
116
115
  .meta({ id: 'PlanRunStatusSchema' })
117
116
  export type PlanRunStatus = z.infer<typeof PlanRunStatusSchema>
118
117
 
@@ -133,9 +132,7 @@ export const PlanNodeRunStatusSchema = z
133
132
  .meta({ id: 'PlanNodeRunStatusSchema' })
134
133
  export type PlanNodeRunStatus = z.infer<typeof PlanNodeRunStatusSchema>
135
134
 
136
- export const PlanAttemptStatusSchema = z
137
- .enum(['submitted', 'validated', 'completed', 'failed', 'rejected'])
138
- .meta({ id: 'PlanAttemptStatusSchema' })
135
+ export const PlanAttemptStatusSchema = z.enum(['completed', 'failed']).meta({ id: 'PlanAttemptStatusSchema' })
139
136
  export type PlanAttemptStatus = z.infer<typeof PlanAttemptStatusSchema>
140
137
 
141
138
  export const PlanValidationIssueSeveritySchema = z
@@ -177,8 +174,6 @@ export const PlanEventTypeSchema = z
177
174
  'escalation-triggered',
178
175
  'node-scheduled',
179
176
  'node-monitoring',
180
- 'cycle-started',
181
- 'cycle-completed',
182
177
  'feedback-analyzed',
183
178
  ])
184
179
  .meta({ id: 'PlanEventTypeSchema' })
@@ -320,8 +315,11 @@ export type PlanNodeEscalation = z.infer<typeof PlanNodeEscalationSchema>
320
315
  export const NotificationSeveritySchema = z.enum(['info', 'warning', 'urgent', 'critical'])
321
316
  export type NotificationSeverity = z.infer<typeof NotificationSeveritySchema>
322
317
 
323
- export const PlanScheduleStatusSchema = z.enum(['active', 'paused', 'completed', 'cancelled'])
324
- export type PlanScheduleStatus = z.infer<typeof PlanScheduleStatusSchema>
318
+ const ActiveRecordStatusSchema = z.enum(['active', 'paused', 'completed', 'cancelled'])
319
+ type ActiveRecordStatus = z.infer<typeof ActiveRecordStatusSchema>
320
+
321
+ export const PlanScheduleStatusSchema = ActiveRecordStatusSchema
322
+ export type PlanScheduleStatus = ActiveRecordStatus
325
323
 
326
324
  export const PlanScheduleRecordSchema = z.object({
327
325
  id: recordIdSchema,
@@ -359,8 +357,8 @@ export const CycleScheduleSchema = z
359
357
  .strict()
360
358
  export type CycleSchedule = z.infer<typeof CycleScheduleSchema>
361
359
 
362
- export const PlanCycleStatusSchema = z.enum(['active', 'paused', 'completed', 'cancelled'])
363
- export type PlanCycleStatus = z.infer<typeof PlanCycleStatusSchema>
360
+ export const PlanCycleStatusSchema = ActiveRecordStatusSchema
361
+ export type PlanCycleStatus = ActiveRecordStatus
364
362
 
365
363
  export const ExecutionModeSchema = z.enum(['linear', 'graph-lite', 'graph-full']).default('linear')
366
364
  export type ExecutionMode = z.infer<typeof ExecutionModeSchema>
@@ -624,33 +622,11 @@ export const PlanSpecSchema = z.object({
624
622
  })
625
623
  export type PlanSpecRecord = z.infer<typeof PlanSpecSchema>
626
624
 
627
- export const PlanNodeSpecRecordSchema = z.object({
625
+ export const PlanNodeSpecRecordSchema = PlanNodeSpecSchema.omit({ id: true }).extend({
628
626
  id: recordIdSchema,
629
627
  planSpecId: recordIdSchema,
630
- nodeId: z.string(),
628
+ nodeId: PlanNodeSpecSchema.shape.id,
631
629
  position: z.number().int().nonnegative(),
632
- type: PlanNodeTypeSchema,
633
- label: z.string(),
634
- owner: PlanNodeOwnerSchema,
635
- objective: z.string(),
636
- instructions: z.string(),
637
- inputSchemaRef: z.string().optional(),
638
- outputSchemaRef: z.string().optional(),
639
- deliverables: z.array(PlanArtifactSpecSchema),
640
- successCriteria: z.array(z.string()),
641
- completionChecks: z.array(PlanCompletionCheckSchema),
642
- retryPolicy: PlanRetryPolicySchema,
643
- failurePolicy: z.array(PlanFailureRuleSchema),
644
- timeoutMs: z.number().int().positive().optional(),
645
- toolPolicy: PlanToolPolicySchema,
646
- contextPolicy: PlanContextPolicySchema,
647
- executionVisibility: PlanExecutionVisibilitySchema.default('auto'),
648
- schedule: PlanScheduleSpecSchema.optional(),
649
- deadline: DeadlineSpecSchema.optional(),
650
- escalation: PlanNodeEscalationSchema.optional(),
651
- monitoringConfig: MonitoringWindowConfigSchema.optional(),
652
- delayAfterPredecessorMs: z.number().int().positive().optional(),
653
- deliberationConfig: DeliberationForkConfigSchema.optional(),
654
630
  upstreamNodeIds: z.array(z.string()).default([]),
655
631
  downstreamNodeIds: z.array(z.string()).default([]),
656
632
  createdAt: dbDateTimeSchema,
@@ -799,24 +775,18 @@ export const PlanEventSchema = z.object({
799
775
  })
800
776
  export type PlanEventRecord = z.infer<typeof PlanEventSchema>
801
777
 
802
- export const SerializablePlanNodeSchema = z.object({
803
- id: z.string(),
804
- type: PlanNodeTypeSchema,
805
- label: z.string(),
806
- owner: PlanNodeOwnerSchema,
807
- objective: z.string(),
808
- instructions: z.string(),
778
+ export const SerializablePlanNodeSchema = PlanNodeSpecRecordSchema.omit({
779
+ id: true,
780
+ planSpecId: true,
781
+ nodeId: true,
782
+ position: true,
783
+ createdAt: true,
784
+ updatedAt: true,
785
+ }).extend({
786
+ id: PlanNodeSpecRecordSchema.shape.nodeId,
809
787
  inputSchemaRef: z.string().nullish(),
810
788
  outputSchemaRef: z.string().nullish(),
811
- deliverables: z.array(PlanArtifactSpecSchema),
812
- successCriteria: z.array(z.string()),
813
- completionChecks: z.array(PlanCompletionCheckSchema),
814
- retryPolicy: PlanRetryPolicySchema,
815
- failurePolicy: z.array(PlanFailureRuleSchema),
816
789
  timeoutMs: z.number().int().positive().nullish(),
817
- toolPolicy: PlanToolPolicySchema,
818
- contextPolicy: PlanContextPolicySchema,
819
- executionVisibility: PlanExecutionVisibilitySchema,
820
790
  schedule: PlanScheduleSpecSchema.nullish(),
821
791
  deadline: DeadlineSpecSchema.nullish(),
822
792
  escalation: PlanNodeEscalationSchema.nullish(),
@@ -832,8 +802,6 @@ export const SerializablePlanNodeSchema = z.object({
832
802
  handoffContext: PlanNodeHandoffContextSchema.nullish(),
833
803
  blockedReason: z.string().nullish(),
834
804
  failureClass: PlanFailureClassSchema.nullish(),
835
- upstreamNodeIds: z.array(z.string()),
836
- downstreamNodeIds: z.array(z.string()),
837
805
  readyAt: z.iso.datetime().nullish(),
838
806
  startedAt: z.iso.datetime().nullish(),
839
807
  completedAt: z.iso.datetime().nullish(),
@@ -3,12 +3,7 @@ import { z } from 'zod'
3
3
  import { AgentPlanDraftSchema } from './agent-plan-draft'
4
4
  import { baseChatMessageSchema } from './chat-api'
5
5
  import type { AnyChatMessage } from './chat-message'
6
- import {
7
- PlanDraftSchema,
8
- PlanNodeResultSubmissionSchema,
9
- PlanRunStatusSchema,
10
- SerializableExecutionPlanSchema,
11
- } from './execution-plan'
6
+ import { PlanNodeResultSubmissionSchema, PlanRunStatusSchema, SerializableExecutionPlanSchema } from './execution-plan'
12
7
 
13
8
  export const USER_QUESTIONS_TOOL_NAME = 'userQuestions' as const
14
9
  export const CONSULT_SPECIALIST_TOOL_NAME = 'consultSpecialist' as const
@@ -62,8 +57,13 @@ const ExecutionPlanToolActionSchema = z.enum([
62
57
  'none',
63
58
  ])
64
59
 
65
- export const CreateExecutionPlanArgsSchema = PlanDraftSchema.extend({
66
- targetWorkstreamId: z.string().trim().min(1).optional(),
60
+ export const CreateExecutionPlanArgsSchema = AgentPlanDraftSchema.extend({
61
+ targetWorkstreamId: z
62
+ .string()
63
+ .trim()
64
+ .min(1)
65
+ .optional()
66
+ .describe('Target workstream ID. Defaults to the current workstream.'),
67
67
  }).strict()
68
68
 
69
69
  export const CreateProjectWithPlanArgsSchema = AgentPlanDraftSchema.extend({
@@ -74,9 +74,9 @@ export const CreateProjectWithPlanArgsSchema = AgentPlanDraftSchema.extend({
74
74
  path: ['projectTitle'],
75
75
  })
76
76
 
77
- export const ReplaceExecutionPlanArgsSchema = PlanDraftSchema.extend({
78
- runId: z.string().trim().min(1),
79
- reason: z.string().trim().min(1).max(1000),
77
+ export const ReplaceExecutionPlanArgsSchema = AgentPlanDraftSchema.extend({
78
+ runId: z.string().trim().min(1).describe('ID of the plan run to replace.'),
79
+ reason: z.string().trim().min(1).max(1000).describe('Why the plan is being replaced.'),
80
80
  }).strict()
81
81
 
82
82
  export const SubmitExecutionNodeResultArgsSchema = z
@@ -90,11 +90,11 @@ export const ListExecutionPlansArgsSchema = z.object({}).strict()
90
90
  export const GetActiveExecutionPlanArgsSchema = z
91
91
  .object({
92
92
  runId: z.string().trim().min(1).optional(),
93
- includeEvents: z.boolean().default(true),
94
- includeArtifacts: z.boolean().default(true),
95
- includeApprovals: z.boolean().default(true),
96
- includeCheckpoints: z.boolean().default(false),
97
- includeValidationIssues: z.boolean().default(true),
93
+ includeEvents: z.boolean().default(true).describe('Include events'),
94
+ includeArtifacts: z.boolean().default(true).describe('Include artifacts'),
95
+ includeApprovals: z.boolean().default(true).describe('Include approvals'),
96
+ includeCheckpoints: z.boolean().default(false).describe('Include checkpoints'),
97
+ includeValidationIssues: z.boolean().default(true).describe('Include validation issues'),
98
98
  })
99
99
  .strict()
100
100
 
@@ -5,24 +5,6 @@ import { recordIdSchema, recordIdStringSchema } from './common'
5
5
  export const sdkWorkstreamModeSchema = z.enum(['direct', 'group'])
6
6
  export const sdkWorkstreamStatusSchema = z.enum(['regular', 'archived'])
7
7
 
8
- export const sdkWorkstreamSchema = z.object({
9
- id: recordIdStringSchema,
10
- organizationId: recordIdStringSchema,
11
- userId: recordIdStringSchema,
12
- agentId: z.string().nullable().optional(),
13
- mode: sdkWorkstreamModeSchema,
14
- core: z.boolean(),
15
- coreType: z.string().nullable().optional(),
16
- title: z.string(),
17
- status: sdkWorkstreamStatusSchema,
18
- nameGenerated: z.boolean(), // Ideally `isNameGenerated`, but maps directly to SurrealDB column `nameGenerated`
19
- isRunning: z.boolean(),
20
- isCompacting: z.boolean(),
21
- memoryBlock: z.string().optional(),
22
- createdAt: z.iso.datetime(),
23
- updatedAt: z.iso.datetime(),
24
- })
25
-
26
8
  export const sdkWorkstreamRecordSchema = z.object({
27
9
  id: recordIdSchema,
28
10
  organizationId: recordIdSchema,
@@ -36,15 +18,37 @@ export const sdkWorkstreamRecordSchema = z.object({
36
18
  memoryBlock: z.string().nullish(),
37
19
  memoryBlockSummary: z.string().nullish(),
38
20
  activeRunId: z.string().nullish(),
21
+ activeStreamId: z.string().nullish(),
39
22
  compactionSummary: z.string().nullish(),
40
23
  lastCompactedMessageId: z.string().nullish(),
41
24
  nameGenerated: z.boolean(), // Ideally `isNameGenerated`, but maps directly to SurrealDB column `nameGenerated`
42
25
  isCompacting: z.boolean().optional(),
43
26
  state: z.unknown().optional(),
27
+ turnCount: z.number().int(),
44
28
  createdAt: z.coerce.date(),
45
29
  updatedAt: z.coerce.date(),
46
30
  })
47
31
 
32
+ export const sdkWorkstreamSchema = sdkWorkstreamRecordSchema
33
+ .pick({ agentId: true, mode: true, core: true, coreType: true, status: true, nameGenerated: true })
34
+ .extend({
35
+ id: recordIdStringSchema,
36
+ organizationId: recordIdStringSchema,
37
+ userId: recordIdStringSchema,
38
+ title: z.string(),
39
+ isRunning: z.boolean(),
40
+ isCompacting: z.boolean(),
41
+ memoryBlock: z.string().optional(),
42
+ createdAt: z.iso.datetime(),
43
+ updatedAt: z.iso.datetime(),
44
+ })
45
+
46
+ export const sdkPublicWorkstreamSchema = sdkWorkstreamSchema.omit({
47
+ organizationId: true,
48
+ userId: true,
49
+ memoryBlock: true,
50
+ })
51
+
48
52
  export const sdkWorkstreamMessageSchema = z.object({
49
53
  id: recordIdStringSchema,
50
54
  workstreamId: recordIdStringSchema,
@@ -70,7 +74,8 @@ export const sdkWorkstreamAttachmentSchema = z.object({
70
74
  updatedAt: z.iso.datetime(),
71
75
  })
72
76
 
73
- export type SdkWorkstream = z.infer<typeof sdkWorkstreamSchema>
74
77
  export type SdkWorkstreamRecord = z.infer<typeof sdkWorkstreamRecordSchema>
78
+ export type SdkWorkstream = z.infer<typeof sdkWorkstreamSchema>
79
+ export type SdkPublicWorkstream = z.infer<typeof sdkPublicWorkstreamSchema>
75
80
  export type SdkWorkstreamMessage = z.infer<typeof sdkWorkstreamMessageSchema>
76
81
  export type SdkWorkstreamAttachment = z.infer<typeof sdkWorkstreamAttachmentSchema>