@lota-sdk/shared 0.4.5 → 0.4.7

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.5",
3
+ "version": "0.4.7",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -4,6 +4,7 @@ import { AgentPlanDraftSchema, AgentPlanEdgeDraftSchema } from './agent-plan-dra
4
4
  import { baseChatMessageSchema } from './chat-api'
5
5
  import type { AnyChatMessage } from './chat-message'
6
6
  import {
7
+ PlanArtifactSubmissionSchema,
7
8
  PlanEdgeSpecSchema,
8
9
  PlanNodeResultSubmissionSchema,
9
10
  PlanNodeRunStatusSchema,
@@ -67,9 +68,9 @@ export const SubmitExecutionNodeResultArgsSchema = PlanNodeResultSubmissionSchem
67
68
  export const SubmitPlanTurnResultArgsSchema = PlanNodeResultSubmissionSchema
68
69
 
69
70
  export const ExecutionPlanActionSchema = z
70
- .enum(['create', 'create-project', 'replace', 'resume'])
71
+ .enum(['create', 'create-project', 'replace', 'resume', 'update-node'])
71
72
  .describe(
72
- 'create: inline plan (1-2 nodes). create-project: plan in a dedicated project thread (3+ nodes). replace: replace active plan. resume: resume interrupted plan.',
73
+ 'create: inline plan (1-2 nodes). create-project: plan in a dedicated project thread (3+ nodes). replace: replace active plan. resume: resume interrupted plan. update-node: submit result for a specific plan node.',
73
74
  )
74
75
  export type ExecutionPlanAction = z.infer<typeof ExecutionPlanActionSchema>
75
76
 
@@ -117,6 +118,22 @@ export const ExecutionPlanResumeArgsSchema = z
117
118
  .object({ action: z.literal('resume'), runId: runIdSchema.describe('Required for replace and resume.') })
118
119
  .strict()
119
120
 
121
+ const ExecutionPlanNodeUpdateSchema = z
122
+ .object({
123
+ id: z.string().trim().min(1).describe('The node ID to update.'),
124
+ latestNotes: z.string().trim().min(1).max(4000).describe('Summary of what was accomplished.'),
125
+ deliverables: z.array(PlanArtifactSubmissionSchema).optional().describe('Artifacts produced by the node.'),
126
+ })
127
+ .strict()
128
+
129
+ export const ExecutionPlanUpdateNodeArgsSchema = z
130
+ .object({
131
+ action: z.literal('update-node'),
132
+ runId: runIdSchema.describe('The plan run containing the node.'),
133
+ node: ExecutionPlanNodeUpdateSchema,
134
+ })
135
+ .strict()
136
+
120
137
  const ExecutionPlanBaseArgsSchema = z
121
138
  .object({
122
139
  action: ExecutionPlanActionSchema,
@@ -127,8 +144,9 @@ const ExecutionPlanBaseArgsSchema = z
127
144
  projectTitle: projectTitleSchema.optional(),
128
145
  targetThreadId: targetThreadIdSchema.optional(),
129
146
  requireApproval: requireApprovalSchema,
130
- runId: runIdSchema.describe('Required for replace and resume.').optional(),
147
+ runId: runIdSchema.describe('Required for replace, resume, and update-node.').optional(),
131
148
  reason: replaceReasonSchema.describe('Required for replace.').optional(),
149
+ node: ExecutionPlanNodeUpdateSchema.optional().describe('Required for update-node.'),
132
150
  })
133
151
  .strict()
134
152
 
@@ -221,6 +239,43 @@ export const ExecutionPlanArgsSchema = ExecutionPlanBaseArgsSchema.superRefine((
221
239
  }
222
240
  }
223
241
  }
242
+
243
+ if (value.action === 'update-node') {
244
+ if (value.runId === undefined) {
245
+ addMissingExecutionPlanFieldIssue(ctx, 'runId', 'runId is required for update-node.')
246
+ }
247
+ if (value.node === undefined) {
248
+ addMissingExecutionPlanFieldIssue(ctx, 'node', 'node is required for update-node.')
249
+ }
250
+ for (const path of [
251
+ 'title',
252
+ 'objective',
253
+ 'nodes',
254
+ 'edges',
255
+ 'projectTitle',
256
+ 'targetThreadId',
257
+ 'reason',
258
+ ] as const) {
259
+ if (value[path] !== undefined) {
260
+ addUnexpectedExecutionPlanFieldIssue(
261
+ ctx,
262
+ path,
263
+ `${path} is not allowed when action is "update-node". Use only action, runId, and node.`,
264
+ )
265
+ }
266
+ }
267
+ if (value.requireApproval !== undefined) {
268
+ addUnexpectedExecutionPlanFieldIssue(
269
+ ctx,
270
+ 'requireApproval',
271
+ 'requireApproval is not allowed when action is "update-node".',
272
+ )
273
+ }
274
+ }
275
+
276
+ if (value.action !== 'update-node' && value.node !== undefined) {
277
+ addUnexpectedExecutionPlanFieldIssue(ctx, 'node', 'node is only allowed when action is "update-node".')
278
+ }
224
279
  })
225
280
 
226
281
  export type ExecutionPlanArgs =
@@ -228,6 +283,7 @@ export type ExecutionPlanArgs =
228
283
  | z.infer<typeof ExecutionPlanCreateProjectArgsSchema>
229
284
  | z.infer<typeof ExecutionPlanReplaceArgsSchema>
230
285
  | z.infer<typeof ExecutionPlanResumeArgsSchema>
286
+ | z.infer<typeof ExecutionPlanUpdateNodeArgsSchema>
231
287
 
232
288
  export const ExecutionPlanQueryArgsSchema = z
233
289
  .object({
@@ -103,10 +103,20 @@ function stripRawToolPayloadObjects(value: string): string {
103
103
  return result
104
104
  }
105
105
 
106
+ /** Strip bracketed plan/node status labels the LLM sometimes appends to titles (e.g. "Plan Title [blocked]") */
107
+ const BRACKETED_STATUS_PATTERN = /\s*\[(blocked|failed|running|stalled|inactive|paused|cancelled|errored)\]/gi
108
+
109
+ /** Strip raw execution plan run/node IDs the LLM sometimes echoes (e.g. "Run: 019d6382-...") */
110
+ const RAW_RUN_ID_PATTERN = /\bRun:\s*[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}\b/gi
111
+ const RAW_PLAN_RUN_ID_PATTERN = /\bplanRun:[\w⟨⟩-]+/g
112
+
106
113
  export function sanitizeAssistantVisibleText(value: string): string {
107
114
  let next = value
108
115
 
109
116
  next = next.replace(/\[REDACTED\]/gi, '')
117
+ next = next.replace(BRACKETED_STATUS_PATTERN, '')
118
+ next = next.replace(RAW_RUN_ID_PATTERN, '')
119
+ next = next.replace(RAW_PLAN_RUN_ID_PATTERN, '')
110
120
 
111
121
  for (const pattern of INTERNAL_BLOCK_PATTERNS) {
112
122
  next = next.replace(pattern, '')