forge-openclaw-plugin 0.2.3 → 0.2.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/README.md +114 -6
- package/dist/assets/board-CzgvdLO8.js +6 -0
- package/dist/assets/board-CzgvdLO8.js.map +1 -0
- package/dist/assets/favicon-BCHm9dUV.ico +0 -0
- package/dist/assets/index-8d_oM8fL.js +27 -0
- package/dist/assets/index-8d_oM8fL.js.map +1 -0
- package/dist/assets/index-D4A_bq8m.css +1 -0
- package/dist/assets/motion-STUd1O46.js +10 -0
- package/dist/assets/motion-STUd1O46.js.map +1 -0
- package/dist/assets/plus-jakarta-sans-latin-ext-wght-normal-DmpS2jIq.woff2 +0 -0
- package/dist/assets/plus-jakarta-sans-latin-wght-normal-eXO_dkmS.woff2 +0 -0
- package/dist/assets/plus-jakarta-sans-vietnamese-wght-normal-qRpaaN48.woff2 +0 -0
- package/dist/assets/sora-latin-ext-wght-normal-CawQDOvP.woff2 +0 -0
- package/dist/assets/sora-latin-wght-normal-DdqRvwsR.woff2 +0 -0
- package/dist/assets/space-grotesk-latin-500-normal-CNSSEhBt.woff +0 -0
- package/dist/assets/space-grotesk-latin-500-normal-lFbtlQH6.woff2 +0 -0
- package/dist/assets/space-grotesk-latin-700-normal-CwsQ-cCU.woff +0 -0
- package/dist/assets/space-grotesk-latin-700-normal-RjhwGPKo.woff2 +0 -0
- package/dist/assets/space-grotesk-latin-ext-500-normal-3dgZTiw9.woff +0 -0
- package/dist/assets/space-grotesk-latin-ext-500-normal-DUe3BAxM.woff2 +0 -0
- package/dist/assets/space-grotesk-latin-ext-700-normal-BQnZhY3m.woff2 +0 -0
- package/dist/assets/space-grotesk-latin-ext-700-normal-HVCqSBdx.woff +0 -0
- package/dist/assets/space-grotesk-vietnamese-500-normal-BTqKIpxg.woff +0 -0
- package/dist/assets/space-grotesk-vietnamese-500-normal-BmEvtly_.woff2 +0 -0
- package/dist/assets/space-grotesk-vietnamese-700-normal-DMty7AZE.woff2 +0 -0
- package/dist/assets/space-grotesk-vietnamese-700-normal-Duxec5Rn.woff +0 -0
- package/dist/assets/table-CtNlETLc.js +23 -0
- package/dist/assets/table-CtNlETLc.js.map +1 -0
- package/dist/assets/ui-ThzkR_oW.js +46 -0
- package/dist/assets/ui-ThzkR_oW.js.map +1 -0
- package/dist/assets/vendor-CRS-psbw.css +1 -0
- package/dist/assets/vendor-DyHAI6nk.js +423 -0
- package/dist/assets/vendor-DyHAI6nk.js.map +1 -0
- package/dist/assets/viz-BJuBCz_G.js +34 -0
- package/dist/assets/viz-BJuBCz_G.js.map +1 -0
- package/dist/favicon.ico +0 -0
- package/dist/favicon.png +0 -0
- package/dist/index.html +29 -0
- package/dist/openclaw/api-client.d.ts +8 -0
- package/dist/openclaw/api-client.js +31 -4
- package/dist/openclaw/local-runtime.d.ts +3 -0
- package/dist/openclaw/local-runtime.js +135 -0
- package/dist/openclaw/parity.d.ts +4 -4
- package/dist/openclaw/parity.js +23 -33
- package/dist/openclaw/plugin-entry-shared.d.ts +5 -3
- package/dist/openclaw/plugin-entry-shared.js +52 -10
- package/dist/openclaw/routes.d.ts +12 -3
- package/dist/openclaw/routes.js +156 -924
- package/dist/openclaw/tools.js +242 -1100
- package/dist/server/app.js +2450 -0
- package/dist/server/db.js +313 -0
- package/dist/server/e2e-server.js +20 -0
- package/dist/server/errors.js +15 -0
- package/dist/server/index.js +16 -0
- package/dist/server/managers/base.js +17 -0
- package/dist/server/managers/contracts.js +47 -0
- package/dist/server/managers/platform/api-gateway-manager.js +11 -0
- package/dist/server/managers/platform/audit-manager.js +15 -0
- package/dist/server/managers/platform/authentication-manager.js +56 -0
- package/dist/server/managers/platform/authorization-manager.js +56 -0
- package/dist/server/managers/platform/background-job-manager.js +10 -0
- package/dist/server/managers/platform/configuration-manager.js +33 -0
- package/dist/server/managers/platform/database-manager.js +14 -0
- package/dist/server/managers/platform/event-bus-manager.js +7 -0
- package/dist/server/managers/platform/external-service-manager.js +11 -0
- package/dist/server/managers/platform/health-manager.js +7 -0
- package/dist/server/managers/platform/migration-manager.js +8 -0
- package/dist/server/managers/platform/search-index-manager.js +4 -0
- package/dist/server/managers/platform/secrets-manager.js +19 -0
- package/dist/server/managers/platform/session-manager.js +121 -0
- package/dist/server/managers/platform/storage-manager.js +16 -0
- package/dist/server/managers/platform/token-manager.js +37 -0
- package/dist/server/managers/platform/transaction-manager.js +8 -0
- package/dist/server/managers/platform/trusted-network.js +39 -0
- package/dist/server/managers/runtime.js +56 -0
- package/dist/server/managers/type-guards.js +4 -0
- package/dist/server/openapi.js +3512 -0
- package/dist/server/psyche-types.js +395 -0
- package/dist/server/repositories/activity-events.js +157 -0
- package/dist/server/repositories/collaboration.js +497 -0
- package/dist/server/repositories/comments.js +176 -0
- package/dist/server/repositories/deleted-entities.js +192 -0
- package/dist/server/repositories/domains.js +30 -0
- package/dist/server/repositories/event-log.js +64 -0
- package/dist/server/repositories/goals.js +159 -0
- package/dist/server/repositories/projects.js +214 -0
- package/dist/server/repositories/psyche.js +1356 -0
- package/dist/server/repositories/rewards.js +675 -0
- package/dist/server/repositories/settings.js +399 -0
- package/dist/server/repositories/tags.js +160 -0
- package/dist/server/repositories/task-runs.js +488 -0
- package/dist/server/repositories/tasks.js +413 -0
- package/dist/server/services/context.js +214 -0
- package/dist/server/services/dashboard.js +170 -0
- package/dist/server/services/entity-crud.js +576 -0
- package/dist/server/services/gamification.js +215 -0
- package/dist/server/services/insights.js +91 -0
- package/dist/server/services/projects.js +75 -0
- package/dist/server/services/psyche.js +63 -0
- package/dist/server/services/relations.js +28 -0
- package/dist/server/services/reviews.js +88 -0
- package/dist/server/services/run-recovery.js +13 -0
- package/dist/server/services/tagging.js +49 -0
- package/dist/server/services/task-run-watchdog.js +92 -0
- package/dist/server/services/work-time.js +176 -0
- package/dist/server/types.js +999 -0
- package/dist/server/web.js +91 -0
- package/openclaw.plugin.json +22 -10
- package/package.json +17 -4
- package/server/migrations/001_core.sql +333 -0
- package/server/migrations/002_psyche.sql +241 -0
- package/server/migrations/003_timer_execution.sql +18 -0
- package/server/migrations/004_psyche_linked_entities.sql +5 -0
- package/server/migrations/005_adaptive_schemas.sql +157 -0
- package/server/migrations/006_psyche_auth_setting.sql +4 -0
- package/server/migrations/007_deleted_entities.sql +16 -0
- package/skills/forge-openclaw/SKILL.md +189 -275
|
@@ -0,0 +1,999 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const taskStatusSchema = z.enum(["backlog", "focus", "in_progress", "blocked", "done"]);
|
|
3
|
+
export const taskPrioritySchema = z.enum(["low", "medium", "high", "critical"]);
|
|
4
|
+
export const taskEffortSchema = z.enum(["light", "deep", "marathon"]);
|
|
5
|
+
export const taskEnergySchema = z.enum(["low", "steady", "high"]);
|
|
6
|
+
export const goalStatusSchema = z.enum(["active", "paused", "completed"]);
|
|
7
|
+
export const goalHorizonSchema = z.enum(["quarter", "year", "lifetime"]);
|
|
8
|
+
export const projectStatusSchema = z.enum(["active", "paused", "completed"]);
|
|
9
|
+
export const tagKindSchema = z.enum(["value", "category", "execution"]);
|
|
10
|
+
export const taskDueFilterSchema = z.enum(["overdue", "today", "week"]);
|
|
11
|
+
export const taskRunStatusSchema = z.enum(["active", "completed", "released", "timed_out"]);
|
|
12
|
+
export const taskTimerModeSchema = z.enum(["planned", "unlimited"]);
|
|
13
|
+
export const timeAccountingModeSchema = z.enum(["split", "parallel", "primary_only"]);
|
|
14
|
+
export const activityEntityTypeSchema = z.enum([
|
|
15
|
+
"task",
|
|
16
|
+
"goal",
|
|
17
|
+
"project",
|
|
18
|
+
"domain",
|
|
19
|
+
"psyche_value",
|
|
20
|
+
"behavior_pattern",
|
|
21
|
+
"behavior",
|
|
22
|
+
"belief_entry",
|
|
23
|
+
"mode_profile",
|
|
24
|
+
"trigger_report",
|
|
25
|
+
"comment",
|
|
26
|
+
"event_type",
|
|
27
|
+
"emotion_definition",
|
|
28
|
+
"tag",
|
|
29
|
+
"task_run",
|
|
30
|
+
"system",
|
|
31
|
+
"insight",
|
|
32
|
+
"approval_request",
|
|
33
|
+
"agent_action",
|
|
34
|
+
"reward",
|
|
35
|
+
"session"
|
|
36
|
+
]);
|
|
37
|
+
export const activitySourceSchema = z.enum(["ui", "openclaw", "agent", "system"]);
|
|
38
|
+
export const agentTrustLevelSchema = z.enum(["standard", "trusted", "autonomous"]);
|
|
39
|
+
export const autonomyModeSchema = z.enum(["approval_required", "scoped_write", "autonomous"]);
|
|
40
|
+
export const approvalModeSchema = z.enum(["approval_by_default", "high_impact_only", "none"]);
|
|
41
|
+
export const insightOriginSchema = z.enum(["system", "user", "agent"]);
|
|
42
|
+
export const insightStatusSchema = z.enum(["open", "accepted", "dismissed", "snoozed", "applied", "expired"]);
|
|
43
|
+
export const insightVisibilitySchema = z.enum(["visible", "pending_review", "archived"]);
|
|
44
|
+
export const insightFeedbackTypeSchema = z.enum(["accepted", "dismissed", "applied", "snoozed"]);
|
|
45
|
+
export const approvalRequestStatusSchema = z.enum(["pending", "approved", "rejected", "cancelled", "executed"]);
|
|
46
|
+
export const actionRiskLevelSchema = z.enum(["low", "medium", "high"]);
|
|
47
|
+
export const agentActionStatusSchema = z.enum(["pending_approval", "approved", "rejected", "executed"]);
|
|
48
|
+
export const crudEntityTypeSchema = z.enum([
|
|
49
|
+
"goal",
|
|
50
|
+
"project",
|
|
51
|
+
"task",
|
|
52
|
+
"tag",
|
|
53
|
+
"comment",
|
|
54
|
+
"insight",
|
|
55
|
+
"psyche_value",
|
|
56
|
+
"behavior_pattern",
|
|
57
|
+
"behavior",
|
|
58
|
+
"belief_entry",
|
|
59
|
+
"mode_profile",
|
|
60
|
+
"mode_guide_session",
|
|
61
|
+
"event_type",
|
|
62
|
+
"emotion_definition",
|
|
63
|
+
"trigger_report"
|
|
64
|
+
]);
|
|
65
|
+
export const deleteModeSchema = z.enum(["soft", "hard"]);
|
|
66
|
+
export const rewardRuleFamilySchema = z.enum([
|
|
67
|
+
"completion",
|
|
68
|
+
"consistency",
|
|
69
|
+
"alignment",
|
|
70
|
+
"recovery",
|
|
71
|
+
"collaboration",
|
|
72
|
+
"ambient"
|
|
73
|
+
]);
|
|
74
|
+
export const appLocaleSchema = z.enum(["en", "fr"]);
|
|
75
|
+
const trimmedString = z.string().trim();
|
|
76
|
+
const nonEmptyTrimmedString = trimmedString.min(1);
|
|
77
|
+
const rewardConfigValueSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
|
|
78
|
+
function isValidDateOnly(value) {
|
|
79
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const [yearText, monthText, dayText] = value.split("-");
|
|
83
|
+
const year = Number(yearText);
|
|
84
|
+
const month = Number(monthText);
|
|
85
|
+
const day = Number(dayText);
|
|
86
|
+
const candidate = new Date(Date.UTC(year, month - 1, day));
|
|
87
|
+
return (candidate.getUTCFullYear() === year &&
|
|
88
|
+
candidate.getUTCMonth() === month - 1 &&
|
|
89
|
+
candidate.getUTCDate() === day);
|
|
90
|
+
}
|
|
91
|
+
const dateOnlySchema = trimmedString.refine(isValidDateOnly, {
|
|
92
|
+
message: "Expected a valid date in YYYY-MM-DD format"
|
|
93
|
+
});
|
|
94
|
+
const uniqueStringArraySchema = z
|
|
95
|
+
.array(nonEmptyTrimmedString)
|
|
96
|
+
.superRefine((values, context) => {
|
|
97
|
+
const seen = new Set();
|
|
98
|
+
values.forEach((value, index) => {
|
|
99
|
+
if (seen.has(value)) {
|
|
100
|
+
context.addIssue({
|
|
101
|
+
code: z.ZodIssueCode.custom,
|
|
102
|
+
path: [index],
|
|
103
|
+
message: `Duplicate value '${value}' is not allowed`
|
|
104
|
+
});
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
seen.add(value);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
export const tagSchema = z.object({
|
|
111
|
+
id: z.string(),
|
|
112
|
+
name: nonEmptyTrimmedString,
|
|
113
|
+
kind: tagKindSchema,
|
|
114
|
+
color: z.string(),
|
|
115
|
+
description: z.string()
|
|
116
|
+
});
|
|
117
|
+
export const taskTimeSummarySchema = z.object({
|
|
118
|
+
totalTrackedSeconds: z.number().int().nonnegative(),
|
|
119
|
+
totalCreditedSeconds: z.number().nonnegative(),
|
|
120
|
+
activeRunCount: z.number().int().nonnegative(),
|
|
121
|
+
hasCurrentRun: z.boolean(),
|
|
122
|
+
currentRunId: z.string().nullable()
|
|
123
|
+
});
|
|
124
|
+
export const goalSchema = z.object({
|
|
125
|
+
id: z.string(),
|
|
126
|
+
title: nonEmptyTrimmedString,
|
|
127
|
+
description: trimmedString,
|
|
128
|
+
horizon: goalHorizonSchema,
|
|
129
|
+
status: goalStatusSchema,
|
|
130
|
+
targetPoints: z.number().int().nonnegative(),
|
|
131
|
+
themeColor: z.string(),
|
|
132
|
+
createdAt: z.string(),
|
|
133
|
+
updatedAt: z.string(),
|
|
134
|
+
tagIds: uniqueStringArraySchema.default([])
|
|
135
|
+
});
|
|
136
|
+
export const projectSchema = z.object({
|
|
137
|
+
id: z.string(),
|
|
138
|
+
goalId: z.string(),
|
|
139
|
+
title: nonEmptyTrimmedString,
|
|
140
|
+
description: trimmedString,
|
|
141
|
+
status: projectStatusSchema,
|
|
142
|
+
targetPoints: z.number().int().nonnegative(),
|
|
143
|
+
themeColor: z.string(),
|
|
144
|
+
createdAt: z.string(),
|
|
145
|
+
updatedAt: z.string()
|
|
146
|
+
});
|
|
147
|
+
export const taskSchema = z.object({
|
|
148
|
+
id: z.string(),
|
|
149
|
+
title: nonEmptyTrimmedString,
|
|
150
|
+
description: trimmedString,
|
|
151
|
+
status: taskStatusSchema,
|
|
152
|
+
priority: taskPrioritySchema,
|
|
153
|
+
owner: nonEmptyTrimmedString,
|
|
154
|
+
goalId: z.string().nullable(),
|
|
155
|
+
projectId: z.string().nullable(),
|
|
156
|
+
dueDate: dateOnlySchema.nullable(),
|
|
157
|
+
effort: taskEffortSchema,
|
|
158
|
+
energy: taskEnergySchema,
|
|
159
|
+
points: z.number().int().nonnegative(),
|
|
160
|
+
sortOrder: z.number().int().nonnegative(),
|
|
161
|
+
completedAt: z.string().nullable(),
|
|
162
|
+
createdAt: z.string(),
|
|
163
|
+
updatedAt: z.string(),
|
|
164
|
+
tagIds: z.array(z.string()).default([]),
|
|
165
|
+
time: taskTimeSummarySchema.default({
|
|
166
|
+
totalTrackedSeconds: 0,
|
|
167
|
+
totalCreditedSeconds: 0,
|
|
168
|
+
activeRunCount: 0,
|
|
169
|
+
hasCurrentRun: false,
|
|
170
|
+
currentRunId: null
|
|
171
|
+
})
|
|
172
|
+
});
|
|
173
|
+
export const taskRunSchema = z.object({
|
|
174
|
+
id: z.string(),
|
|
175
|
+
taskId: z.string(),
|
|
176
|
+
taskTitle: nonEmptyTrimmedString,
|
|
177
|
+
actor: nonEmptyTrimmedString,
|
|
178
|
+
status: taskRunStatusSchema,
|
|
179
|
+
timerMode: taskTimerModeSchema,
|
|
180
|
+
plannedDurationSeconds: z.number().int().positive().nullable(),
|
|
181
|
+
elapsedWallSeconds: z.number().int().nonnegative(),
|
|
182
|
+
creditedSeconds: z.number().nonnegative(),
|
|
183
|
+
remainingSeconds: z.number().int().nonnegative().nullable(),
|
|
184
|
+
overtimeSeconds: z.number().int().nonnegative(),
|
|
185
|
+
isCurrent: z.boolean(),
|
|
186
|
+
note: trimmedString,
|
|
187
|
+
leaseTtlSeconds: z.number().int().positive(),
|
|
188
|
+
claimedAt: z.string(),
|
|
189
|
+
heartbeatAt: z.string(),
|
|
190
|
+
leaseExpiresAt: z.string(),
|
|
191
|
+
completedAt: z.string().nullable(),
|
|
192
|
+
releasedAt: z.string().nullable(),
|
|
193
|
+
timedOutAt: z.string().nullable(),
|
|
194
|
+
updatedAt: z.string()
|
|
195
|
+
});
|
|
196
|
+
export const activityEventSchema = z.object({
|
|
197
|
+
id: z.string(),
|
|
198
|
+
entityType: activityEntityTypeSchema,
|
|
199
|
+
entityId: z.string(),
|
|
200
|
+
eventType: z.string(),
|
|
201
|
+
title: z.string(),
|
|
202
|
+
description: z.string(),
|
|
203
|
+
actor: z.string().nullable(),
|
|
204
|
+
source: activitySourceSchema,
|
|
205
|
+
metadata: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])),
|
|
206
|
+
createdAt: z.string()
|
|
207
|
+
});
|
|
208
|
+
export const dashboardGoalSchema = goalSchema.extend({
|
|
209
|
+
progress: z.number().min(0).max(100),
|
|
210
|
+
totalTasks: z.number().int().nonnegative(),
|
|
211
|
+
completedTasks: z.number().int().nonnegative(),
|
|
212
|
+
earnedPoints: z.number().int().nonnegative(),
|
|
213
|
+
momentumLabel: z.string(),
|
|
214
|
+
tags: z.array(tagSchema)
|
|
215
|
+
});
|
|
216
|
+
export const dashboardStatsSchema = z.object({
|
|
217
|
+
totalPoints: z.number().int().nonnegative(),
|
|
218
|
+
completedThisWeek: z.number().int().nonnegative(),
|
|
219
|
+
activeGoals: z.number().int().nonnegative(),
|
|
220
|
+
alignmentScore: z.number().int().nonnegative(),
|
|
221
|
+
focusTasks: z.number().int().nonnegative(),
|
|
222
|
+
overdueTasks: z.number().int().nonnegative(),
|
|
223
|
+
dueThisWeek: z.number().int().nonnegative()
|
|
224
|
+
});
|
|
225
|
+
export const executionBucketToneSchema = z.enum(["urgent", "accent", "neutral", "success"]);
|
|
226
|
+
export const dashboardExecutionBucketSchema = z.object({
|
|
227
|
+
id: z.enum(["overdue", "due_soon", "focus_now", "recently_completed"]),
|
|
228
|
+
label: z.string(),
|
|
229
|
+
summary: z.string(),
|
|
230
|
+
tone: executionBucketToneSchema,
|
|
231
|
+
tasks: z.array(taskSchema)
|
|
232
|
+
});
|
|
233
|
+
export const projectSummarySchema = projectSchema.extend({
|
|
234
|
+
goalTitle: z.string(),
|
|
235
|
+
activeTaskCount: z.number().int().nonnegative(),
|
|
236
|
+
completedTaskCount: z.number().int().nonnegative(),
|
|
237
|
+
totalTasks: z.number().int().nonnegative(),
|
|
238
|
+
earnedPoints: z.number().int().nonnegative(),
|
|
239
|
+
progress: z.number().min(0).max(100),
|
|
240
|
+
nextTaskId: z.string().nullable(),
|
|
241
|
+
nextTaskTitle: z.string().nullable(),
|
|
242
|
+
momentumLabel: z.string(),
|
|
243
|
+
time: taskTimeSummarySchema
|
|
244
|
+
});
|
|
245
|
+
export const gamificationProfileSchema = z.object({
|
|
246
|
+
totalXp: z.number().int().nonnegative(),
|
|
247
|
+
level: z.number().int().positive(),
|
|
248
|
+
currentLevelXp: z.number().int().nonnegative(),
|
|
249
|
+
nextLevelXp: z.number().int().positive(),
|
|
250
|
+
weeklyXp: z.number().int().nonnegative(),
|
|
251
|
+
streakDays: z.number().int().nonnegative(),
|
|
252
|
+
comboMultiplier: z.number().nonnegative(),
|
|
253
|
+
momentumScore: z.number().int().min(0).max(100),
|
|
254
|
+
topGoalId: z.string().nullable(),
|
|
255
|
+
topGoalTitle: z.string().nullable()
|
|
256
|
+
});
|
|
257
|
+
export const achievementTierSchema = z.enum(["bronze", "silver", "gold", "platinum"]);
|
|
258
|
+
export const achievementSignalSchema = z.object({
|
|
259
|
+
id: z.string(),
|
|
260
|
+
title: z.string(),
|
|
261
|
+
summary: z.string(),
|
|
262
|
+
tier: achievementTierSchema,
|
|
263
|
+
progressLabel: z.string(),
|
|
264
|
+
unlocked: z.boolean(),
|
|
265
|
+
unlockedAt: z.string().nullable()
|
|
266
|
+
});
|
|
267
|
+
export const milestoneRewardSchema = z.object({
|
|
268
|
+
id: z.string(),
|
|
269
|
+
title: z.string(),
|
|
270
|
+
summary: z.string(),
|
|
271
|
+
rewardLabel: z.string(),
|
|
272
|
+
progressLabel: z.string(),
|
|
273
|
+
current: z.number().int().nonnegative(),
|
|
274
|
+
target: z.number().int().positive(),
|
|
275
|
+
completed: z.boolean()
|
|
276
|
+
});
|
|
277
|
+
export const gamificationOverviewSchema = z.object({
|
|
278
|
+
profile: gamificationProfileSchema,
|
|
279
|
+
achievements: z.array(achievementSignalSchema),
|
|
280
|
+
milestoneRewards: z.array(milestoneRewardSchema)
|
|
281
|
+
});
|
|
282
|
+
export const xpMomentumPulseSchema = z.object({
|
|
283
|
+
status: z.enum(["surging", "steady", "recovering"]),
|
|
284
|
+
headline: z.string(),
|
|
285
|
+
detail: z.string(),
|
|
286
|
+
celebrationLabel: z.string(),
|
|
287
|
+
nextMilestoneId: z.string().nullable(),
|
|
288
|
+
nextMilestoneLabel: z.string()
|
|
289
|
+
});
|
|
290
|
+
export const dashboardPayloadSchema = z.object({
|
|
291
|
+
stats: dashboardStatsSchema,
|
|
292
|
+
goals: z.array(dashboardGoalSchema),
|
|
293
|
+
projects: z.array(projectSummarySchema),
|
|
294
|
+
tasks: z.array(taskSchema),
|
|
295
|
+
tags: z.array(tagSchema),
|
|
296
|
+
suggestedTags: z.array(tagSchema),
|
|
297
|
+
owners: z.array(z.string()),
|
|
298
|
+
executionBuckets: z.array(dashboardExecutionBucketSchema),
|
|
299
|
+
gamification: gamificationProfileSchema,
|
|
300
|
+
achievements: z.array(achievementSignalSchema),
|
|
301
|
+
milestoneRewards: z.array(milestoneRewardSchema),
|
|
302
|
+
recentActivity: z.array(activityEventSchema)
|
|
303
|
+
});
|
|
304
|
+
export const contextDomainBalanceSchema = z.object({
|
|
305
|
+
tagId: z.string(),
|
|
306
|
+
label: z.string(),
|
|
307
|
+
color: z.string(),
|
|
308
|
+
goalCount: z.number().int().nonnegative(),
|
|
309
|
+
activeTaskCount: z.number().int().nonnegative(),
|
|
310
|
+
completedPoints: z.number().int().nonnegative(),
|
|
311
|
+
momentumLabel: z.string()
|
|
312
|
+
});
|
|
313
|
+
export const contextNeglectedGoalSchema = z.object({
|
|
314
|
+
goalId: z.string(),
|
|
315
|
+
title: z.string(),
|
|
316
|
+
summary: z.string(),
|
|
317
|
+
risk: z.enum(["low", "medium", "high"])
|
|
318
|
+
});
|
|
319
|
+
export const overviewContextSchema = z.object({
|
|
320
|
+
generatedAt: z.string(),
|
|
321
|
+
strategicHeader: z.object({
|
|
322
|
+
streakDays: z.number().int().nonnegative(),
|
|
323
|
+
level: z.number().int().positive(),
|
|
324
|
+
totalXp: z.number().int().nonnegative(),
|
|
325
|
+
currentLevelXp: z.number().int().nonnegative(),
|
|
326
|
+
nextLevelXp: z.number().int().positive(),
|
|
327
|
+
momentumScore: z.number().int().min(0).max(100),
|
|
328
|
+
focusTasks: z.number().int().nonnegative(),
|
|
329
|
+
overdueTasks: z.number().int().nonnegative()
|
|
330
|
+
}),
|
|
331
|
+
projects: z.array(projectSummarySchema),
|
|
332
|
+
activeGoals: z.array(dashboardGoalSchema),
|
|
333
|
+
topTasks: z.array(taskSchema),
|
|
334
|
+
recentEvidence: z.array(activityEventSchema),
|
|
335
|
+
achievements: z.array(achievementSignalSchema),
|
|
336
|
+
domainBalance: z.array(contextDomainBalanceSchema),
|
|
337
|
+
neglectedGoals: z.array(contextNeglectedGoalSchema)
|
|
338
|
+
});
|
|
339
|
+
export const todayQuestSchema = z.object({
|
|
340
|
+
id: z.string(),
|
|
341
|
+
title: z.string(),
|
|
342
|
+
summary: z.string(),
|
|
343
|
+
rewardXp: z.number().int().positive(),
|
|
344
|
+
progressLabel: z.string(),
|
|
345
|
+
completed: z.boolean()
|
|
346
|
+
});
|
|
347
|
+
export const todayTimelineBucketSchema = z.object({
|
|
348
|
+
id: z.enum(["completed", "active", "upcoming", "deferred", "in_progress", "ready", "blocked", "done"]),
|
|
349
|
+
label: z.string(),
|
|
350
|
+
tasks: z.array(taskSchema)
|
|
351
|
+
});
|
|
352
|
+
export const todayContextSchema = z.object({
|
|
353
|
+
generatedAt: z.string(),
|
|
354
|
+
directive: z.object({
|
|
355
|
+
task: taskSchema.nullable(),
|
|
356
|
+
goalTitle: z.string().nullable(),
|
|
357
|
+
rewardXp: z.number().int().nonnegative(),
|
|
358
|
+
sessionLabel: z.string()
|
|
359
|
+
}),
|
|
360
|
+
timeline: z.array(todayTimelineBucketSchema),
|
|
361
|
+
dailyQuests: z.array(todayQuestSchema),
|
|
362
|
+
milestoneRewards: z.array(milestoneRewardSchema),
|
|
363
|
+
momentum: z.object({
|
|
364
|
+
streakDays: z.number().int().nonnegative(),
|
|
365
|
+
momentumScore: z.number().int().min(0).max(100),
|
|
366
|
+
recoveryHint: z.string()
|
|
367
|
+
})
|
|
368
|
+
});
|
|
369
|
+
export const riskContextSchema = z.object({
|
|
370
|
+
generatedAt: z.string(),
|
|
371
|
+
overdueTasks: z.array(taskSchema),
|
|
372
|
+
blockedTasks: z.array(taskSchema),
|
|
373
|
+
neglectedGoals: z.array(contextNeglectedGoalSchema),
|
|
374
|
+
summary: z.string()
|
|
375
|
+
});
|
|
376
|
+
export const taskContextPayloadSchema = z.object({
|
|
377
|
+
task: taskSchema,
|
|
378
|
+
goal: goalSchema.nullable(),
|
|
379
|
+
project: projectSummarySchema.nullable(),
|
|
380
|
+
activeTaskRun: taskRunSchema.nullable(),
|
|
381
|
+
taskRuns: z.array(taskRunSchema),
|
|
382
|
+
activity: z.array(activityEventSchema)
|
|
383
|
+
});
|
|
384
|
+
export const projectBoardPayloadSchema = z.object({
|
|
385
|
+
project: projectSummarySchema,
|
|
386
|
+
goal: goalSchema,
|
|
387
|
+
tasks: z.array(taskSchema),
|
|
388
|
+
activity: z.array(activityEventSchema)
|
|
389
|
+
});
|
|
390
|
+
export const insightsHeatmapCellSchema = z.object({
|
|
391
|
+
id: z.string(),
|
|
392
|
+
label: z.string(),
|
|
393
|
+
completed: z.number().int().nonnegative(),
|
|
394
|
+
focus: z.number().int().nonnegative(),
|
|
395
|
+
intensity: z.number().int().min(0).max(4)
|
|
396
|
+
});
|
|
397
|
+
export const insightsExecutionTrendSchema = z.object({
|
|
398
|
+
label: z.string(),
|
|
399
|
+
xp: z.number().int().nonnegative(),
|
|
400
|
+
focusScore: z.number().int().min(0).max(100)
|
|
401
|
+
});
|
|
402
|
+
export const insightsDomainBalanceRowSchema = z.object({
|
|
403
|
+
label: z.string(),
|
|
404
|
+
value: z.number().int().min(0).max(100),
|
|
405
|
+
color: z.string(),
|
|
406
|
+
note: z.string()
|
|
407
|
+
});
|
|
408
|
+
export const coachingInsightSchema = z.object({
|
|
409
|
+
title: z.string(),
|
|
410
|
+
summary: z.string(),
|
|
411
|
+
recommendation: z.string(),
|
|
412
|
+
ctaLabel: z.string()
|
|
413
|
+
});
|
|
414
|
+
export const insightsPayloadSchema = z.object({
|
|
415
|
+
generatedAt: z.string(),
|
|
416
|
+
status: z.object({
|
|
417
|
+
systemStatus: z.string(),
|
|
418
|
+
streakDays: z.number().int().nonnegative(),
|
|
419
|
+
momentumScore: z.number().int().min(0).max(100)
|
|
420
|
+
}),
|
|
421
|
+
momentumHeatmap: z.array(insightsHeatmapCellSchema),
|
|
422
|
+
executionTrends: z.array(insightsExecutionTrendSchema),
|
|
423
|
+
domainBalance: z.array(insightsDomainBalanceRowSchema),
|
|
424
|
+
coaching: coachingInsightSchema,
|
|
425
|
+
evidenceDigest: z.array(activityEventSchema),
|
|
426
|
+
feed: z.array(z.lazy(() => insightSchema)),
|
|
427
|
+
openCount: z.number().int().nonnegative()
|
|
428
|
+
});
|
|
429
|
+
export const weeklyReviewChartPointSchema = z.object({
|
|
430
|
+
label: z.string(),
|
|
431
|
+
xp: z.number().int().nonnegative(),
|
|
432
|
+
focusHours: z.number().int().nonnegative()
|
|
433
|
+
});
|
|
434
|
+
export const weeklyReviewWinSchema = z.object({
|
|
435
|
+
id: z.string(),
|
|
436
|
+
title: z.string(),
|
|
437
|
+
summary: z.string(),
|
|
438
|
+
rewardXp: z.number().int().nonnegative()
|
|
439
|
+
});
|
|
440
|
+
export const weeklyReviewCalibrationSchema = z.object({
|
|
441
|
+
id: z.string(),
|
|
442
|
+
title: z.string(),
|
|
443
|
+
mode: z.enum(["accelerate", "maintain", "recover"]),
|
|
444
|
+
note: z.string()
|
|
445
|
+
});
|
|
446
|
+
export const weeklyReviewPayloadSchema = z.object({
|
|
447
|
+
generatedAt: z.string(),
|
|
448
|
+
windowLabel: z.string(),
|
|
449
|
+
momentumSummary: z.object({
|
|
450
|
+
totalXp: z.number().int().nonnegative(),
|
|
451
|
+
focusHours: z.number().int().nonnegative(),
|
|
452
|
+
efficiencyScore: z.number().int().min(0).max(100),
|
|
453
|
+
peakWindow: z.string()
|
|
454
|
+
}),
|
|
455
|
+
chart: z.array(weeklyReviewChartPointSchema),
|
|
456
|
+
wins: z.array(weeklyReviewWinSchema),
|
|
457
|
+
calibration: z.array(weeklyReviewCalibrationSchema),
|
|
458
|
+
reward: z.object({
|
|
459
|
+
title: z.string(),
|
|
460
|
+
summary: z.string(),
|
|
461
|
+
rewardXp: z.number().int().nonnegative()
|
|
462
|
+
})
|
|
463
|
+
});
|
|
464
|
+
export const notificationPreferencesSchema = z.object({
|
|
465
|
+
goalDriftAlerts: z.boolean(),
|
|
466
|
+
dailyQuestReminders: z.boolean(),
|
|
467
|
+
achievementCelebrations: z.boolean()
|
|
468
|
+
});
|
|
469
|
+
export const themePreferenceSchema = z.enum(["obsidian", "solar", "system"]);
|
|
470
|
+
export const executionSettingsSchema = z.object({
|
|
471
|
+
maxActiveTasks: z.number().int().min(1).max(8),
|
|
472
|
+
timeAccountingMode: timeAccountingModeSchema
|
|
473
|
+
});
|
|
474
|
+
export const agentTokenSummarySchema = z.object({
|
|
475
|
+
id: z.string(),
|
|
476
|
+
label: z.string(),
|
|
477
|
+
tokenPrefix: z.string(),
|
|
478
|
+
scopes: z.array(z.string()),
|
|
479
|
+
agentId: z.string().nullable(),
|
|
480
|
+
agentLabel: z.string().nullable(),
|
|
481
|
+
trustLevel: agentTrustLevelSchema,
|
|
482
|
+
autonomyMode: autonomyModeSchema,
|
|
483
|
+
approvalMode: approvalModeSchema,
|
|
484
|
+
description: z.string(),
|
|
485
|
+
lastUsedAt: z.string().nullable(),
|
|
486
|
+
revokedAt: z.string().nullable(),
|
|
487
|
+
createdAt: z.string(),
|
|
488
|
+
updatedAt: z.string(),
|
|
489
|
+
status: z.enum(["active", "revoked"])
|
|
490
|
+
});
|
|
491
|
+
export const agentIdentitySchema = z.object({
|
|
492
|
+
id: z.string(),
|
|
493
|
+
label: z.string(),
|
|
494
|
+
agentType: z.string(),
|
|
495
|
+
trustLevel: agentTrustLevelSchema,
|
|
496
|
+
autonomyMode: autonomyModeSchema,
|
|
497
|
+
approvalMode: approvalModeSchema,
|
|
498
|
+
description: z.string(),
|
|
499
|
+
tokenCount: z.number().int().nonnegative(),
|
|
500
|
+
activeTokenCount: z.number().int().nonnegative(),
|
|
501
|
+
createdAt: z.string(),
|
|
502
|
+
updatedAt: z.string()
|
|
503
|
+
});
|
|
504
|
+
export const eventLogEntrySchema = z.object({
|
|
505
|
+
id: z.string(),
|
|
506
|
+
eventKind: z.string(),
|
|
507
|
+
entityType: z.string(),
|
|
508
|
+
entityId: z.string(),
|
|
509
|
+
actor: z.string().nullable(),
|
|
510
|
+
source: activitySourceSchema,
|
|
511
|
+
causedByEventId: z.string().nullable(),
|
|
512
|
+
metadata: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])),
|
|
513
|
+
createdAt: z.string()
|
|
514
|
+
});
|
|
515
|
+
export const insightEvidenceSchema = z.object({
|
|
516
|
+
entityType: z.string(),
|
|
517
|
+
entityId: z.string(),
|
|
518
|
+
label: z.string()
|
|
519
|
+
});
|
|
520
|
+
export const insightSchema = z.object({
|
|
521
|
+
id: z.string(),
|
|
522
|
+
originType: insightOriginSchema,
|
|
523
|
+
originAgentId: z.string().nullable(),
|
|
524
|
+
originLabel: z.string().nullable(),
|
|
525
|
+
visibility: insightVisibilitySchema,
|
|
526
|
+
status: insightStatusSchema,
|
|
527
|
+
entityType: z.string().nullable(),
|
|
528
|
+
entityId: z.string().nullable(),
|
|
529
|
+
timeframeLabel: z.string().nullable(),
|
|
530
|
+
title: z.string(),
|
|
531
|
+
summary: z.string(),
|
|
532
|
+
recommendation: z.string(),
|
|
533
|
+
rationale: z.string(),
|
|
534
|
+
confidence: z.number().min(0).max(1),
|
|
535
|
+
ctaLabel: z.string(),
|
|
536
|
+
evidence: z.array(insightEvidenceSchema),
|
|
537
|
+
createdAt: z.string(),
|
|
538
|
+
updatedAt: z.string()
|
|
539
|
+
});
|
|
540
|
+
export const insightFeedbackSchema = z.object({
|
|
541
|
+
id: z.string(),
|
|
542
|
+
insightId: z.string(),
|
|
543
|
+
actor: z.string().nullable(),
|
|
544
|
+
feedbackType: insightFeedbackTypeSchema,
|
|
545
|
+
note: z.string(),
|
|
546
|
+
createdAt: z.string()
|
|
547
|
+
});
|
|
548
|
+
export const approvalRequestSchema = z.object({
|
|
549
|
+
id: z.string(),
|
|
550
|
+
actionType: z.string(),
|
|
551
|
+
status: approvalRequestStatusSchema,
|
|
552
|
+
title: z.string(),
|
|
553
|
+
summary: z.string(),
|
|
554
|
+
entityType: z.string().nullable(),
|
|
555
|
+
entityId: z.string().nullable(),
|
|
556
|
+
requestedByAgentId: z.string().nullable(),
|
|
557
|
+
requestedByTokenId: z.string().nullable(),
|
|
558
|
+
requestedPayload: z.record(z.string(), z.unknown()),
|
|
559
|
+
approvedBy: z.string().nullable(),
|
|
560
|
+
approvedAt: z.string().nullable(),
|
|
561
|
+
rejectedBy: z.string().nullable(),
|
|
562
|
+
rejectedAt: z.string().nullable(),
|
|
563
|
+
resolutionNote: z.string(),
|
|
564
|
+
createdAt: z.string(),
|
|
565
|
+
updatedAt: z.string()
|
|
566
|
+
});
|
|
567
|
+
export const agentActionSchema = z.object({
|
|
568
|
+
id: z.string(),
|
|
569
|
+
agentId: z.string().nullable(),
|
|
570
|
+
tokenId: z.string().nullable(),
|
|
571
|
+
actionType: z.string(),
|
|
572
|
+
riskLevel: actionRiskLevelSchema,
|
|
573
|
+
status: agentActionStatusSchema,
|
|
574
|
+
title: z.string(),
|
|
575
|
+
summary: z.string(),
|
|
576
|
+
payload: z.record(z.string(), z.unknown()),
|
|
577
|
+
idempotencyKey: z.string().nullable(),
|
|
578
|
+
approvalRequestId: z.string().nullable(),
|
|
579
|
+
outcome: z.record(z.string(), z.unknown()),
|
|
580
|
+
createdAt: z.string(),
|
|
581
|
+
updatedAt: z.string(),
|
|
582
|
+
completedAt: z.string().nullable()
|
|
583
|
+
});
|
|
584
|
+
export const rewardRuleSchema = z.object({
|
|
585
|
+
id: z.string(),
|
|
586
|
+
family: rewardRuleFamilySchema,
|
|
587
|
+
code: z.string(),
|
|
588
|
+
title: z.string(),
|
|
589
|
+
description: z.string(),
|
|
590
|
+
active: z.boolean(),
|
|
591
|
+
config: z.record(z.string(), rewardConfigValueSchema),
|
|
592
|
+
createdAt: z.string(),
|
|
593
|
+
updatedAt: z.string()
|
|
594
|
+
});
|
|
595
|
+
export const rewardLedgerEventSchema = z.object({
|
|
596
|
+
id: z.string(),
|
|
597
|
+
ruleId: z.string().nullable(),
|
|
598
|
+
eventLogId: z.string().nullable(),
|
|
599
|
+
entityType: z.string(),
|
|
600
|
+
entityId: z.string(),
|
|
601
|
+
actor: z.string().nullable(),
|
|
602
|
+
source: activitySourceSchema,
|
|
603
|
+
deltaXp: z.number().int(),
|
|
604
|
+
reasonTitle: z.string(),
|
|
605
|
+
reasonSummary: z.string(),
|
|
606
|
+
reversibleGroup: z.string().nullable(),
|
|
607
|
+
reversedByRewardId: z.string().nullable(),
|
|
608
|
+
metadata: z.record(z.string(), rewardConfigValueSchema),
|
|
609
|
+
createdAt: z.string()
|
|
610
|
+
});
|
|
611
|
+
export const sessionEventSchema = z.object({
|
|
612
|
+
id: z.string(),
|
|
613
|
+
sessionId: z.string(),
|
|
614
|
+
eventType: z.string(),
|
|
615
|
+
actor: z.string().nullable(),
|
|
616
|
+
source: activitySourceSchema,
|
|
617
|
+
metrics: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])),
|
|
618
|
+
createdAt: z.string()
|
|
619
|
+
});
|
|
620
|
+
export const xpMetricsPayloadSchema = z.object({
|
|
621
|
+
profile: gamificationProfileSchema,
|
|
622
|
+
achievements: z.array(achievementSignalSchema),
|
|
623
|
+
milestoneRewards: z.array(milestoneRewardSchema),
|
|
624
|
+
momentumPulse: xpMomentumPulseSchema,
|
|
625
|
+
recentLedger: z.array(rewardLedgerEventSchema),
|
|
626
|
+
rules: z.array(rewardRuleSchema),
|
|
627
|
+
dailyAmbientXp: z.number().int().nonnegative(),
|
|
628
|
+
dailyAmbientCap: z.number().int().positive()
|
|
629
|
+
});
|
|
630
|
+
export const operatorContextPayloadSchema = z.object({
|
|
631
|
+
generatedAt: z.string(),
|
|
632
|
+
activeProjects: z.array(projectSummarySchema),
|
|
633
|
+
focusTasks: z.array(taskSchema),
|
|
634
|
+
currentBoard: z.object({
|
|
635
|
+
backlog: z.array(taskSchema),
|
|
636
|
+
focus: z.array(taskSchema),
|
|
637
|
+
inProgress: z.array(taskSchema),
|
|
638
|
+
blocked: z.array(taskSchema),
|
|
639
|
+
done: z.array(taskSchema)
|
|
640
|
+
}),
|
|
641
|
+
recentActivity: z.array(activityEventSchema),
|
|
642
|
+
recentTaskRuns: z.array(taskRunSchema),
|
|
643
|
+
recommendedNextTask: taskSchema.nullable(),
|
|
644
|
+
xp: xpMetricsPayloadSchema
|
|
645
|
+
});
|
|
646
|
+
export const updateRewardRuleSchema = z.object({
|
|
647
|
+
title: nonEmptyTrimmedString.optional(),
|
|
648
|
+
description: trimmedString.optional(),
|
|
649
|
+
active: z.boolean().optional(),
|
|
650
|
+
config: z.record(z.string(), rewardConfigValueSchema).optional()
|
|
651
|
+
});
|
|
652
|
+
export const createManualRewardGrantSchema = z.object({
|
|
653
|
+
entityType: nonEmptyTrimmedString,
|
|
654
|
+
entityId: nonEmptyTrimmedString,
|
|
655
|
+
deltaXp: z.number().int().refine((value) => value !== 0, {
|
|
656
|
+
message: "deltaXp must not be zero"
|
|
657
|
+
}),
|
|
658
|
+
reasonTitle: nonEmptyTrimmedString,
|
|
659
|
+
reasonSummary: trimmedString.default(""),
|
|
660
|
+
metadata: z.record(z.string(), rewardConfigValueSchema).default({})
|
|
661
|
+
});
|
|
662
|
+
export const settingsPayloadSchema = z.object({
|
|
663
|
+
profile: z.object({
|
|
664
|
+
operatorName: z.string(),
|
|
665
|
+
operatorEmail: z.string(),
|
|
666
|
+
operatorTitle: z.string()
|
|
667
|
+
}),
|
|
668
|
+
notifications: notificationPreferencesSchema,
|
|
669
|
+
execution: executionSettingsSchema,
|
|
670
|
+
themePreference: themePreferenceSchema,
|
|
671
|
+
localePreference: appLocaleSchema,
|
|
672
|
+
security: z.object({
|
|
673
|
+
integrityScore: z.number().int().min(0).max(100),
|
|
674
|
+
lastAuditAt: z.string(),
|
|
675
|
+
storageMode: z.literal("local-first"),
|
|
676
|
+
activeSessions: z.number().int().positive(),
|
|
677
|
+
tokenCount: z.number().int().nonnegative(),
|
|
678
|
+
psycheAuthRequired: z.boolean()
|
|
679
|
+
}),
|
|
680
|
+
agents: z.array(agentIdentitySchema),
|
|
681
|
+
agentTokens: z.array(agentTokenSummarySchema)
|
|
682
|
+
});
|
|
683
|
+
export const deletedEntityRecordSchema = z.object({
|
|
684
|
+
entityType: crudEntityTypeSchema,
|
|
685
|
+
entityId: nonEmptyTrimmedString,
|
|
686
|
+
title: nonEmptyTrimmedString,
|
|
687
|
+
subtitle: trimmedString,
|
|
688
|
+
deletedAt: z.string(),
|
|
689
|
+
deletedByActor: z.string().nullable(),
|
|
690
|
+
deletedSource: activitySourceSchema,
|
|
691
|
+
deleteReason: trimmedString,
|
|
692
|
+
snapshot: z.record(z.string(), z.unknown())
|
|
693
|
+
});
|
|
694
|
+
export const settingsBinPayloadSchema = z.object({
|
|
695
|
+
generatedAt: z.string(),
|
|
696
|
+
totalCount: z.number().int().nonnegative(),
|
|
697
|
+
countsByEntityType: z.record(z.string(), z.number().int().nonnegative()),
|
|
698
|
+
records: z.array(deletedEntityRecordSchema)
|
|
699
|
+
});
|
|
700
|
+
export const taskListQuerySchema = z.object({
|
|
701
|
+
status: taskStatusSchema.optional(),
|
|
702
|
+
owner: nonEmptyTrimmedString.optional(),
|
|
703
|
+
goalId: nonEmptyTrimmedString.optional(),
|
|
704
|
+
projectId: nonEmptyTrimmedString.optional(),
|
|
705
|
+
tagId: nonEmptyTrimmedString.optional(),
|
|
706
|
+
due: taskDueFilterSchema.optional(),
|
|
707
|
+
limit: z.coerce.number().int().positive().max(100).optional()
|
|
708
|
+
});
|
|
709
|
+
export const taskRunListQuerySchema = z.object({
|
|
710
|
+
taskId: nonEmptyTrimmedString.optional(),
|
|
711
|
+
status: taskRunStatusSchema.optional(),
|
|
712
|
+
active: z.coerce.boolean().optional(),
|
|
713
|
+
limit: z.coerce.number().int().positive().max(100).optional()
|
|
714
|
+
});
|
|
715
|
+
export const activityListQuerySchema = z.object({
|
|
716
|
+
entityType: activityEntityTypeSchema.optional(),
|
|
717
|
+
entityId: nonEmptyTrimmedString.optional(),
|
|
718
|
+
source: activitySourceSchema.optional(),
|
|
719
|
+
includeCorrected: z.coerce.boolean().optional(),
|
|
720
|
+
limit: z.coerce.number().int().positive().max(100).optional()
|
|
721
|
+
});
|
|
722
|
+
export const projectListQuerySchema = z.object({
|
|
723
|
+
goalId: nonEmptyTrimmedString.optional(),
|
|
724
|
+
status: projectStatusSchema.optional(),
|
|
725
|
+
limit: z.coerce.number().int().positive().max(100).optional()
|
|
726
|
+
});
|
|
727
|
+
export const createGoalSchema = z.object({
|
|
728
|
+
title: nonEmptyTrimmedString,
|
|
729
|
+
description: trimmedString.default(""),
|
|
730
|
+
horizon: goalHorizonSchema.default("year"),
|
|
731
|
+
status: goalStatusSchema.default("active"),
|
|
732
|
+
targetPoints: z.number().int().min(25).max(10000).default(400),
|
|
733
|
+
themeColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).default("#c8a46b"),
|
|
734
|
+
tagIds: uniqueStringArraySchema.default([])
|
|
735
|
+
});
|
|
736
|
+
export const updateGoalSchema = createGoalSchema.partial();
|
|
737
|
+
export const createTagSchema = z.object({
|
|
738
|
+
name: nonEmptyTrimmedString,
|
|
739
|
+
kind: tagKindSchema.default("category"),
|
|
740
|
+
color: z.string().regex(/^#[0-9a-fA-F]{6}$/).default("#71717a"),
|
|
741
|
+
description: trimmedString.default("")
|
|
742
|
+
});
|
|
743
|
+
export const updateTagSchema = createTagSchema.partial();
|
|
744
|
+
export const createProjectSchema = z.object({
|
|
745
|
+
goalId: nonEmptyTrimmedString,
|
|
746
|
+
title: nonEmptyTrimmedString,
|
|
747
|
+
description: trimmedString.default(""),
|
|
748
|
+
status: projectStatusSchema.default("active"),
|
|
749
|
+
targetPoints: z.number().int().min(25).max(10000).default(240),
|
|
750
|
+
themeColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).default("#c0c1ff")
|
|
751
|
+
});
|
|
752
|
+
export const updateProjectSchema = createProjectSchema.partial();
|
|
753
|
+
export const taskMutationShape = {
|
|
754
|
+
title: nonEmptyTrimmedString,
|
|
755
|
+
description: trimmedString.default(""),
|
|
756
|
+
status: taskStatusSchema.default("backlog"),
|
|
757
|
+
priority: taskPrioritySchema.default("medium"),
|
|
758
|
+
owner: nonEmptyTrimmedString.default("Albert"),
|
|
759
|
+
goalId: nonEmptyTrimmedString.nullable().default(null),
|
|
760
|
+
projectId: nonEmptyTrimmedString.nullable().default(null),
|
|
761
|
+
dueDate: dateOnlySchema.nullable().default(null),
|
|
762
|
+
effort: taskEffortSchema.default("deep"),
|
|
763
|
+
energy: taskEnergySchema.default("steady"),
|
|
764
|
+
points: z.number().int().min(5).max(500).default(40),
|
|
765
|
+
sortOrder: z.number().int().nonnegative().optional(),
|
|
766
|
+
tagIds: uniqueStringArraySchema.default([])
|
|
767
|
+
};
|
|
768
|
+
export const createTaskSchema = z.object(taskMutationShape);
|
|
769
|
+
export const updateTaskSchema = z.object({
|
|
770
|
+
title: nonEmptyTrimmedString.optional(),
|
|
771
|
+
description: trimmedString.optional(),
|
|
772
|
+
status: taskStatusSchema.optional(),
|
|
773
|
+
priority: taskPrioritySchema.optional(),
|
|
774
|
+
owner: nonEmptyTrimmedString.optional(),
|
|
775
|
+
goalId: nonEmptyTrimmedString.nullable().optional(),
|
|
776
|
+
projectId: nonEmptyTrimmedString.nullable().optional(),
|
|
777
|
+
dueDate: dateOnlySchema.nullable().optional(),
|
|
778
|
+
effort: taskEffortSchema.optional(),
|
|
779
|
+
energy: taskEnergySchema.optional(),
|
|
780
|
+
points: z.number().int().min(5).max(500).optional(),
|
|
781
|
+
sortOrder: z.number().int().nonnegative().optional(),
|
|
782
|
+
tagIds: uniqueStringArraySchema.optional()
|
|
783
|
+
});
|
|
784
|
+
export const tagSuggestionRequestSchema = z.object({
|
|
785
|
+
title: trimmedString.default(""),
|
|
786
|
+
description: trimmedString.default(""),
|
|
787
|
+
goalId: nonEmptyTrimmedString.nullable().default(null),
|
|
788
|
+
selectedTagIds: uniqueStringArraySchema.default([])
|
|
789
|
+
});
|
|
790
|
+
export const taskRunClaimSchema = z.object({
|
|
791
|
+
actor: nonEmptyTrimmedString,
|
|
792
|
+
timerMode: taskTimerModeSchema.default("unlimited"),
|
|
793
|
+
plannedDurationSeconds: z.coerce.number().int().min(60).max(86_400).nullable().default(null),
|
|
794
|
+
isCurrent: z.coerce.boolean().default(true),
|
|
795
|
+
leaseTtlSeconds: z.coerce.number().int().min(1).max(14400).default(900),
|
|
796
|
+
note: trimmedString.default("")
|
|
797
|
+
}).superRefine((value, context) => {
|
|
798
|
+
if (value.timerMode === "planned" && value.plannedDurationSeconds === null) {
|
|
799
|
+
context.addIssue({
|
|
800
|
+
code: z.ZodIssueCode.custom,
|
|
801
|
+
path: ["plannedDurationSeconds"],
|
|
802
|
+
message: "plannedDurationSeconds is required when timerMode is planned"
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
if (value.timerMode === "unlimited" && value.plannedDurationSeconds !== null) {
|
|
806
|
+
context.addIssue({
|
|
807
|
+
code: z.ZodIssueCode.custom,
|
|
808
|
+
path: ["plannedDurationSeconds"],
|
|
809
|
+
message: "plannedDurationSeconds must be null when timerMode is unlimited"
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
export const taskRunHeartbeatSchema = z.object({
|
|
814
|
+
actor: nonEmptyTrimmedString.optional(),
|
|
815
|
+
leaseTtlSeconds: z.coerce.number().int().min(1).max(14400).default(900),
|
|
816
|
+
note: trimmedString.optional()
|
|
817
|
+
});
|
|
818
|
+
export const taskRunFinishSchema = z.object({
|
|
819
|
+
actor: nonEmptyTrimmedString.optional(),
|
|
820
|
+
note: trimmedString.default("")
|
|
821
|
+
});
|
|
822
|
+
export const taskRunFocusSchema = z.object({
|
|
823
|
+
actor: nonEmptyTrimmedString.optional()
|
|
824
|
+
});
|
|
825
|
+
export const updateSettingsSchema = z.object({
|
|
826
|
+
profile: z
|
|
827
|
+
.object({
|
|
828
|
+
operatorName: nonEmptyTrimmedString.optional(),
|
|
829
|
+
operatorEmail: nonEmptyTrimmedString.optional(),
|
|
830
|
+
operatorTitle: nonEmptyTrimmedString.optional()
|
|
831
|
+
})
|
|
832
|
+
.optional(),
|
|
833
|
+
notifications: notificationPreferencesSchema.partial().optional(),
|
|
834
|
+
execution: executionSettingsSchema.partial().optional(),
|
|
835
|
+
themePreference: themePreferenceSchema.optional(),
|
|
836
|
+
localePreference: appLocaleSchema.optional(),
|
|
837
|
+
security: z
|
|
838
|
+
.object({
|
|
839
|
+
psycheAuthRequired: z.boolean().optional()
|
|
840
|
+
})
|
|
841
|
+
.optional()
|
|
842
|
+
});
|
|
843
|
+
export const createAgentTokenSchema = z.object({
|
|
844
|
+
label: nonEmptyTrimmedString,
|
|
845
|
+
agentLabel: nonEmptyTrimmedString.default("Forge Agent"),
|
|
846
|
+
agentType: nonEmptyTrimmedString.default("assistant"),
|
|
847
|
+
description: trimmedString.default(""),
|
|
848
|
+
trustLevel: agentTrustLevelSchema.default("standard"),
|
|
849
|
+
autonomyMode: autonomyModeSchema.default("approval_required"),
|
|
850
|
+
approvalMode: approvalModeSchema.default("approval_by_default"),
|
|
851
|
+
scopes: uniqueStringArraySchema.default(["read", "write", "insights"])
|
|
852
|
+
});
|
|
853
|
+
export const activityArchiveQuerySchema = activityListQuerySchema.extend({
|
|
854
|
+
groupBy: z.enum(["day", "entity"]).optional(),
|
|
855
|
+
includeCorrected: z.coerce.boolean().optional()
|
|
856
|
+
});
|
|
857
|
+
export const eventsListQuerySchema = z.object({
|
|
858
|
+
entityType: nonEmptyTrimmedString.optional(),
|
|
859
|
+
entityId: nonEmptyTrimmedString.optional(),
|
|
860
|
+
eventKind: nonEmptyTrimmedString.optional(),
|
|
861
|
+
limit: z.coerce.number().int().positive().max(200).optional()
|
|
862
|
+
});
|
|
863
|
+
export const rewardsLedgerQuerySchema = z.object({
|
|
864
|
+
entityType: nonEmptyTrimmedString.optional(),
|
|
865
|
+
entityId: nonEmptyTrimmedString.optional(),
|
|
866
|
+
limit: z.coerce.number().int().positive().max(200).optional()
|
|
867
|
+
});
|
|
868
|
+
export const createInsightSchema = z.object({
|
|
869
|
+
originType: insightOriginSchema.default("user"),
|
|
870
|
+
originAgentId: nonEmptyTrimmedString.nullable().default(null),
|
|
871
|
+
originLabel: trimmedString.nullable().default(null),
|
|
872
|
+
visibility: insightVisibilitySchema.default("visible"),
|
|
873
|
+
status: insightStatusSchema.default("open"),
|
|
874
|
+
entityType: trimmedString.nullable().default(null),
|
|
875
|
+
entityId: trimmedString.nullable().default(null),
|
|
876
|
+
timeframeLabel: trimmedString.nullable().default(null),
|
|
877
|
+
title: nonEmptyTrimmedString,
|
|
878
|
+
summary: nonEmptyTrimmedString,
|
|
879
|
+
recommendation: nonEmptyTrimmedString,
|
|
880
|
+
rationale: trimmedString.default(""),
|
|
881
|
+
confidence: z.number().min(0).max(1).default(0.7),
|
|
882
|
+
ctaLabel: nonEmptyTrimmedString.default("Review insight"),
|
|
883
|
+
evidence: z.array(insightEvidenceSchema).default([])
|
|
884
|
+
});
|
|
885
|
+
export const updateInsightSchema = createInsightSchema.partial();
|
|
886
|
+
export const createInsightFeedbackSchema = z.object({
|
|
887
|
+
feedbackType: insightFeedbackTypeSchema,
|
|
888
|
+
note: trimmedString.default(""),
|
|
889
|
+
actor: trimmedString.nullable().default(null)
|
|
890
|
+
});
|
|
891
|
+
export const createAgentActionSchema = z.object({
|
|
892
|
+
actionType: nonEmptyTrimmedString,
|
|
893
|
+
riskLevel: actionRiskLevelSchema.default("medium"),
|
|
894
|
+
title: nonEmptyTrimmedString,
|
|
895
|
+
summary: trimmedString.default(""),
|
|
896
|
+
payload: z.record(z.string(), z.unknown()).default({}),
|
|
897
|
+
agentId: trimmedString.nullable().default(null),
|
|
898
|
+
tokenId: trimmedString.nullable().default(null)
|
|
899
|
+
});
|
|
900
|
+
export const resolveApprovalRequestSchema = z.object({
|
|
901
|
+
note: trimmedString.default(""),
|
|
902
|
+
actor: trimmedString.nullable().default(null)
|
|
903
|
+
});
|
|
904
|
+
export const createSessionEventSchema = z.object({
|
|
905
|
+
sessionId: nonEmptyTrimmedString,
|
|
906
|
+
eventType: nonEmptyTrimmedString,
|
|
907
|
+
metrics: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])).default({})
|
|
908
|
+
});
|
|
909
|
+
export const removeActivityEventSchema = z.object({
|
|
910
|
+
reason: trimmedString.default("Removed from the visible archive.")
|
|
911
|
+
});
|
|
912
|
+
export const entityDeleteQuerySchema = z.object({
|
|
913
|
+
mode: deleteModeSchema.default("soft"),
|
|
914
|
+
reason: trimmedString.default("")
|
|
915
|
+
});
|
|
916
|
+
const crudEntityLinkSchema = z.object({
|
|
917
|
+
entityType: crudEntityTypeSchema,
|
|
918
|
+
id: nonEmptyTrimmedString
|
|
919
|
+
});
|
|
920
|
+
export const batchCreateEntitiesSchema = z.object({
|
|
921
|
+
atomic: z.boolean().default(false),
|
|
922
|
+
operations: z.array(z.object({
|
|
923
|
+
entityType: crudEntityTypeSchema,
|
|
924
|
+
clientRef: trimmedString.optional(),
|
|
925
|
+
data: z.record(z.string(), z.unknown())
|
|
926
|
+
})).min(1)
|
|
927
|
+
});
|
|
928
|
+
export const batchUpdateEntitiesSchema = z.object({
|
|
929
|
+
atomic: z.boolean().default(false),
|
|
930
|
+
operations: z.array(z.object({
|
|
931
|
+
entityType: crudEntityTypeSchema,
|
|
932
|
+
id: nonEmptyTrimmedString,
|
|
933
|
+
clientRef: trimmedString.optional(),
|
|
934
|
+
patch: z.record(z.string(), z.unknown())
|
|
935
|
+
})).min(1)
|
|
936
|
+
});
|
|
937
|
+
export const batchDeleteEntitiesSchema = z.object({
|
|
938
|
+
atomic: z.boolean().default(false),
|
|
939
|
+
operations: z.array(z.object({
|
|
940
|
+
entityType: crudEntityTypeSchema,
|
|
941
|
+
id: nonEmptyTrimmedString,
|
|
942
|
+
clientRef: trimmedString.optional(),
|
|
943
|
+
mode: deleteModeSchema.default("soft"),
|
|
944
|
+
reason: trimmedString.default("")
|
|
945
|
+
})).min(1)
|
|
946
|
+
});
|
|
947
|
+
export const batchRestoreEntitiesSchema = z.object({
|
|
948
|
+
atomic: z.boolean().default(false),
|
|
949
|
+
operations: z.array(z.object({
|
|
950
|
+
entityType: crudEntityTypeSchema,
|
|
951
|
+
id: nonEmptyTrimmedString,
|
|
952
|
+
clientRef: trimmedString.optional()
|
|
953
|
+
})).min(1)
|
|
954
|
+
});
|
|
955
|
+
export const batchSearchEntitiesSchema = z.object({
|
|
956
|
+
searches: z.array(z.object({
|
|
957
|
+
entityTypes: z.array(crudEntityTypeSchema).optional(),
|
|
958
|
+
query: trimmedString.optional(),
|
|
959
|
+
ids: uniqueStringArraySchema.optional(),
|
|
960
|
+
status: uniqueStringArraySchema.optional(),
|
|
961
|
+
linkedTo: crudEntityLinkSchema.optional(),
|
|
962
|
+
includeDeleted: z.boolean().default(false),
|
|
963
|
+
limit: z.number().int().positive().max(200).default(25),
|
|
964
|
+
clientRef: trimmedString.optional()
|
|
965
|
+
})).min(1)
|
|
966
|
+
});
|
|
967
|
+
export const uncompleteTaskSchema = z.object({
|
|
968
|
+
status: taskStatusSchema.exclude(["done"]).default("focus")
|
|
969
|
+
});
|
|
970
|
+
export const operatorLogWorkSchema = z
|
|
971
|
+
.object({
|
|
972
|
+
taskId: nonEmptyTrimmedString.optional(),
|
|
973
|
+
title: trimmedString.optional(),
|
|
974
|
+
description: trimmedString.optional(),
|
|
975
|
+
summary: trimmedString.default(""),
|
|
976
|
+
goalId: nonEmptyTrimmedString.nullable().optional(),
|
|
977
|
+
projectId: nonEmptyTrimmedString.nullable().optional(),
|
|
978
|
+
owner: nonEmptyTrimmedString.optional(),
|
|
979
|
+
status: taskStatusSchema.optional(),
|
|
980
|
+
priority: taskPrioritySchema.optional(),
|
|
981
|
+
dueDate: dateOnlySchema.nullable().optional(),
|
|
982
|
+
effort: taskEffortSchema.optional(),
|
|
983
|
+
energy: taskEnergySchema.optional(),
|
|
984
|
+
points: z.number().int().min(5).max(500).optional(),
|
|
985
|
+
tagIds: uniqueStringArraySchema.optional()
|
|
986
|
+
})
|
|
987
|
+
.superRefine((value, context) => {
|
|
988
|
+
if (!value.taskId && (!value.title || value.title.trim().length === 0)) {
|
|
989
|
+
context.addIssue({
|
|
990
|
+
code: z.ZodIssueCode.custom,
|
|
991
|
+
path: ["title"],
|
|
992
|
+
message: "Either taskId or title is required"
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
export const operatorLogWorkResultSchema = z.object({
|
|
997
|
+
task: taskSchema,
|
|
998
|
+
xp: xpMetricsPayloadSchema
|
|
999
|
+
});
|