@lota-sdk/shared 0.1.23 → 0.1.25
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 +1 -1
- package/src/constants/execution-plan.ts +19 -0
- package/src/constants/model.ts +13 -25
- package/src/index.ts +3 -0
- package/src/schemas/agent-plan-draft.ts +232 -0
- package/src/schemas/execution-plan.ts +21 -53
- package/src/schemas/plan-board.ts +129 -0
- package/src/schemas/tools.ts +36 -15
- package/src/schemas/workstream.ts +24 -19
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const SILENT_EXECUTION_VISIBILITY = 'silent' as const
|
|
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
|
+
|
|
7
|
+
export const PROJECT_PLAN_ROUTING_PROMPT = `<project-plan-routing>
|
|
8
|
+
- Use createExecutionPlan for small inline work inside the current workstream.
|
|
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.
|
|
10
|
+
- If createExecutionPlan rejects a larger draft, immediately retry with createProjectWithPlan instead of forcing the plan inline.
|
|
11
|
+
</project-plan-routing>`
|
|
12
|
+
|
|
13
|
+
export const EXECUTION_PLAN_SELF_START_PROMPT = `<execution-plan-self-start>
|
|
14
|
+
- When you create an execution plan with createExecutionPlan or createProjectWithPlan and the first node is assigned to you, begin executing that node immediately in the same turn. Do not wait for the user to ask.
|
|
15
|
+
- After completing a node, submit the result and check whether the next ready node is also yours. If so, continue working.
|
|
16
|
+
- 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
|
+
- When you own a blocked or failed node, tell the user what is blocked and what resolution is needed.
|
|
18
|
+
- Briefly acknowledge what you are doing before you start work on a plan node.
|
|
19
|
+
</execution-plan-self-start>`
|
package/src/constants/model.ts
CHANGED
|
@@ -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
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export const OPENROUTER_XHIGH_REASONING_PROVIDER_OPTIONS =
|
|
21
|
-
|
|
22
|
-
|
|
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')
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from './constants/attachments'
|
|
2
|
+
export * from './constants/execution-plan'
|
|
2
3
|
export * from './constants/workstream'
|
|
3
4
|
export * from './runtime/agent-types'
|
|
4
5
|
export * from './runtime/chat-message-metadata'
|
|
5
6
|
export * from './runtime/execution-plan-result'
|
|
7
|
+
export * from './schemas/agent-plan-draft'
|
|
6
8
|
export * from './schemas/chat-api'
|
|
7
9
|
export * from './schemas/chat-message'
|
|
8
10
|
export * from './schemas/common'
|
|
@@ -14,6 +16,7 @@ export * from './schemas/execution-plan'
|
|
|
14
16
|
export * from './schemas/graph-designer'
|
|
15
17
|
export * from './schemas/organization'
|
|
16
18
|
export * from './schemas/organization-api'
|
|
19
|
+
export * from './schemas/plan-board'
|
|
17
20
|
export * from './schemas/playbook'
|
|
18
21
|
export * from './schemas/plugin-coordination'
|
|
19
22
|
export * from './schemas/queue-job'
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import { SILENT_EXECUTION_VISIBILITY, STRUCTURAL_NODE_TYPES } from '../constants/execution-plan'
|
|
4
|
+
import type { PlanArtifactSpec, PlanCompletionCheck, PlanDraft, PlanNodeOwner, PlanNodeType } from './execution-plan'
|
|
5
|
+
import {
|
|
6
|
+
ExecutionModeSchema,
|
|
7
|
+
PlanArtifactSpecSchema,
|
|
8
|
+
PlanCompletionCheckSchema,
|
|
9
|
+
PlanCompletionCheckTypeSchema,
|
|
10
|
+
PlanContextPolicySchema,
|
|
11
|
+
PlanEdgeSpecSchema,
|
|
12
|
+
PlanExecutionVisibilitySchema,
|
|
13
|
+
PlanNodeOwnerSchema,
|
|
14
|
+
PlanNodeTypeSchema,
|
|
15
|
+
PlanRetryPolicySchema,
|
|
16
|
+
PlanToolPolicySchema,
|
|
17
|
+
} from './execution-plan'
|
|
18
|
+
|
|
19
|
+
const STRUCTURAL_NODE_TYPE_SET = new Set<PlanNodeType>(STRUCTURAL_NODE_TYPES)
|
|
20
|
+
|
|
21
|
+
const agentPlanOwnerStringSchema = z.string().trim().min(1).max(200)
|
|
22
|
+
|
|
23
|
+
const AgentPlanDeliverableDraftSchema = z.union([z.string().trim().min(1).max(1000), PlanArtifactSpecSchema])
|
|
24
|
+
|
|
25
|
+
const SimplifiedCompletionCheckSchema = z.object({
|
|
26
|
+
type: PlanCompletionCheckTypeSchema,
|
|
27
|
+
description: z.string().trim().min(1).max(1000),
|
|
28
|
+
blocking: z.boolean().optional(),
|
|
29
|
+
config: z.record(z.string(), z.unknown()).optional(),
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const AgentPlanCompletionCheckDraftSchema = z.union([PlanCompletionCheckSchema, SimplifiedCompletionCheckSchema])
|
|
33
|
+
|
|
34
|
+
export const AgentPlanNodeDraftSchema = z.object({
|
|
35
|
+
id: z.string().trim().min(1).max(200),
|
|
36
|
+
type: PlanNodeTypeSchema,
|
|
37
|
+
label: z.string().trim().min(1).max(300),
|
|
38
|
+
owner: z.union([PlanNodeOwnerSchema, agentPlanOwnerStringSchema]),
|
|
39
|
+
objective: z.string().trim().min(1).max(2000),
|
|
40
|
+
instructions: z.string().trim().min(1).max(4000),
|
|
41
|
+
successCriteria: z.array(z.string().trim().min(1).max(1000)).min(1),
|
|
42
|
+
deliverables: z.array(AgentPlanDeliverableDraftSchema).min(1).optional(),
|
|
43
|
+
completionChecks: z.array(AgentPlanCompletionCheckDraftSchema).min(1).optional(),
|
|
44
|
+
})
|
|
45
|
+
export type AgentPlanNodeDraft = z.infer<typeof AgentPlanNodeDraftSchema>
|
|
46
|
+
|
|
47
|
+
export const AgentPlanEdgeDraftSchema = z.object({
|
|
48
|
+
id: z.string().trim().min(1).max(200),
|
|
49
|
+
source: z.string().trim().min(1).max(200),
|
|
50
|
+
target: z.string().trim().min(1).max(200),
|
|
51
|
+
when: z.string().trim().min(1).max(500).optional(),
|
|
52
|
+
})
|
|
53
|
+
export type AgentPlanEdgeDraft = z.infer<typeof AgentPlanEdgeDraftSchema>
|
|
54
|
+
|
|
55
|
+
export const AgentPlanDraftSchema = z.object({
|
|
56
|
+
title: z.string().trim().min(1).max(200),
|
|
57
|
+
objective: z.string().trim().min(1).max(2000),
|
|
58
|
+
nodes: z.array(AgentPlanNodeDraftSchema).min(1).max(32),
|
|
59
|
+
edges: z.array(AgentPlanEdgeDraftSchema).default([]),
|
|
60
|
+
entryNodeIds: z.array(z.string().trim().min(1).max(200)).min(1).optional(),
|
|
61
|
+
executionMode: ExecutionModeSchema.optional(),
|
|
62
|
+
})
|
|
63
|
+
export type AgentPlanDraft = z.infer<typeof AgentPlanDraftSchema>
|
|
64
|
+
|
|
65
|
+
export function normalizeOwner(owner: string | PlanNodeOwner): PlanNodeOwner {
|
|
66
|
+
if (typeof owner !== 'string') {
|
|
67
|
+
return owner
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const normalized = owner.trim()
|
|
71
|
+
if (normalized.toLowerCase() === 'user') {
|
|
72
|
+
return { executorType: 'user', ref: 'user' }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return { executorType: 'agent', ref: normalized }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function toDeliverableName(value: string, fallback: string): string {
|
|
79
|
+
const normalized = value
|
|
80
|
+
.trim()
|
|
81
|
+
.toLowerCase()
|
|
82
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
83
|
+
.replace(/^-+|-+$/g, '')
|
|
84
|
+
|
|
85
|
+
return normalized.length > 0 ? normalized.slice(0, 200) : fallback
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function isStructuralNodeType(type: PlanNodeType): boolean {
|
|
89
|
+
return STRUCTURAL_NODE_TYPE_SET.has(type)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function buildDefaultDeliverables(node: AgentPlanNodeDraft): PlanArtifactSpec[] {
|
|
93
|
+
if (isStructuralNodeType(node.type)) {
|
|
94
|
+
return []
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (node.type === 'human-approval') {
|
|
98
|
+
return [
|
|
99
|
+
{ name: `${node.id}-approval`, kind: 'json', required: false, description: `Approval record from ${node.label}` },
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (node.type === 'human-input' || node.type === 'human-review-edit' || node.type === 'human-decision') {
|
|
104
|
+
return [{ name: `${node.id}-response`, kind: 'json', required: false, description: `Response from ${node.label}` }]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return [{ name: `${node.id}-output`, kind: 'markdown', required: false, description: `Output from ${node.label}` }]
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function expandDeliverables(node: AgentPlanNodeDraft): PlanArtifactSpec[] {
|
|
111
|
+
const deliverables = node.deliverables
|
|
112
|
+
if (!deliverables || deliverables.length === 0) {
|
|
113
|
+
return buildDefaultDeliverables(node)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return deliverables.map((deliverable, index) => {
|
|
117
|
+
if (typeof deliverable !== 'string') {
|
|
118
|
+
return deliverable
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const description = deliverable.trim()
|
|
122
|
+
const fallbackName = `${node.id}-output-${index + 1}`
|
|
123
|
+
return { name: toDeliverableName(description, fallbackName), kind: 'markdown', required: false, description }
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function buildDefaultCompletionChecks(
|
|
128
|
+
node: AgentPlanNodeDraft,
|
|
129
|
+
deliverables: PlanArtifactSpec[],
|
|
130
|
+
): PlanCompletionCheck[] {
|
|
131
|
+
if (isStructuralNodeType(node.type)) {
|
|
132
|
+
return []
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (node.type === 'human-approval') {
|
|
136
|
+
return [
|
|
137
|
+
{
|
|
138
|
+
type: 'human-approval',
|
|
139
|
+
config: { approvedField: 'approved' },
|
|
140
|
+
blocking: true,
|
|
141
|
+
description: 'Approval recorded',
|
|
142
|
+
},
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (node.type === 'human-input' || node.type === 'human-review-edit') {
|
|
147
|
+
return [
|
|
148
|
+
{
|
|
149
|
+
type: 'assertion',
|
|
150
|
+
config: { truthyPaths: ['responseText'] },
|
|
151
|
+
blocking: true,
|
|
152
|
+
description: 'Response captured',
|
|
153
|
+
},
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (node.type === 'human-decision') {
|
|
158
|
+
return [
|
|
159
|
+
{ type: 'assertion', config: { truthyPaths: ['approved'] }, blocking: true, description: 'Decision captured' },
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const primaryDeliverable = deliverables.at(0)
|
|
164
|
+
return [
|
|
165
|
+
{
|
|
166
|
+
type: 'tool-check',
|
|
167
|
+
config: primaryDeliverable ? { artifact: primaryDeliverable.name, mode: 'artifact-present' } : {},
|
|
168
|
+
blocking: true,
|
|
169
|
+
description: primaryDeliverable ? `Artifact "${primaryDeliverable.name}" exists` : 'Required output is present',
|
|
170
|
+
},
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function expandCompletionChecks(node: AgentPlanNodeDraft, deliverables: PlanArtifactSpec[]): PlanCompletionCheck[] {
|
|
175
|
+
const completionChecks = node.completionChecks
|
|
176
|
+
if (!completionChecks || completionChecks.length === 0) {
|
|
177
|
+
return buildDefaultCompletionChecks(node, deliverables)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const primaryDeliverable = deliverables.at(0)
|
|
181
|
+
return completionChecks.map((check) => {
|
|
182
|
+
const blocking = check.blocking ?? true
|
|
183
|
+
const config =
|
|
184
|
+
check.config ??
|
|
185
|
+
(check.type === 'human-approval'
|
|
186
|
+
? { approvedField: 'approved' }
|
|
187
|
+
: check.type === 'tool-check' && primaryDeliverable
|
|
188
|
+
? { artifact: primaryDeliverable.name, mode: 'artifact-present' }
|
|
189
|
+
: {})
|
|
190
|
+
|
|
191
|
+
return { type: check.type, description: check.description, blocking, config }
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function expandAgentPlanDraft(draft: AgentPlanDraft): PlanDraft {
|
|
196
|
+
const expandedNodes = draft.nodes.map((node) => {
|
|
197
|
+
const deliverables = expandDeliverables(node)
|
|
198
|
+
const completionChecks = expandCompletionChecks(node, deliverables)
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
id: node.id,
|
|
202
|
+
type: node.type,
|
|
203
|
+
label: node.label,
|
|
204
|
+
owner: normalizeOwner(node.owner),
|
|
205
|
+
objective: node.objective,
|
|
206
|
+
instructions: node.instructions,
|
|
207
|
+
deliverables,
|
|
208
|
+
successCriteria: [...node.successCriteria],
|
|
209
|
+
completionChecks,
|
|
210
|
+
retryPolicy: PlanRetryPolicySchema.parse({ maxAttempts: 0, retryOn: [] }),
|
|
211
|
+
failurePolicy: [],
|
|
212
|
+
toolPolicy: PlanToolPolicySchema.parse({ allow: [], deny: [] }),
|
|
213
|
+
contextPolicy: PlanContextPolicySchema.parse({
|
|
214
|
+
retrievalScopes: [],
|
|
215
|
+
attachmentPolicy: 'referenced-only',
|
|
216
|
+
webPolicy: 'allowed',
|
|
217
|
+
}),
|
|
218
|
+
executionVisibility: PlanExecutionVisibilitySchema.parse('auto'),
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
title: draft.title,
|
|
224
|
+
objective: draft.objective,
|
|
225
|
+
schemas: {},
|
|
226
|
+
defaultExecutionVisibility: SILENT_EXECUTION_VISIBILITY,
|
|
227
|
+
nodes: expandedNodes,
|
|
228
|
+
edges: draft.edges.map((edge) => PlanEdgeSpecSchema.parse({ ...edge, map: {} })),
|
|
229
|
+
entryNodeIds: draft.entryNodeIds ? [...draft.entryNodeIds] : undefined,
|
|
230
|
+
executionMode: draft.executionMode,
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -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'
|
|
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
|
-
|
|
324
|
-
|
|
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 =
|
|
363
|
-
export type PlanCycleStatus =
|
|
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>
|
|
@@ -549,7 +547,7 @@ export const PlanNodeSpecSchema = z
|
|
|
549
547
|
outputSchemaRef: z.string().trim().min(1).max(200).optional(),
|
|
550
548
|
deliverables: z.array(PlanArtifactSpecSchema).default([]),
|
|
551
549
|
successCriteria: z.array(z.string().trim().min(1).max(1000)).default([]),
|
|
552
|
-
completionChecks: z.array(PlanCompletionCheckSchema).
|
|
550
|
+
completionChecks: z.array(PlanCompletionCheckSchema).min(1),
|
|
553
551
|
retryPolicy: PlanRetryPolicySchema.default({ maxAttempts: 0, retryOn: [] }),
|
|
554
552
|
failurePolicy: z.array(PlanFailureRuleSchema).default([]),
|
|
555
553
|
timeoutMs: z.number().int().positive().optional(),
|
|
@@ -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 =
|
|
625
|
+
export const PlanNodeSpecRecordSchema = PlanNodeSpecSchema.omit({ id: true }).extend({
|
|
628
626
|
id: recordIdSchema,
|
|
629
627
|
planSpecId: recordIdSchema,
|
|
630
|
-
nodeId:
|
|
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 =
|
|
803
|
-
id:
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
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(),
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const PlanNodeCardSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
nodeId: z.string().trim().min(1),
|
|
6
|
+
label: z.string().trim().min(1),
|
|
7
|
+
objective: z.string(),
|
|
8
|
+
status: z.string().trim().min(1),
|
|
9
|
+
ownerType: z.string().trim().min(1),
|
|
10
|
+
ownerRef: z.string().trim().min(1),
|
|
11
|
+
planRunId: z.string().trim().min(1),
|
|
12
|
+
planTitle: z.string().trim().min(1),
|
|
13
|
+
workstreamId: z.string().trim().min(1),
|
|
14
|
+
workstreamTitle: z.string().trim().min(1),
|
|
15
|
+
nodeType: z.string().trim().min(1),
|
|
16
|
+
artifactCount: z.number().int().nonnegative(),
|
|
17
|
+
hasApproval: z.boolean(),
|
|
18
|
+
approvalId: z.string().trim().min(1).nullable(),
|
|
19
|
+
approvalStatus: z.string().trim().min(1).nullable(),
|
|
20
|
+
blockedReason: z.string().nullable(),
|
|
21
|
+
latestNotes: z.string().nullable(),
|
|
22
|
+
startedAt: z.iso.datetime().nullable(),
|
|
23
|
+
completedAt: z.iso.datetime().nullable(),
|
|
24
|
+
readyAt: z.iso.datetime().nullable(),
|
|
25
|
+
})
|
|
26
|
+
.strict()
|
|
27
|
+
export type PlanNodeCard = z.infer<typeof PlanNodeCardSchema>
|
|
28
|
+
|
|
29
|
+
export const PlanBoardColumnSchema = z
|
|
30
|
+
.object({ status: z.string().trim().min(1), label: z.string().trim().min(1), nodes: z.array(PlanNodeCardSchema) })
|
|
31
|
+
.strict()
|
|
32
|
+
export type PlanBoardColumn = z.infer<typeof PlanBoardColumnSchema>
|
|
33
|
+
|
|
34
|
+
export const PlanBoardResponseSchema = z
|
|
35
|
+
.object({
|
|
36
|
+
columns: z.array(PlanBoardColumnSchema),
|
|
37
|
+
summary: z
|
|
38
|
+
.object({
|
|
39
|
+
totalNodes: z.number().int().nonnegative(),
|
|
40
|
+
completedNodes: z.number().int().nonnegative(),
|
|
41
|
+
activePlanCount: z.number().int().nonnegative(),
|
|
42
|
+
pendingApprovalCount: z.number().int().nonnegative(),
|
|
43
|
+
})
|
|
44
|
+
.strict(),
|
|
45
|
+
})
|
|
46
|
+
.strict()
|
|
47
|
+
export type PlanBoardResponse = z.infer<typeof PlanBoardResponseSchema>
|
|
48
|
+
|
|
49
|
+
export const PlanViewNodeSchema = PlanNodeCardSchema.extend({
|
|
50
|
+
deliverableNames: z.array(z.string()),
|
|
51
|
+
upstreamNodeIds: z.array(z.string()),
|
|
52
|
+
downstreamNodeIds: z.array(z.string()),
|
|
53
|
+
}).strict()
|
|
54
|
+
export type PlanViewNode = z.infer<typeof PlanViewNodeSchema>
|
|
55
|
+
|
|
56
|
+
export const PlanViewResponseSchema = z
|
|
57
|
+
.object({
|
|
58
|
+
planRunId: z.string().trim().min(1),
|
|
59
|
+
title: z.string().trim().min(1),
|
|
60
|
+
objective: z.string().trim().min(1),
|
|
61
|
+
status: z.string().trim().min(1),
|
|
62
|
+
leadAgentId: z.string().trim().min(1),
|
|
63
|
+
progress: z.object({ completed: z.number().int().nonnegative(), total: z.number().int().nonnegative() }).strict(),
|
|
64
|
+
nodes: z.array(PlanViewNodeSchema),
|
|
65
|
+
edges: z.array(z.object({ from: z.string().trim().min(1), to: z.string().trim().min(1) }).strict()),
|
|
66
|
+
})
|
|
67
|
+
.strict()
|
|
68
|
+
export type PlanViewResponse = z.infer<typeof PlanViewResponseSchema>
|
|
69
|
+
|
|
70
|
+
export const MyTasksResponseSchema = z
|
|
71
|
+
.object({ tasks: z.array(PlanNodeCardSchema), pendingApprovalCount: z.number().int().nonnegative() })
|
|
72
|
+
.strict()
|
|
73
|
+
export type MyTasksResponse = z.infer<typeof MyTasksResponseSchema>
|
|
74
|
+
|
|
75
|
+
export const AgentProjectEntrySchema = z
|
|
76
|
+
.object({
|
|
77
|
+
workstreamId: z.string().trim().min(1),
|
|
78
|
+
workstreamTitle: z.string().trim().min(1),
|
|
79
|
+
planRunId: z.string().trim().min(1),
|
|
80
|
+
planTitle: z.string().trim().min(1),
|
|
81
|
+
status: z.string().trim().min(1),
|
|
82
|
+
})
|
|
83
|
+
.strict()
|
|
84
|
+
export type AgentProjectEntry = z.infer<typeof AgentProjectEntrySchema>
|
|
85
|
+
|
|
86
|
+
export const AgentActivityCountsSchema = z
|
|
87
|
+
.object({
|
|
88
|
+
running: z.number().int().nonnegative(),
|
|
89
|
+
ready: z.number().int().nonnegative(),
|
|
90
|
+
pending: z.number().int().nonnegative(),
|
|
91
|
+
awaitingHuman: z.number().int().nonnegative(),
|
|
92
|
+
blocked: z.number().int().nonnegative(),
|
|
93
|
+
completed: z.number().int().nonnegative(),
|
|
94
|
+
failed: z.number().int().nonnegative(),
|
|
95
|
+
})
|
|
96
|
+
.strict()
|
|
97
|
+
export type AgentActivityCounts = z.infer<typeof AgentActivityCountsSchema>
|
|
98
|
+
|
|
99
|
+
export const UserActivitySummarySchema = z
|
|
100
|
+
.object({
|
|
101
|
+
taskCount: z.number().int().nonnegative(),
|
|
102
|
+
pendingApprovalCount: z.number().int().nonnegative(),
|
|
103
|
+
awaitingHumanCount: z.number().int().nonnegative(),
|
|
104
|
+
lastActiveAt: z.iso.datetime().nullable(),
|
|
105
|
+
})
|
|
106
|
+
.strict()
|
|
107
|
+
export type UserActivitySummary = z.infer<typeof UserActivitySummarySchema>
|
|
108
|
+
|
|
109
|
+
export const AgentActivityEntrySchema = z
|
|
110
|
+
.object({
|
|
111
|
+
agentId: z.string().trim().min(1),
|
|
112
|
+
counts: AgentActivityCountsSchema,
|
|
113
|
+
tasks: z.array(PlanNodeCardSchema),
|
|
114
|
+
projects: z.array(AgentProjectEntrySchema),
|
|
115
|
+
isLeadingActivePlan: z.boolean(),
|
|
116
|
+
isRunning: z.boolean(),
|
|
117
|
+
lastActiveAt: z.iso.datetime().nullable(),
|
|
118
|
+
})
|
|
119
|
+
.strict()
|
|
120
|
+
export type AgentActivityEntry = z.infer<typeof AgentActivityEntrySchema>
|
|
121
|
+
|
|
122
|
+
export const AgentActivityResponseSchema = z
|
|
123
|
+
.object({
|
|
124
|
+
agents: z.array(AgentActivityEntrySchema),
|
|
125
|
+
userActivity: UserActivitySummarySchema,
|
|
126
|
+
totalActivePlans: z.number().int().nonnegative(),
|
|
127
|
+
})
|
|
128
|
+
.strict()
|
|
129
|
+
export type AgentActivityResponse = z.infer<typeof AgentActivityResponseSchema>
|
package/src/schemas/tools.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
+
import { AgentPlanDraftSchema } from './agent-plan-draft'
|
|
3
4
|
import { baseChatMessageSchema } from './chat-api'
|
|
4
5
|
import type { AnyChatMessage } from './chat-message'
|
|
5
|
-
import {
|
|
6
|
-
PlanDraftSchema,
|
|
7
|
-
PlanNodeResultSubmissionSchema,
|
|
8
|
-
PlanRunStatusSchema,
|
|
9
|
-
SerializableExecutionPlanSchema,
|
|
10
|
-
} from './execution-plan'
|
|
6
|
+
import { PlanNodeResultSubmissionSchema, PlanRunStatusSchema, SerializableExecutionPlanSchema } from './execution-plan'
|
|
11
7
|
|
|
12
8
|
export const USER_QUESTIONS_TOOL_NAME = 'userQuestions' as const
|
|
13
9
|
export const CONSULT_SPECIALIST_TOOL_NAME = 'consultSpecialist' as const
|
|
14
10
|
export const CONSULT_TEAM_TOOL_NAME = 'consultTeam' as const
|
|
15
11
|
export const CREATE_EXECUTION_PLAN_TOOL_NAME = 'createExecutionPlan' as const
|
|
12
|
+
export const CREATE_PROJECT_WITH_PLAN_TOOL_NAME = 'createProjectWithPlan' as const
|
|
16
13
|
export const REPLACE_EXECUTION_PLAN_TOOL_NAME = 'replaceExecutionPlan' as const
|
|
17
14
|
export const SUBMIT_EXECUTION_NODE_RESULT_TOOL_NAME = 'submitExecutionNodeResult' as const
|
|
18
15
|
export const SUBMIT_PLAN_TURN_RESULT_TOOL_NAME = 'submitPlanTurnResult' as const
|
|
@@ -60,11 +57,26 @@ const ExecutionPlanToolActionSchema = z.enum([
|
|
|
60
57
|
'none',
|
|
61
58
|
])
|
|
62
59
|
|
|
63
|
-
export const CreateExecutionPlanArgsSchema =
|
|
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
|
+
}).strict()
|
|
64
68
|
|
|
65
|
-
export const
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
export const CreateProjectWithPlanArgsSchema = AgentPlanDraftSchema.extend({
|
|
70
|
+
projectTitle: z.string().trim().min(1).max(200).optional(),
|
|
71
|
+
targetWorkstreamId: z.string().trim().min(1).optional(),
|
|
72
|
+
}).refine((value) => Boolean(value.projectTitle) !== Boolean(value.targetWorkstreamId), {
|
|
73
|
+
message: 'Provide exactly one of projectTitle or targetWorkstreamId.',
|
|
74
|
+
path: ['projectTitle'],
|
|
75
|
+
})
|
|
76
|
+
|
|
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.'),
|
|
68
80
|
}).strict()
|
|
69
81
|
|
|
70
82
|
export const SubmitExecutionNodeResultArgsSchema = z
|
|
@@ -78,11 +90,11 @@ export const ListExecutionPlansArgsSchema = z.object({}).strict()
|
|
|
78
90
|
export const GetActiveExecutionPlanArgsSchema = z
|
|
79
91
|
.object({
|
|
80
92
|
runId: z.string().trim().min(1).optional(),
|
|
81
|
-
includeEvents: z.boolean().default(true),
|
|
82
|
-
includeArtifacts: z.boolean().default(true),
|
|
83
|
-
includeApprovals: z.boolean().default(true),
|
|
84
|
-
includeCheckpoints: z.boolean().default(false),
|
|
85
|
-
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'),
|
|
86
98
|
})
|
|
87
99
|
.strict()
|
|
88
100
|
|
|
@@ -121,6 +133,12 @@ export const ExecutionPlanToolResultDataSchema = z
|
|
|
121
133
|
})
|
|
122
134
|
.strict()
|
|
123
135
|
|
|
136
|
+
export const CreateProjectWithPlanResultDataSchema = ExecutionPlanToolResultDataSchema.extend({
|
|
137
|
+
workstreamId: z.string().trim().min(1),
|
|
138
|
+
workstreamTitle: z.string().trim().min(1),
|
|
139
|
+
createdWorkstream: z.boolean(),
|
|
140
|
+
}).strict()
|
|
141
|
+
|
|
124
142
|
export const ConsultTeamResultDataSchema = z.object({ responses: z.array(ConsultTeamResponseSchema) }).strict()
|
|
125
143
|
|
|
126
144
|
export type UserQuestionItem = z.infer<typeof UserQuestionItemSchema>
|
|
@@ -133,6 +151,7 @@ export type ConsultTeamResponseData = Omit<z.infer<typeof ConsultTeamResponseSch
|
|
|
133
151
|
}
|
|
134
152
|
export type ConsultTeamResultData = { responses: ConsultTeamResponseData[] }
|
|
135
153
|
export type CreateExecutionPlanArgs = z.infer<typeof CreateExecutionPlanArgsSchema>
|
|
154
|
+
export type CreateProjectWithPlanArgs = z.infer<typeof CreateProjectWithPlanArgsSchema>
|
|
136
155
|
export type ReplaceExecutionPlanArgs = z.infer<typeof ReplaceExecutionPlanArgsSchema>
|
|
137
156
|
export type SubmitExecutionNodeResultArgs = z.infer<typeof SubmitExecutionNodeResultArgsSchema>
|
|
138
157
|
export type SubmitPlanTurnResultArgs = z.infer<typeof SubmitPlanTurnResultArgsSchema>
|
|
@@ -142,11 +161,13 @@ export type ListExecutionPlansToolResultData = z.infer<typeof ListExecutionPlans
|
|
|
142
161
|
export type GetActiveExecutionPlanArgs = z.infer<typeof GetActiveExecutionPlanArgsSchema>
|
|
143
162
|
export type ResumeExecutionPlanRunArgs = z.infer<typeof ResumeExecutionPlanRunArgsSchema>
|
|
144
163
|
export type ExecutionPlanToolResultData = z.infer<typeof ExecutionPlanToolResultDataSchema>
|
|
164
|
+
export type CreateProjectWithPlanResultData = z.infer<typeof CreateProjectWithPlanResultDataSchema>
|
|
145
165
|
export type CoreChatTools = {
|
|
146
166
|
userQuestions: { input: UserQuestionsArgs; output: unknown }
|
|
147
167
|
consultSpecialist: { input: ConsultSpecialistArgs; output: ConsultSpecialistResultData }
|
|
148
168
|
consultTeam: { input: ConsultTeamArgs; output: ConsultTeamResultData }
|
|
149
169
|
createExecutionPlan: { input: CreateExecutionPlanArgs; output: ExecutionPlanToolResultData }
|
|
170
|
+
createProjectWithPlan: { input: CreateProjectWithPlanArgs; output: CreateProjectWithPlanResultData }
|
|
150
171
|
replaceExecutionPlan: { input: ReplaceExecutionPlanArgs; output: ExecutionPlanToolResultData }
|
|
151
172
|
submitExecutionNodeResult: { input: SubmitExecutionNodeResultArgs; output: ExecutionPlanToolResultData }
|
|
152
173
|
submitPlanTurnResult: { input: SubmitPlanTurnResultArgs; output: ExecutionPlanToolResultData }
|
|
@@ -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>
|