@opencorelabs/lucidity 0.6.0 → 0.8.0
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 +18 -3
- package/dist/assets/speech/lucidity-speech +0 -0
- package/dist/automations/agent.d.ts.map +1 -1
- package/dist/automations/agent.js +2 -0
- package/dist/automations/designer.d.ts +1 -1
- package/dist/chat/server.d.ts +1 -0
- package/dist/chat/server.d.ts.map +1 -1
- package/dist/chat/server.js +6 -1
- package/dist/coding/conduct.d.ts +1 -22
- package/dist/coding/conduct.d.ts.map +1 -1
- package/dist/coding/conduct.js +9 -94
- package/dist/coding/runCodeTurn.d.ts +3 -16
- package/dist/coding/runCodeTurn.d.ts.map +1 -1
- package/dist/coding/runCodeTurn.js +157 -165
- package/dist/coding/workspaceRegistry.d.ts +24 -0
- package/dist/coding/workspaceRegistry.d.ts.map +1 -0
- package/dist/coding/workspaceRegistry.js +230 -0
- package/dist/coding/worktree.d.ts +11 -14
- package/dist/coding/worktree.d.ts.map +1 -1
- package/dist/coding/worktree.js +41 -21
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/daemonLease.d.ts +12 -0
- package/dist/daemonLease.d.ts.map +1 -0
- package/dist/daemonLease.js +32 -0
- package/dist/goals/assessment.d.ts +115 -0
- package/dist/goals/assessment.d.ts.map +1 -0
- package/dist/goals/assessment.js +67 -0
- package/dist/goals/notes.d.ts +18 -0
- package/dist/goals/notes.d.ts.map +1 -0
- package/dist/goals/notes.js +72 -0
- package/dist/index.js +63 -15
- package/dist/jobs/goals.d.ts +15 -0
- package/dist/jobs/goals.d.ts.map +1 -0
- package/dist/jobs/goals.js +286 -0
- package/dist/jobs/weeklyReview.d.ts.map +1 -1
- package/dist/jobs/weeklyReview.js +3 -2
- package/dist/queue.d.ts +1 -0
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +4 -0
- package/dist/room/client.d.ts +5 -0
- package/dist/room/client.d.ts.map +1 -1
- package/dist/room/client.js +124 -107
- package/dist/room/computer.d.ts.map +1 -1
- package/dist/room/computer.js +2 -0
- package/dist/room/durablePublish.d.ts +6 -0
- package/dist/room/durablePublish.d.ts.map +1 -0
- package/dist/room/durablePublish.js +19 -0
- package/dist/room/incidents.d.ts +1 -1
- package/dist/room/incidents.d.ts.map +1 -1
- package/dist/room/incidents.js +14 -7
- package/dist/room/turnQueue.d.ts.map +1 -1
- package/dist/room/turnQueue.js +27 -24
- package/dist/runtimeStore.d.ts +44 -0
- package/dist/runtimeStore.d.ts.map +1 -0
- package/dist/runtimeStore.js +188 -0
- package/dist/setup/server.js +1 -1
- package/dist/turnLog.d.ts +10 -40
- package/dist/turnLog.d.ts.map +1 -1
- package/dist/turnLog.js +33 -56
- package/package.json +4 -4
- package/src/automations/agent.ts +2 -0
- package/src/chat/server.ts +7 -1
- package/src/coding/conduct.ts +10 -147
- package/src/coding/runCodeTurn.ts +42 -61
- package/src/coding/workspaceRegistry.ts +210 -0
- package/src/coding/worktree.ts +44 -20
- package/src/config.ts +2 -0
- package/src/daemonLease.ts +33 -0
- package/src/goals/assessment.ts +106 -0
- package/src/goals/notes.ts +88 -0
- package/src/index.ts +63 -18
- package/src/jobs/goals.ts +384 -0
- package/src/jobs/weeklyReview.ts +4 -3
- package/src/queue.ts +4 -0
- package/src/room/client.ts +85 -80
- package/src/room/computer.ts +2 -0
- package/src/room/durablePublish.ts +25 -0
- package/src/room/incidents.ts +16 -8
- package/src/room/turnQueue.ts +26 -27
- package/src/runtimeStore.ts +190 -0
- package/src/setup/server.ts +1 -1
- package/src/turnLog.ts +32 -75
- package/vendor/decisions/dist/dayPlan.d.ts +9 -0
- package/vendor/decisions/dist/dayPlan.js +82 -0
- package/vendor/decisions/dist/index.d.ts +1 -0
- package/vendor/decisions/dist/index.js +1 -0
- package/vendor/decisions/dist/jev.js +3 -1
- package/vendor/decisions/src/dayPlan.ts +80 -0
- package/vendor/decisions/src/index.ts +1 -0
- package/vendor/decisions/src/jev.ts +3 -1
- package/vendor/mcp-server/dist/index.js +2 -0
- package/vendor/mcp-server/dist/tools/goals.d.ts +4 -0
- package/vendor/mcp-server/dist/tools/goals.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/goals.js +38 -0
- package/vendor/mcp-server/package.json +1 -1
- package/vendor/mcp-server/src/index.ts +2 -0
- package/vendor/mcp-server/src/tools/goals.ts +62 -0
- package/vendor/runtime/README.md +2 -2
- package/vendor/runtime/dist/executor/asyncQueue.d.ts +1 -0
- package/vendor/runtime/dist/executor/asyncQueue.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/asyncQueue.js +3 -0
- package/vendor/runtime/dist/executor/claudeAgent.d.ts +1 -1
- package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/claudeAgent.js +25 -10
- package/vendor/runtime/dist/executor/codex.d.ts +1 -0
- package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codex.js +69 -36
- package/vendor/runtime/dist/executor/codexProtocol/FunctionCallOutputContentItem.d.ts +4 -1
- package/vendor/runtime/dist/executor/codexProtocol/FunctionCallOutputContentItem.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/Personality.d.ts +3 -0
- package/vendor/runtime/dist/executor/codexProtocol/Personality.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.d.ts +6 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/Model.d.ts +8 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/Model.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.d.ts +11 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts +4 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadResumeParams.d.ts +4 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadResumeParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStartParams.d.ts +3 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStartParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStartParams.d.ts +7 -2
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStartParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/UserInput.d.ts +3 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/UserInput.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexRpc.d.ts +10 -3
- package/vendor/runtime/dist/executor/codexRpc.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexRpc.js +18 -3
- package/vendor/runtime/dist/executor/codexSessions.d.ts +30 -0
- package/vendor/runtime/dist/executor/codexSessions.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexSessions.js +88 -0
- package/vendor/runtime/dist/executor/health.d.ts +2 -1
- package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/health.js +17 -5
- package/vendor/runtime/dist/executor/liveTurns.d.ts +2 -1
- package/vendor/runtime/dist/executor/liveTurns.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/liveTurns.js +12 -5
- package/vendor/runtime/dist/executor/ownership.d.ts +35 -0
- package/vendor/runtime/dist/executor/ownership.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/ownership.js +99 -0
- package/vendor/runtime/dist/executor/providerRouter.d.ts +1 -0
- package/vendor/runtime/dist/executor/providerRouter.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/providerRouter.js +5 -0
- package/vendor/runtime/dist/executor/types.d.ts +4 -0
- package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.d.ts +1 -0
- package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.js +12 -1
- package/vendor/runtime/dist/harness/types.d.ts +2 -1
- package/vendor/runtime/dist/harness/types.d.ts.map +1 -1
- package/vendor/runtime/dist/index.d.ts +1 -0
- package/vendor/runtime/dist/index.d.ts.map +1 -1
- package/vendor/runtime/dist/index.js +1 -0
- package/vendor/runtime/dist/prompts/dayPlanning.d.ts +44 -0
- package/vendor/runtime/dist/prompts/dayPlanning.d.ts.map +1 -0
- package/vendor/runtime/dist/prompts/dayPlanning.js +42 -0
- package/vendor/runtime/src/executor/asyncQueue.ts +3 -0
- package/vendor/runtime/src/executor/claudeAgent.ts +20 -9
- package/vendor/runtime/src/executor/codex.ts +76 -44
- package/vendor/runtime/src/executor/codexProtocol/FunctionCallOutputContentItem.ts +1 -1
- package/vendor/runtime/src/executor/codexProtocol/Personality.ts +3 -0
- package/vendor/runtime/src/executor/codexProtocol/PlanType.ts +1 -1
- package/vendor/runtime/src/executor/codexProtocol/README.md +2 -2
- package/vendor/runtime/src/executor/codexProtocol/v2/CyberAccessProgram.ts +9 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/GetAccountRateLimitsResponse.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/Model.ts +11 -2
- package/vendor/runtime/src/executor/codexProtocol/v2/ModelAccessPrograms.ts +13 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitSnapshot.ts +5 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/ReviewStartParams.ts +2 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadResumeParams.ts +5 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadStartParams.ts +4 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/TurnStartParams.ts +7 -2
- package/vendor/runtime/src/executor/codexProtocol/v2/UserInput.ts +1 -1
- package/vendor/runtime/src/executor/codexRpc.ts +22 -4
- package/vendor/runtime/src/executor/codexSessions.ts +108 -0
- package/vendor/runtime/src/executor/health.ts +16 -6
- package/vendor/runtime/src/executor/liveTurns.ts +12 -5
- package/vendor/runtime/src/executor/ownership.ts +76 -0
- package/vendor/runtime/src/executor/providerRouter.ts +6 -0
- package/vendor/runtime/src/executor/types.ts +4 -0
- package/vendor/runtime/src/harness/index.ts +12 -1
- package/vendor/runtime/src/harness/types.ts +2 -1
- package/vendor/runtime/src/index.ts +1 -0
- package/vendor/runtime/src/prompts/dayPlanning.ts +46 -0
- package/vendor/shared/dist/agentCommands.d.ts +1 -0
- package/vendor/shared/dist/agentCommands.d.ts.map +1 -1
- package/vendor/shared/dist/cardStudio.d.ts +41 -0
- package/vendor/shared/dist/cardStudio.d.ts.map +1 -1
- package/vendor/shared/dist/cardStudio.js +13 -3
- package/vendor/shared/dist/commandLocal.d.ts.map +1 -1
- package/vendor/shared/dist/commandLocal.js +2 -0
- package/vendor/shared/dist/commands.d.ts +18 -0
- package/vendor/shared/dist/commands.d.ts.map +1 -1
- package/vendor/shared/dist/commands.js +2 -0
- package/vendor/shared/dist/computer.d.ts +7 -1
- package/vendor/shared/dist/computer.d.ts.map +1 -1
- package/vendor/shared/dist/computer.js +13 -2
- package/vendor/shared/dist/constants.d.ts +3 -3
- package/vendor/shared/dist/constants.d.ts.map +1 -1
- package/vendor/shared/dist/constants.js +5 -4
- package/vendor/shared/dist/dayPlan.d.ts +86 -0
- package/vendor/shared/dist/dayPlan.d.ts.map +1 -0
- package/vendor/shared/dist/dayPlan.js +46 -0
- package/vendor/shared/dist/dayPlanning.d.ts +139 -0
- package/vendor/shared/dist/dayPlanning.d.ts.map +1 -0
- package/vendor/shared/dist/dayPlanning.js +67 -0
- package/vendor/shared/dist/goalNotes.d.ts +4 -0
- package/vendor/shared/dist/goalNotes.d.ts.map +1 -0
- package/vendor/shared/dist/goalNotes.js +23 -0
- package/vendor/shared/dist/goals.d.ts +835 -0
- package/vendor/shared/dist/goals.d.ts.map +1 -0
- package/vendor/shared/dist/goals.js +198 -0
- package/vendor/shared/dist/index.d.ts +5 -0
- package/vendor/shared/dist/index.d.ts.map +1 -1
- package/vendor/shared/dist/index.js +5 -0
- package/vendor/shared/dist/schemas/harness.d.ts +155 -0
- package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/harness.js +8 -0
- package/vendor/shared/dist/workspaces.d.ts +138 -0
- package/vendor/shared/dist/workspaces.d.ts.map +1 -0
- package/vendor/shared/dist/workspaces.js +40 -0
- package/vendor/shared/src/agentCommands.ts +1 -0
- package/vendor/shared/src/cardStudio.ts +13 -3
- package/vendor/shared/src/commandLocal.ts +2 -0
- package/vendor/shared/src/commands.ts +2 -0
- package/vendor/shared/src/computer.ts +18 -2
- package/vendor/shared/src/constants.ts +5 -4
- package/vendor/shared/src/dayPlan.ts +81 -0
- package/vendor/shared/src/dayPlanning.ts +77 -0
- package/vendor/shared/src/goalNotes.ts +23 -0
- package/vendor/shared/src/goals.ts +237 -0
- package/vendor/shared/src/index.ts +6 -0
- package/vendor/shared/src/schemas/harness.ts +8 -0
- package/vendor/shared/src/workspaces.ts +48 -0
- package/dist/coding/fleetIntegrate.d.ts +0 -37
- package/dist/coding/fleetIntegrate.d.ts.map +0 -1
- package/dist/coding/fleetIntegrate.js +0 -64
- package/dist/coding/openFleetPr.d.ts +0 -41
- package/dist/coding/openFleetPr.d.ts.map +0 -1
- package/dist/coding/openFleetPr.js +0 -121
- package/src/coding/fleetIntegrate.ts +0 -95
- package/src/coding/openFleetPr.ts +0 -148
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SavedChatMessageSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
role: z.ZodEnum<{
|
|
5
|
+
user: "user";
|
|
6
|
+
lucid: "lucid";
|
|
7
|
+
notice: "notice";
|
|
8
|
+
}>;
|
|
9
|
+
text: z.ZodString;
|
|
10
|
+
}, z.core.$loose>;
|
|
11
|
+
export declare const WorkerWorkspaceSchema: z.ZodObject<{
|
|
12
|
+
workerId: z.ZodUUID;
|
|
13
|
+
repoId: z.ZodString;
|
|
14
|
+
title: z.ZodString;
|
|
15
|
+
brief: z.ZodDefault<z.ZodString>;
|
|
16
|
+
workspaceId: z.ZodString;
|
|
17
|
+
conversationId: z.ZodString;
|
|
18
|
+
state: z.ZodEnum<{
|
|
19
|
+
ready: "ready";
|
|
20
|
+
archived: "archived";
|
|
21
|
+
creating: "creating";
|
|
22
|
+
setup_failed: "setup_failed";
|
|
23
|
+
}>;
|
|
24
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
25
|
+
baseRef: z.ZodOptional<z.ZodString>;
|
|
26
|
+
baseSha: z.ZodOptional<z.ZodString>;
|
|
27
|
+
resume: z.ZodOptional<z.ZodString>;
|
|
28
|
+
error: z.ZodOptional<z.ZodString>;
|
|
29
|
+
createdAt: z.ZodString;
|
|
30
|
+
updatedAt: z.ZodString;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type WorkerWorkspace = z.infer<typeof WorkerWorkspaceSchema>;
|
|
33
|
+
export declare const WorkspaceCommandSchema: z.ZodObject<{
|
|
34
|
+
action: z.ZodEnum<{
|
|
35
|
+
archive: "archive";
|
|
36
|
+
history: "history";
|
|
37
|
+
list: "list";
|
|
38
|
+
create: "create";
|
|
39
|
+
restore: "restore";
|
|
40
|
+
import: "import";
|
|
41
|
+
"clear-history": "clear-history";
|
|
42
|
+
}>;
|
|
43
|
+
repoId: z.ZodOptional<z.ZodString>;
|
|
44
|
+
workerId: z.ZodOptional<z.ZodUUID>;
|
|
45
|
+
checkout: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
revision: z.ZodOptional<z.ZodString>;
|
|
47
|
+
title: z.ZodOptional<z.ZodString>;
|
|
48
|
+
brief: z.ZodOptional<z.ZodString>;
|
|
49
|
+
before: z.ZodOptional<z.ZodString>;
|
|
50
|
+
legacy: z.ZodOptional<z.ZodObject<{
|
|
51
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
role: z.ZodEnum<{
|
|
54
|
+
user: "user";
|
|
55
|
+
lucid: "lucid";
|
|
56
|
+
notice: "notice";
|
|
57
|
+
}>;
|
|
58
|
+
text: z.ZodString;
|
|
59
|
+
}, z.core.$loose>>;
|
|
60
|
+
resume: z.ZodOptional<z.ZodString>;
|
|
61
|
+
sessionCheckout: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
export type WorkspaceCommand = z.infer<typeof WorkspaceCommandSchema>;
|
|
65
|
+
export declare const WorkspaceRunSchema: z.ZodObject<{
|
|
66
|
+
requestId: z.ZodString;
|
|
67
|
+
prompt: z.ZodString;
|
|
68
|
+
handoff: z.ZodOptional<z.ZodObject<{
|
|
69
|
+
from: z.ZodEnum<{
|
|
70
|
+
claude: "claude";
|
|
71
|
+
codex: "codex";
|
|
72
|
+
}>;
|
|
73
|
+
to: z.ZodEnum<{
|
|
74
|
+
claude: "claude";
|
|
75
|
+
codex: "codex";
|
|
76
|
+
}>;
|
|
77
|
+
}, z.core.$strip>>;
|
|
78
|
+
frames: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
79
|
+
terminated: z.ZodBoolean;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
export type WorkspaceRun = z.infer<typeof WorkspaceRunSchema>;
|
|
82
|
+
export declare const WorkspaceSnapshotSchema: z.ZodObject<{
|
|
83
|
+
workers: z.ZodArray<z.ZodObject<{
|
|
84
|
+
workerId: z.ZodUUID;
|
|
85
|
+
repoId: z.ZodString;
|
|
86
|
+
title: z.ZodString;
|
|
87
|
+
brief: z.ZodDefault<z.ZodString>;
|
|
88
|
+
workspaceId: z.ZodString;
|
|
89
|
+
conversationId: z.ZodString;
|
|
90
|
+
state: z.ZodEnum<{
|
|
91
|
+
ready: "ready";
|
|
92
|
+
archived: "archived";
|
|
93
|
+
creating: "creating";
|
|
94
|
+
setup_failed: "setup_failed";
|
|
95
|
+
}>;
|
|
96
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
97
|
+
baseRef: z.ZodOptional<z.ZodString>;
|
|
98
|
+
baseSha: z.ZodOptional<z.ZodString>;
|
|
99
|
+
resume: z.ZodOptional<z.ZodString>;
|
|
100
|
+
error: z.ZodOptional<z.ZodString>;
|
|
101
|
+
createdAt: z.ZodString;
|
|
102
|
+
updatedAt: z.ZodString;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
checkout: z.ZodOptional<z.ZodObject<{
|
|
105
|
+
repoId: z.ZodString;
|
|
106
|
+
conversationId: z.ZodString;
|
|
107
|
+
revision: z.ZodString;
|
|
108
|
+
resume: z.ZodOptional<z.ZodString>;
|
|
109
|
+
}, z.core.$strip>>;
|
|
110
|
+
runs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
111
|
+
requestId: z.ZodString;
|
|
112
|
+
prompt: z.ZodString;
|
|
113
|
+
handoff: z.ZodOptional<z.ZodObject<{
|
|
114
|
+
from: z.ZodEnum<{
|
|
115
|
+
claude: "claude";
|
|
116
|
+
codex: "codex";
|
|
117
|
+
}>;
|
|
118
|
+
to: z.ZodEnum<{
|
|
119
|
+
claude: "claude";
|
|
120
|
+
codex: "codex";
|
|
121
|
+
}>;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
frames: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
124
|
+
terminated: z.ZodBoolean;
|
|
125
|
+
}, z.core.$strip>>>;
|
|
126
|
+
legacyMessages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
127
|
+
id: z.ZodString;
|
|
128
|
+
role: z.ZodEnum<{
|
|
129
|
+
user: "user";
|
|
130
|
+
lucid: "lucid";
|
|
131
|
+
notice: "notice";
|
|
132
|
+
}>;
|
|
133
|
+
text: z.ZodString;
|
|
134
|
+
}, z.core.$loose>>>;
|
|
135
|
+
nextBefore: z.ZodOptional<z.ZodString>;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
export type WorkspaceSnapshot = z.infer<typeof WorkspaceSnapshotSchema>;
|
|
138
|
+
//# sourceMappingURL=workspaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../src/workspaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,sBAAsB;;;;;;;;iBAEnB,CAAC;AAEjB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;iBAQhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAUjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;iBAK7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBASlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const SavedChatMessageSchema = z.object({
|
|
3
|
+
id: z.string().min(1), role: z.enum(['user', 'lucid', 'notice']), text: z.string(),
|
|
4
|
+
}).passthrough();
|
|
5
|
+
export const WorkerWorkspaceSchema = z.object({
|
|
6
|
+
workerId: z.uuidv7(), repoId: z.string().min(1), title: z.string().min(1).max(200),
|
|
7
|
+
brief: z.string().max(8000).default(''),
|
|
8
|
+
workspaceId: z.string(), conversationId: z.string(),
|
|
9
|
+
state: z.enum(['creating', 'ready', 'setup_failed', 'archived']),
|
|
10
|
+
branch: z.string().optional(), baseRef: z.string().optional(), baseSha: z.string().optional(),
|
|
11
|
+
resume: z.string().optional(), error: z.string().optional(),
|
|
12
|
+
createdAt: z.string(), updatedAt: z.string(),
|
|
13
|
+
});
|
|
14
|
+
export const WorkspaceCommandSchema = z.object({
|
|
15
|
+
action: z.enum(['list', 'create', 'history', 'archive', 'restore', 'import', 'clear-history']),
|
|
16
|
+
repoId: z.string().min(1).optional(), workerId: z.uuidv7().optional(),
|
|
17
|
+
checkout: z.boolean().optional(), revision: z.string().optional(),
|
|
18
|
+
title: z.string().trim().min(1).max(200).optional(),
|
|
19
|
+
brief: z.string().max(8000).optional(), before: z.string().optional(),
|
|
20
|
+
legacy: z.object({
|
|
21
|
+
messages: z.array(SavedChatMessageSchema).max(10_000), resume: z.string().optional(),
|
|
22
|
+
sessionCheckout: z.boolean().optional(),
|
|
23
|
+
}).optional(),
|
|
24
|
+
});
|
|
25
|
+
export const WorkspaceRunSchema = z.object({
|
|
26
|
+
requestId: z.string(), prompt: z.string(),
|
|
27
|
+
handoff: z.object({ from: z.enum(['claude', 'codex']), to: z.enum(['claude', 'codex']) }).optional(),
|
|
28
|
+
frames: z.array(z.record(z.string(), z.unknown())),
|
|
29
|
+
terminated: z.boolean(),
|
|
30
|
+
});
|
|
31
|
+
export const WorkspaceSnapshotSchema = z.object({
|
|
32
|
+
workers: z.array(WorkerWorkspaceSchema),
|
|
33
|
+
checkout: z.object({
|
|
34
|
+
repoId: z.string(), conversationId: z.string(), revision: z.string(),
|
|
35
|
+
resume: z.string().optional(),
|
|
36
|
+
}).optional(),
|
|
37
|
+
runs: z.array(WorkspaceRunSchema).optional(),
|
|
38
|
+
legacyMessages: z.array(SavedChatMessageSchema).optional(),
|
|
39
|
+
nextBefore: z.string().optional(),
|
|
40
|
+
});
|
|
@@ -20,6 +20,7 @@ export interface AgentCommandOption {
|
|
|
20
20
|
argumentHint: string;
|
|
21
21
|
/** SDK commands can accept freeform arguments without publishing a hint. */
|
|
22
22
|
acceptsArguments?: boolean;
|
|
23
|
+
startsConversation?: boolean;
|
|
23
24
|
aliases?: string[];
|
|
24
25
|
clearsContext?: boolean;
|
|
25
26
|
}
|
|
@@ -8,6 +8,7 @@ export const CardIdSchema = z.enum([
|
|
|
8
8
|
'habit-contributions',
|
|
9
9
|
'focus',
|
|
10
10
|
'weekly-review',
|
|
11
|
+
'goals',
|
|
11
12
|
]);
|
|
12
13
|
export type CardId = z.infer<typeof CardIdSchema>;
|
|
13
14
|
export const CardStyleSchema = z.enum(['glance', 'act']);
|
|
@@ -19,6 +20,13 @@ export const CARD_CATALOG: {
|
|
|
19
20
|
source: string;
|
|
20
21
|
styles: boolean;
|
|
21
22
|
}[] = [
|
|
23
|
+
{
|
|
24
|
+
id: 'goals',
|
|
25
|
+
name: 'Goals',
|
|
26
|
+
description: 'Something you want to achieve, with a timeframe and quiet checks from Lucid.',
|
|
27
|
+
source: 'Linked tasks, projects, private notes and habits',
|
|
28
|
+
styles: true,
|
|
29
|
+
},
|
|
22
30
|
{
|
|
23
31
|
id: 'attention',
|
|
24
32
|
name: 'Attention',
|
|
@@ -73,9 +81,10 @@ export const CARD_CATALOG: {
|
|
|
73
81
|
export const CardPreferencesSchema = z.object({
|
|
74
82
|
order: z
|
|
75
83
|
.array(CardIdSchema)
|
|
76
|
-
.max(
|
|
84
|
+
.max(8)
|
|
77
85
|
.refine((ids) => new Set(ids).size === ids.length),
|
|
78
86
|
styles: z.object({
|
|
87
|
+
goals: CardStyleSchema.default('glance'),
|
|
79
88
|
habits: CardStyleSchema,
|
|
80
89
|
'habit-contributions': CardStyleSchema.default('glance'),
|
|
81
90
|
focus: CardStyleSchema,
|
|
@@ -88,6 +97,7 @@ export type StyledCardId = keyof CardPreferences['styles'];
|
|
|
88
97
|
export const DEFAULT_CARD_PREFERENCES: CardPreferences = {
|
|
89
98
|
order: ['attention', 'today', 'github'],
|
|
90
99
|
styles: {
|
|
100
|
+
goals: 'glance',
|
|
91
101
|
habits: 'act',
|
|
92
102
|
'habit-contributions': 'glance',
|
|
93
103
|
focus: 'act',
|
|
@@ -99,7 +109,7 @@ export const CardPreferenceChangeSchema = z.discriminatedUnion('type', [
|
|
|
99
109
|
z.object({
|
|
100
110
|
type: z.literal('add'),
|
|
101
111
|
id: CardIdSchema,
|
|
102
|
-
index: z.number().int().min(0).max(
|
|
112
|
+
index: z.number().int().min(0).max(7).optional(),
|
|
103
113
|
}),
|
|
104
114
|
z.object({ type: z.literal('remove'), id: CardIdSchema }),
|
|
105
115
|
z.object({
|
|
@@ -109,7 +119,7 @@ export const CardPreferenceChangeSchema = z.discriminatedUnion('type', [
|
|
|
109
119
|
}),
|
|
110
120
|
z.object({
|
|
111
121
|
type: z.literal('style'),
|
|
112
|
-
id: z.enum(['habits', 'habit-contributions', 'focus', 'weekly-review']),
|
|
122
|
+
id: z.enum(['habits', 'habit-contributions', 'focus', 'weekly-review', 'goals']),
|
|
113
123
|
style: CardStyleSchema,
|
|
114
124
|
}),
|
|
115
125
|
z.object({ type: z.literal('dismiss'), key: z.string().min(1).max(240) }),
|
|
@@ -37,6 +37,8 @@ export type LocalCommandStep = Extract<CommandExecutableStep, { kind: 'navigate'
|
|
|
37
37
|
*/
|
|
38
38
|
const ALIASES: Record<CommandDestination, readonly string[]> = {
|
|
39
39
|
dash: ['home', 'go home', 'main'],
|
|
40
|
+
plan: ['daily plan', 'day plan', 'plan my day'],
|
|
41
|
+
deck: ['my deck'],
|
|
40
42
|
search: ['task list', 'search'],
|
|
41
43
|
today: ['todays tasks', 'tasks for today', 'whats due today'],
|
|
42
44
|
inbox: [],
|
|
@@ -47,6 +47,8 @@ export const COMMAND_DESTINATIONS = [
|
|
|
47
47
|
{ key: 'focus', label: 'Focus', description: 'The focus timer' },
|
|
48
48
|
{ key: 'card_studio', label: 'Card Studio', description: 'Choosing the cards on the Dashboard' },
|
|
49
49
|
{ key: 'ask_lucid', label: 'Lucid', description: 'A conversation with Lucid on your computer' },
|
|
50
|
+
{ key: 'plan', label: 'My day', description: 'Plan the day and review its chosen tasks and main focus' },
|
|
51
|
+
{ key: 'deck', label: 'Deck', description: 'The cards for habits, projects and daily summaries' },
|
|
50
52
|
] as const;
|
|
51
53
|
export type CommandDestination = (typeof COMMAND_DESTINATIONS)[number]['key'];
|
|
52
54
|
/**
|
|
@@ -49,9 +49,12 @@ export const ComputerPresenceSchema = z.object({
|
|
|
49
49
|
});
|
|
50
50
|
export type ComputerPresence = z.infer<typeof ComputerPresenceSchema>;
|
|
51
51
|
export type ComputerFeature =
|
|
52
|
+
| 'checkout-history'
|
|
53
|
+
| 'workspaces'
|
|
52
54
|
| 'turn-queue'
|
|
53
55
|
| 'provider-handoff'
|
|
54
56
|
| 'queue-control'
|
|
57
|
+
| 'day-plan'
|
|
55
58
|
| 'ask'
|
|
56
59
|
| 'code'
|
|
57
60
|
| 'conduct'
|
|
@@ -93,6 +96,7 @@ export type Availability = {
|
|
|
93
96
|
};
|
|
94
97
|
export const INFERENCE_FEATURES = new Set<string>([
|
|
95
98
|
'ask',
|
|
99
|
+
'day-plan',
|
|
96
100
|
'code',
|
|
97
101
|
'conduct',
|
|
98
102
|
'briefing',
|
|
@@ -227,15 +231,27 @@ export function computerAvailability(
|
|
|
227
231
|
|
|
228
232
|
/** Session affinity can be read in RN without importing Node Buffer. Legacy IDs are Claude. */
|
|
229
233
|
export function sessionProvider(resume?: string): ComputerProvider | undefined {
|
|
234
|
+
return sessionPreferences(resume)?.provider;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** Saved overrides are needed when a conversation keeps a different provider from settings. */
|
|
238
|
+
export function sessionPreferences(resume?: string):
|
|
239
|
+
| { provider: ComputerProvider; model?: string; effort?: string }
|
|
240
|
+
| undefined {
|
|
230
241
|
if (!resume) return undefined;
|
|
231
|
-
if (!resume.startsWith('lucidity-session:')) return 'claude';
|
|
242
|
+
if (!resume.startsWith('lucidity-session:')) return { provider: 'claude' };
|
|
232
243
|
try {
|
|
233
244
|
const encoded = resume
|
|
234
245
|
.slice('lucidity-session:'.length)
|
|
235
246
|
.replace(/-/g, '+')
|
|
236
247
|
.replace(/_/g, '/');
|
|
237
248
|
const session = JSON.parse(atob(encoded));
|
|
238
|
-
|
|
249
|
+
if (session.provider !== 'codex' && session.provider !== 'claude') return undefined;
|
|
250
|
+
return {
|
|
251
|
+
provider: session.provider,
|
|
252
|
+
model: typeof session.model === 'string' ? session.model : undefined,
|
|
253
|
+
effort: typeof session.effort === 'string' ? session.effort : undefined,
|
|
254
|
+
};
|
|
239
255
|
} catch {
|
|
240
256
|
return undefined;
|
|
241
257
|
}
|
|
@@ -379,6 +379,7 @@ export function normalizeBio(input: string): string | null {
|
|
|
379
379
|
// re-fetches an interrupted turn's frames from the daemon's durable turn log
|
|
380
380
|
// (`sinceSeq` onward) so a dropped reply is recovered, never re-run.
|
|
381
381
|
export const HARNESS_REQUEST_KINDS = [
|
|
382
|
+
'workspaces',
|
|
382
383
|
'getAutomations',
|
|
383
384
|
'automation',
|
|
384
385
|
'queue-control',
|
|
@@ -429,7 +430,7 @@ export const EFFORT_LEVELS = [
|
|
|
429
430
|
export const EFFORT_OPTIONS = [
|
|
430
431
|
{
|
|
431
432
|
value: 'auto',
|
|
432
|
-
label: '
|
|
433
|
+
label: 'Automatic',
|
|
433
434
|
blurb: 'Use the model’s recommended effort',
|
|
434
435
|
},
|
|
435
436
|
{ value: 'low', label: 'Low', blurb: 'Fastest, least thorough' },
|
|
@@ -446,13 +447,13 @@ export const EFFORT_OPTIONS = [
|
|
|
446
447
|
|
|
447
448
|
/** A safe fallback when the live provider catalog is unavailable. Never guess a version. */
|
|
448
449
|
export function claudeModelLabel(alias: string): string {
|
|
449
|
-
return alias === 'default' ? '
|
|
450
|
+
return alias === 'default' ? 'Claude' : alias;
|
|
450
451
|
}
|
|
451
452
|
|
|
452
|
-
/** Friendly label for an effort level; unset
|
|
453
|
+
/** Friendly label for an effort level; unset values use automatic reasoning. */
|
|
453
454
|
export function effortLabel(value: string | null | undefined): string {
|
|
454
455
|
return (
|
|
455
|
-
EFFORT_OPTIONS.find((e) => e.value === value)?.label ?? '
|
|
456
|
+
EFFORT_OPTIONS.find((e) => e.value === value)?.label ?? 'Automatic'
|
|
456
457
|
);
|
|
457
458
|
}
|
|
458
459
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const PlanDateSchema = z.iso.date();
|
|
4
|
+
export const PlanTimeZoneSchema = z.string().min(1).max(100).refine((zone) => {
|
|
5
|
+
try { new Intl.DateTimeFormat('en', { timeZone: zone }); return true; } catch { return false; }
|
|
6
|
+
}, 'Choose a valid time zone.');
|
|
7
|
+
|
|
8
|
+
export const PlanTaskLinkSchema = z.object({
|
|
9
|
+
kind: z.literal('task'),
|
|
10
|
+
taskId: z.uuid(),
|
|
11
|
+
occurrenceId: z.uuid().nullable(),
|
|
12
|
+
focus: z.boolean(),
|
|
13
|
+
});
|
|
14
|
+
export const PlanNewTaskSchema = z.object({
|
|
15
|
+
kind: z.literal('new'),
|
|
16
|
+
taskId: z.uuidv7(),
|
|
17
|
+
title: z.string().trim().min(1).max(500),
|
|
18
|
+
focus: z.boolean(),
|
|
19
|
+
});
|
|
20
|
+
export const PlanInputItemSchema = z.discriminatedUnion('kind', [PlanTaskLinkSchema, PlanNewTaskSchema]);
|
|
21
|
+
export const SaveDayPlanSchema = z.object({
|
|
22
|
+
timeZone: PlanTimeZoneSchema,
|
|
23
|
+
revision: z.number().int().min(0),
|
|
24
|
+
mutationId: z.uuidv7(),
|
|
25
|
+
items: z.array(PlanInputItemSchema).max(30),
|
|
26
|
+
}).superRefine(({ items }, context) => {
|
|
27
|
+
if (items.filter((item) => item.focus).length > 1)
|
|
28
|
+
context.addIssue({ code: 'custom', message: 'Choose one main focus.', path: ['items'] });
|
|
29
|
+
const links = items.map((item) => `${item.taskId}:${item.kind === 'task' ? item.occurrenceId ?? '' : ''}`);
|
|
30
|
+
if (new Set(links).size !== links.length)
|
|
31
|
+
context.addIssue({ code: 'custom', message: 'A task can appear only once in a plan.', path: ['items'] });
|
|
32
|
+
const newIds = items.filter((item) => item.kind === 'new').map((item) => item.taskId);
|
|
33
|
+
if (newIds.some((id) => items.filter((item) => item.taskId === id).length > 1))
|
|
34
|
+
context.addIssue({ code: 'custom', message: 'New tasks need separate identities.', path: ['items'] });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export type PlanTaskLink = z.infer<typeof PlanTaskLinkSchema>;
|
|
38
|
+
export type PlanInputItem = z.infer<typeof PlanInputItemSchema>;
|
|
39
|
+
export type SaveDayPlan = z.infer<typeof SaveDayPlanSchema>;
|
|
40
|
+
|
|
41
|
+
/** A task becoming private or deleted leaves a placeholder, never a cached title. */
|
|
42
|
+
export interface PlanTask {
|
|
43
|
+
id: string;
|
|
44
|
+
title: string;
|
|
45
|
+
projectName: string | null;
|
|
46
|
+
projectKey: string | null;
|
|
47
|
+
taskNumber: number | null;
|
|
48
|
+
occurrenceId: string | null;
|
|
49
|
+
completed: boolean;
|
|
50
|
+
canComplete: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface DayPlanItem extends PlanTaskLink { task: PlanTask | null }
|
|
53
|
+
export interface DayPlan {
|
|
54
|
+
date: string;
|
|
55
|
+
timeZone: string;
|
|
56
|
+
revision: number;
|
|
57
|
+
updatedAt: string;
|
|
58
|
+
items: DayPlanItem[];
|
|
59
|
+
}
|
|
60
|
+
export interface DayPlanResponse { plan: DayPlan | null; previous: DayPlan | null }
|
|
61
|
+
|
|
62
|
+
export const InterpretDayPlanSchema = z.object({ text: z.string().trim().min(1).max(4000) });
|
|
63
|
+
export interface PlanSuggestion {
|
|
64
|
+
words: string;
|
|
65
|
+
title: string;
|
|
66
|
+
task: PlanTask | null;
|
|
67
|
+
focus: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface PlanInterpretation {
|
|
70
|
+
suggestions: PlanSuggestion[];
|
|
71
|
+
unresolved: string[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function localPlanDate(now: Date, timeZone: string): string {
|
|
75
|
+
const parts = new Intl.DateTimeFormat('en', { timeZone, year: 'numeric', month: '2-digit', day: '2-digit' }).formatToParts(now);
|
|
76
|
+
const value = (name: string) => parts.find((part) => part.type === name)!.value;
|
|
77
|
+
return `${value('year')}-${value('month')}-${value('day')}`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const planItemKey = (item: Pick<PlanTaskLink, 'taskId' | 'occurrenceId'>): string =>
|
|
81
|
+
`${item.taskId}:${item.occurrenceId ?? ''}`;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const words = z.string().trim().min(1).max(4000);
|
|
4
|
+
const title = z.string().trim().min(1).max(300);
|
|
5
|
+
export const DayPlanningProjectSchema = z.object({
|
|
6
|
+
id: z.uuid(), name: z.string().max(255), key: z.string().nullable(),
|
|
7
|
+
});
|
|
8
|
+
export const DayPlanningActionSchema = z.strictObject({
|
|
9
|
+
words, title, projectId: z.uuid().nullable(),
|
|
10
|
+
taskNumber: z.number().int().positive().nullable(), focus: z.boolean(),
|
|
11
|
+
});
|
|
12
|
+
export const DayPlanningExtractionSchema = z.strictObject({
|
|
13
|
+
actions: z.array(DayPlanningActionSchema).max(30),
|
|
14
|
+
questions: z.array(z.strictObject({ words, question: title })).max(12),
|
|
15
|
+
});
|
|
16
|
+
export const DayPlanningCandidateSchema = z.object({
|
|
17
|
+
id: z.uuid(), title: z.string().max(500), projectId: z.uuid().nullable(),
|
|
18
|
+
projectName: z.string().nullable(), taskNumber: z.number().int().nullable(),
|
|
19
|
+
});
|
|
20
|
+
export const DayPlanningMatchesSchema = z.strictObject({
|
|
21
|
+
matches: z.array(z.strictObject({
|
|
22
|
+
actionIndex: z.number().int().min(0).max(29),
|
|
23
|
+
taskId: z.uuid().nullable(), question: title.nullable(),
|
|
24
|
+
})).max(30),
|
|
25
|
+
});
|
|
26
|
+
export const DayPlanningContextSchema = z.discriminatedUnion('phase', [
|
|
27
|
+
z.object({ phase: z.literal('extract'), projects: z.array(DayPlanningProjectSchema).max(200) }),
|
|
28
|
+
z.object({ phase: z.literal('match'), actions: z.array(DayPlanningActionSchema).max(30),
|
|
29
|
+
candidates: z.array(z.object({ actionIndex: z.number().int().min(0).max(29),
|
|
30
|
+
tasks: z.array(DayPlanningCandidateSchema).max(10) })).max(30) }),
|
|
31
|
+
]);
|
|
32
|
+
export const DayPlanningReviewSchema = z.object({
|
|
33
|
+
text: words, extraction: DayPlanningExtractionSchema, matching: DayPlanningMatchesSchema,
|
|
34
|
+
});
|
|
35
|
+
export type DayPlanningAction = z.infer<typeof DayPlanningActionSchema>;
|
|
36
|
+
export type DayPlanningExtraction = z.infer<typeof DayPlanningExtractionSchema>;
|
|
37
|
+
export type DayPlanningMatches = z.infer<typeof DayPlanningMatchesSchema>;
|
|
38
|
+
export type DayPlanningContext = z.infer<typeof DayPlanningContextSchema>;
|
|
39
|
+
export type DayPlanningProject = z.infer<typeof DayPlanningProjectSchema>;
|
|
40
|
+
export type DayPlanningCandidate = z.infer<typeof DayPlanningCandidateSchema>;
|
|
41
|
+
export type DayPlanningReview = z.infer<typeof DayPlanningReviewSchema>;
|
|
42
|
+
|
|
43
|
+
export const dayPlanningOutputSchema = (phase: DayPlanningContext['phase']) =>
|
|
44
|
+
z.toJSONSchema(phase === 'extract' ? DayPlanningExtractionSchema : DayPlanningMatchesSchema, { target: 'draft-7' });
|
|
45
|
+
|
|
46
|
+
const normalized = (value: string) => value.toLowerCase().replace(/\s+/g, ' ').trim();
|
|
47
|
+
export function validateDayPlanningExtraction(text: string, result: DayPlanningExtraction, projects: DayPlanningProject[]) {
|
|
48
|
+
if (result.actions.filter((action) => action.focus).length > 1)
|
|
49
|
+
throw new Error('The plan needs one main focus. Please review again.');
|
|
50
|
+
for (const item of [...result.actions, ...result.questions]) {
|
|
51
|
+
if (!normalized(text).includes(normalized(item.words)))
|
|
52
|
+
throw new Error('The plan could not be checked against your words. Please review again.');
|
|
53
|
+
}
|
|
54
|
+
for (const action of result.actions) {
|
|
55
|
+
if (/^(?:and|i|then|also|so|but|today|okay|ok)[.!?]*$/i.test(action.title) ||
|
|
56
|
+
!/\p{L}/u.test(action.title))
|
|
57
|
+
throw new Error('The plan contains an unfinished thought. Please review again.');
|
|
58
|
+
if (action.projectId && !projects.some((project) => project.id === action.projectId))
|
|
59
|
+
throw new Error('A project in this plan is unavailable. Please review again.');
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
export function validateDayPlanningMatches(context: Extract<DayPlanningContext, { phase: 'match' }>, result: DayPlanningMatches) {
|
|
64
|
+
const indexes = result.matches.map((match) => match.actionIndex);
|
|
65
|
+
if (indexes.length !== context.actions.length || new Set(indexes).size !== indexes.length ||
|
|
66
|
+
indexes.some((index) => !context.actions[index]))
|
|
67
|
+
throw new Error('The task matches are incomplete. Please review again.');
|
|
68
|
+
for (const match of result.matches) {
|
|
69
|
+
if (!match.taskId) continue;
|
|
70
|
+
const action = context.actions[match.actionIndex]!;
|
|
71
|
+
const task = context.candidates.find((group) => group.actionIndex === match.actionIndex)?.tasks.find((item) => item.id === match.taskId);
|
|
72
|
+
if (!task || (action.projectId && action.projectId !== task.projectId) ||
|
|
73
|
+
(action.taskNumber !== null && (!action.projectId || action.taskNumber !== task.taskNumber)) || match.question)
|
|
74
|
+
throw new Error('A suggested task could not be verified. Please review again.');
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { parseFrontmatter } from './notes.js';
|
|
3
|
+
|
|
4
|
+
/** The UUID travels with the note when it is renamed or moved in the private vault. */
|
|
5
|
+
export function goalNoteId(content: string): string | null {
|
|
6
|
+
const parsed = z.uuid().safeParse(parseFrontmatter(content).data.lucidity_id);
|
|
7
|
+
return parsed.success ? parsed.data : null;
|
|
8
|
+
}
|
|
9
|
+
export function withGoalNoteId(content: string, id: string): string {
|
|
10
|
+
z.uuid().parse(id);
|
|
11
|
+
const existing = goalNoteId(content);
|
|
12
|
+
if (existing) {
|
|
13
|
+
if (existing !== id) throw new Error('This note already has a different identity. Reload it.');
|
|
14
|
+
return content;
|
|
15
|
+
}
|
|
16
|
+
if (content.startsWith('---')) {
|
|
17
|
+
const open = /^---[ \t]*\r?\n/.exec(content);
|
|
18
|
+
if (!open || !/^---[ \t]*(?:\r?\n|$)/m.test(content.slice(open[0].length)) || /^lucidity_id\s*:/m.test(content))
|
|
19
|
+
throw new Error('Fix the note’s frontmatter before linking it.');
|
|
20
|
+
return open[0] + `lucidity_id: ${id}\n` + content.slice(open[0].length);
|
|
21
|
+
}
|
|
22
|
+
return `---\nlucidity_id: ${id}\n---\n${content}`;
|
|
23
|
+
}
|