@lota-sdk/shared 0.4.2 → 0.4.4
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
|
@@ -7,11 +7,13 @@ export const STRUCTURAL_NODE_TYPES = ['switch', 'join', 'deliberation-fork'] as
|
|
|
7
7
|
export const PROJECT_PLAN_ROUTING_PROMPT = `<project-plan-routing>
|
|
8
8
|
- Use executionPlan with action "create" for small inline work inside the current thread.
|
|
9
9
|
- Use executionPlan with action "create-project" when the work needs a dedicated project thread, should stay visible in the sidebar or board, or needs 3 or more meaningful execution nodes.
|
|
10
|
+
- Plans created with action "create-project" usually require human approval before execution starts. Treat them as proposals until approved.
|
|
10
11
|
- Never invent other plan tool names.
|
|
11
12
|
</project-plan-routing>`
|
|
12
13
|
|
|
13
14
|
export const EXECUTION_PLAN_SELF_START_PROMPT = `<execution-plan-self-start>
|
|
14
|
-
- When you create an execution plan with executionPlan and the
|
|
15
|
+
- When you create an execution plan with executionPlan and the plan starts running immediately, begin executing your first assigned node in the same turn. Do not wait for the user to ask.
|
|
16
|
+
- When a newly created plan is pending approval, do not start any work. Tell the user the plan is ready for review and wait for approval.
|
|
15
17
|
- After completing a node, submit the result and check whether the next ready node is also yours. If so, continue working.
|
|
16
18
|
- When the user's message relates to an active plan where you own ready nodes, inspect the plan state and proactively work on your ready nodes.
|
|
17
19
|
- When you own a blocked or failed node, tell the user what is blocked and what resolution is needed.
|
|
@@ -112,7 +112,7 @@ export const PlanSpecStatusSchema = z.enum(['compiled', 'superseded']).meta({ id
|
|
|
112
112
|
export type PlanSpecStatus = z.infer<typeof PlanSpecStatusSchema>
|
|
113
113
|
|
|
114
114
|
export const PlanRunStatusSchema = z
|
|
115
|
-
.enum(['running', 'awaiting-human', 'blocked', 'completed', 'failed', 'aborted'])
|
|
115
|
+
.enum(['pending-approval', 'running', 'awaiting-human', 'blocked', 'completed', 'failed', 'aborted'])
|
|
116
116
|
.meta({ id: 'PlanRunStatusSchema' })
|
|
117
117
|
export type PlanRunStatus = z.infer<typeof PlanRunStatusSchema>
|
|
118
118
|
|
|
@@ -149,6 +149,10 @@ export type PlanApprovalStatus = z.infer<typeof PlanApprovalStatusSchema>
|
|
|
149
149
|
export const PlanEventTypeSchema = z
|
|
150
150
|
.enum([
|
|
151
151
|
'plan-created',
|
|
152
|
+
'plan-pending-approval',
|
|
153
|
+
'plan-approved',
|
|
154
|
+
'plan-rejected',
|
|
155
|
+
'plan-changes-requested',
|
|
152
156
|
'plan-replaced',
|
|
153
157
|
'run-status-changed',
|
|
154
158
|
'ownership-transition',
|
|
@@ -635,7 +639,9 @@ export const PlanRunSchema = z.object({
|
|
|
635
639
|
planSpecId: recordIdSchema,
|
|
636
640
|
organizationId: recordIdSchema,
|
|
637
641
|
threadId: recordIdSchema,
|
|
642
|
+
sourceThreadId: recordIdSchema.optional(),
|
|
638
643
|
leadAgentId: z.string(),
|
|
644
|
+
createdByAgentId: z.string().optional(),
|
|
639
645
|
status: PlanRunStatusSchema,
|
|
640
646
|
currentNodeId: z.string().optional(),
|
|
641
647
|
waitingNodeId: z.string().optional(),
|
|
@@ -897,12 +903,14 @@ export const SerializableExecutionPlanSchema = z.object({
|
|
|
897
903
|
specId: z.string(),
|
|
898
904
|
runId: z.string(),
|
|
899
905
|
threadId: z.string(),
|
|
906
|
+
sourceThreadId: z.string().nullish(),
|
|
900
907
|
organizationId: z.string(),
|
|
901
908
|
title: z.string(),
|
|
902
909
|
objective: z.string(),
|
|
903
910
|
version: z.number().int().positive(),
|
|
904
911
|
status: PlanRunStatusSchema,
|
|
905
912
|
leadAgentId: z.string(),
|
|
913
|
+
createdByAgentId: z.string().nullish(),
|
|
906
914
|
defaultExecutionVisibility: PlanExecutionVisibilitySchema,
|
|
907
915
|
executionMode: ExecutionModeSchema,
|
|
908
916
|
schemaRegistry: PlanSchemaRegistrySchema,
|
|
@@ -35,7 +35,7 @@ export const RecentActivityMetadataSchema = z
|
|
|
35
35
|
userMessageText: z.string().optional(),
|
|
36
36
|
assistantSummary: z.string().optional(),
|
|
37
37
|
messageId: z.string().optional(),
|
|
38
|
-
planStatus: z.enum(['awaiting-human', 'blocked', 'completed', 'failed']).optional(),
|
|
38
|
+
planStatus: z.enum(['pending-approval', 'awaiting-human', 'blocked', 'completed', 'failed']).optional(),
|
|
39
39
|
planTitle: z.string().optional(),
|
|
40
40
|
})
|
|
41
41
|
.partial()
|
package/src/schemas/tools.ts
CHANGED
|
@@ -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
|
+
PlanEdgeSpecSchema,
|
|
7
8
|
PlanNodeResultSubmissionSchema,
|
|
8
9
|
PlanNodeRunStatusSchema,
|
|
9
10
|
PlanNodeTypeSchema,
|
|
@@ -15,6 +16,7 @@ export const CONSULT_SPECIALIST_TOOL_NAME = 'consultSpecialist' as const
|
|
|
15
16
|
export const CONSULT_TEAM_TOOL_NAME = 'consultTeam' as const
|
|
16
17
|
export const EXECUTION_PLAN_TOOL_NAME = 'executionPlan' as const
|
|
17
18
|
export const EXECUTION_PLAN_QUERY_TOOL_NAME = 'executionPlanQuery' as const
|
|
19
|
+
export const PLAN_APPROVAL_TOOL_NAME = 'planApproval' as const
|
|
18
20
|
export const SUBMIT_PLAN_TURN_RESULT_TOOL_NAME = 'submitPlanTurnResult' as const
|
|
19
21
|
export const SUBMIT_EXECUTION_NODE_RESULT_TOOL_NAME = 'submitExecutionNodeResult' as const
|
|
20
22
|
|
|
@@ -86,22 +88,29 @@ const targetThreadIdSchema = z
|
|
|
86
88
|
|
|
87
89
|
const runIdSchema = z.string().trim().min(1)
|
|
88
90
|
const replaceReasonSchema = z.string().trim().min(1).max(1000)
|
|
91
|
+
const requireApprovalSchema = z
|
|
92
|
+
.boolean()
|
|
93
|
+
.optional()
|
|
94
|
+
.describe('When true, the created plan stays pending approval until a human explicitly starts it.')
|
|
89
95
|
|
|
90
96
|
export const ExecutionPlanCreateArgsSchema = AgentPlanDraftSchema.extend({
|
|
91
97
|
action: z.literal('create'),
|
|
92
98
|
targetThreadId: targetThreadIdSchema.optional(),
|
|
99
|
+
requireApproval: requireApprovalSchema,
|
|
93
100
|
}).strict()
|
|
94
101
|
|
|
95
102
|
export const ExecutionPlanCreateProjectArgsSchema = AgentPlanDraftSchema.extend({
|
|
96
103
|
action: z.literal('create-project'),
|
|
97
104
|
projectTitle: projectTitleSchema.optional(),
|
|
98
105
|
targetThreadId: targetThreadIdSchema.optional(),
|
|
106
|
+
requireApproval: requireApprovalSchema,
|
|
99
107
|
}).strict()
|
|
100
108
|
|
|
101
109
|
export const ExecutionPlanReplaceArgsSchema = AgentPlanDraftSchema.extend({
|
|
102
110
|
action: z.literal('replace'),
|
|
103
111
|
runId: runIdSchema.describe('Required for replace and resume.'),
|
|
104
112
|
reason: replaceReasonSchema.describe('Required for replace.'),
|
|
113
|
+
requireApproval: requireApprovalSchema,
|
|
105
114
|
}).strict()
|
|
106
115
|
|
|
107
116
|
export const ExecutionPlanResumeArgsSchema = z
|
|
@@ -117,6 +126,7 @@ const ExecutionPlanBaseArgsSchema = z
|
|
|
117
126
|
edges: z.array(AgentPlanEdgeDraftSchema).optional(),
|
|
118
127
|
projectTitle: projectTitleSchema.optional(),
|
|
119
128
|
targetThreadId: targetThreadIdSchema.optional(),
|
|
129
|
+
requireApproval: requireApprovalSchema,
|
|
120
130
|
runId: runIdSchema.describe('Required for replace and resume.').optional(),
|
|
121
131
|
reason: replaceReasonSchema.describe('Required for replace.').optional(),
|
|
122
132
|
})
|
|
@@ -172,6 +182,13 @@ export const ExecutionPlanArgsSchema = ExecutionPlanBaseArgsSchema.superRefine((
|
|
|
172
182
|
)
|
|
173
183
|
}
|
|
174
184
|
}
|
|
185
|
+
if (value.requireApproval !== undefined) {
|
|
186
|
+
addUnexpectedExecutionPlanFieldIssue(
|
|
187
|
+
ctx,
|
|
188
|
+
'requireApproval',
|
|
189
|
+
'requireApproval is not allowed when action is "resume". Use only action and runId.',
|
|
190
|
+
)
|
|
191
|
+
}
|
|
175
192
|
}
|
|
176
193
|
|
|
177
194
|
if (value.action === 'create') {
|
|
@@ -188,6 +205,13 @@ export const ExecutionPlanArgsSchema = ExecutionPlanBaseArgsSchema.superRefine((
|
|
|
188
205
|
addUnexpectedExecutionPlanFieldIssue(ctx, path, `${path} is not allowed when action is "create-project".`)
|
|
189
206
|
}
|
|
190
207
|
}
|
|
208
|
+
if (value.projectTitle === undefined && value.targetThreadId === undefined) {
|
|
209
|
+
addMissingExecutionPlanFieldIssue(
|
|
210
|
+
ctx,
|
|
211
|
+
'projectTitle',
|
|
212
|
+
'Either projectTitle or targetThreadId is required for create-project.',
|
|
213
|
+
)
|
|
214
|
+
}
|
|
191
215
|
}
|
|
192
216
|
|
|
193
217
|
if (value.action === 'replace') {
|
|
@@ -244,35 +268,86 @@ export const ExecutionPlanNodeSummarySchema = z.object({
|
|
|
244
268
|
type: PlanNodeTypeSchema,
|
|
245
269
|
status: PlanNodeRunStatusSchema,
|
|
246
270
|
ownerRef: z.string(),
|
|
271
|
+
objective: z.string().optional(),
|
|
272
|
+
ownerType: z.string().optional(),
|
|
273
|
+
artifactCount: z.number().int().nonnegative().optional(),
|
|
274
|
+
approvalId: z.string().nullish(),
|
|
275
|
+
approvalStatus: z.string().nullish(),
|
|
276
|
+
blockedReason: z.string().nullish(),
|
|
277
|
+
latestNotes: z.string().nullish(),
|
|
278
|
+
startedAt: z.iso.datetime().nullish(),
|
|
279
|
+
completedAt: z.iso.datetime().nullish(),
|
|
280
|
+
readyAt: z.iso.datetime().nullish(),
|
|
281
|
+
deliverableNames: z.array(z.string()).optional(),
|
|
282
|
+
upstreamNodeIds: z.array(z.string()).optional(),
|
|
283
|
+
downstreamNodeIds: z.array(z.string()).optional(),
|
|
247
284
|
})
|
|
248
285
|
|
|
286
|
+
export const ExecutionPlanToolPlanSummarySchema = z
|
|
287
|
+
.object({
|
|
288
|
+
runId: z.string(),
|
|
289
|
+
threadId: z.string().optional(),
|
|
290
|
+
sourceThreadId: z.string().optional(),
|
|
291
|
+
title: z.string(),
|
|
292
|
+
objective: z.string(),
|
|
293
|
+
status: PlanRunStatusSchema,
|
|
294
|
+
leadAgentId: z.string().optional(),
|
|
295
|
+
createdByAgentId: z.string().optional(),
|
|
296
|
+
progress: ExecutionPlanProgressSchema,
|
|
297
|
+
nodes: z.array(ExecutionPlanNodeSummarySchema),
|
|
298
|
+
edges: z.array(PlanEdgeSpecSchema).optional(),
|
|
299
|
+
activeNodeIds: z.array(z.string()),
|
|
300
|
+
readyNodeIds: z.array(z.string()),
|
|
301
|
+
})
|
|
302
|
+
.strict()
|
|
303
|
+
|
|
249
304
|
export const ExecutionPlanToolResultDataSchema = z
|
|
250
305
|
.object({
|
|
251
306
|
action: ExecutionPlanToolActionSchema,
|
|
252
307
|
message: z.string().optional(),
|
|
253
308
|
hasPlan: z.boolean(),
|
|
254
309
|
status: PlanRunStatusSchema.nullish(),
|
|
255
|
-
plan:
|
|
256
|
-
.object({
|
|
257
|
-
runId: z.string(),
|
|
258
|
-
title: z.string(),
|
|
259
|
-
objective: z.string(),
|
|
260
|
-
status: PlanRunStatusSchema,
|
|
261
|
-
progress: ExecutionPlanProgressSchema,
|
|
262
|
-
nodes: z.array(ExecutionPlanNodeSummarySchema),
|
|
263
|
-
activeNodeIds: z.array(z.string()),
|
|
264
|
-
readyNodeIds: z.array(z.string()),
|
|
265
|
-
})
|
|
266
|
-
.nullish(),
|
|
310
|
+
plan: ExecutionPlanToolPlanSummarySchema.nullish(),
|
|
267
311
|
})
|
|
268
312
|
.strict()
|
|
269
313
|
|
|
270
314
|
export const CreateProjectWithPlanResultDataSchema = ExecutionPlanToolResultDataSchema.extend({
|
|
315
|
+
runId: z.string().trim().min(1),
|
|
271
316
|
threadId: z.string().trim().min(1),
|
|
272
317
|
threadTitle: z.string().trim().min(1),
|
|
273
318
|
createdThread: z.boolean(),
|
|
274
319
|
}).strict()
|
|
275
320
|
|
|
321
|
+
export const PlanApprovalToolActionSchema = z.enum(['approved', 'rejected', 'changes-requested'])
|
|
322
|
+
export const PlanApprovalActionSchema = z.enum(['approve', 'reject', 'modify'])
|
|
323
|
+
|
|
324
|
+
export const PlanApprovalArgsSchema = z
|
|
325
|
+
.object({
|
|
326
|
+
action: PlanApprovalActionSchema,
|
|
327
|
+
runId: z.string().trim().min(1),
|
|
328
|
+
reason: z.string().trim().min(1).max(2000).optional(),
|
|
329
|
+
})
|
|
330
|
+
.superRefine((value, ctx) => {
|
|
331
|
+
if (value.action !== 'approve' && !value.reason) {
|
|
332
|
+
ctx.addIssue({
|
|
333
|
+
code: z.ZodIssueCode.custom,
|
|
334
|
+
path: ['reason'],
|
|
335
|
+
message: 'reason is required when action is reject or modify.',
|
|
336
|
+
})
|
|
337
|
+
}
|
|
338
|
+
})
|
|
339
|
+
.strict()
|
|
340
|
+
|
|
341
|
+
export const PlanApprovalToolResultDataSchema = z
|
|
342
|
+
.object({
|
|
343
|
+
action: PlanApprovalToolActionSchema,
|
|
344
|
+
message: z.string(),
|
|
345
|
+
hasPlan: z.boolean(),
|
|
346
|
+
status: PlanRunStatusSchema.nullish(),
|
|
347
|
+
plan: ExecutionPlanToolPlanSummarySchema.nullish(),
|
|
348
|
+
})
|
|
349
|
+
.strict()
|
|
350
|
+
|
|
276
351
|
export const ConsultTeamResultDataSchema = z.object({ responses: z.array(ConsultTeamResponseSchema) }).strict()
|
|
277
352
|
|
|
278
353
|
export type UserQuestionItem = z.infer<typeof UserQuestionItemSchema>
|
|
@@ -290,8 +365,13 @@ export type ListExecutionPlansSummary = z.infer<typeof ListExecutionPlansSummary
|
|
|
290
365
|
export type ListExecutionPlansToolResultData = z.infer<typeof ListExecutionPlansToolResultDataSchema>
|
|
291
366
|
export type ExecutionPlanProgress = z.infer<typeof ExecutionPlanProgressSchema>
|
|
292
367
|
export type ExecutionPlanNodeSummary = z.infer<typeof ExecutionPlanNodeSummarySchema>
|
|
368
|
+
export type ExecutionPlanToolPlanSummary = z.infer<typeof ExecutionPlanToolPlanSummarySchema>
|
|
293
369
|
export type ExecutionPlanToolResultData = z.infer<typeof ExecutionPlanToolResultDataSchema>
|
|
294
370
|
export type CreateProjectWithPlanResultData = z.infer<typeof CreateProjectWithPlanResultDataSchema>
|
|
371
|
+
export type PlanApprovalAction = z.infer<typeof PlanApprovalActionSchema>
|
|
372
|
+
export type PlanApprovalArgs = z.infer<typeof PlanApprovalArgsSchema>
|
|
373
|
+
export type PlanApprovalToolAction = z.infer<typeof PlanApprovalToolActionSchema>
|
|
374
|
+
export type PlanApprovalToolResultData = z.infer<typeof PlanApprovalToolResultDataSchema>
|
|
295
375
|
export type CoreChatTools = {
|
|
296
376
|
userQuestions: { input: UserQuestionsArgs; output: unknown }
|
|
297
377
|
consultSpecialist: { input: ConsultSpecialistArgs; output: ConsultSpecialistResultData }
|
|
@@ -301,5 +381,6 @@ export type CoreChatTools = {
|
|
|
301
381
|
input: ExecutionPlanQueryArgs
|
|
302
382
|
output: ExecutionPlanToolResultData | ListExecutionPlansToolResultData
|
|
303
383
|
}
|
|
384
|
+
planApproval: { input: PlanApprovalArgs; output: PlanApprovalToolResultData }
|
|
304
385
|
submitPlanTurnResult: { input: SubmitPlanTurnResultArgs; output: ExecutionPlanToolResultData }
|
|
305
386
|
}
|