@lukstei/dsh-schedule-script 0.0.0-stage → 0.2.2-rc.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +203 -2
- package/cordis.patch.yml +4 -0
- package/dist/client.js +848 -0
- package/dist/index.js +826 -0
- package/package.json +103 -3
- package/src/client.tsx +717 -0
- package/src/executor.ts +101 -0
- package/src/fold.ts +154 -0
- package/src/index.ts +616 -0
- package/src/parser.ts +138 -0
- package/src/runner-cli.ts +81 -0
- package/src/skill.ts +120 -0
- package/src/styles.ts +333 -0
- package/src/types.ts +132 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type {} from "@deepseek-ai/dsh-session-projection";
|
|
2
|
+
import type {} from "@deepseek-ai/dsh-session-projection/types";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
export const SCHEDULE_SCRIPT_KIND = "dsh-schedule-script" as const;
|
|
6
|
+
export const SCHEDULE_SCRIPT_EVENT_NAME = "dsh-schedule-script" as const;
|
|
7
|
+
|
|
8
|
+
export interface ScriptContext<TState = unknown> {
|
|
9
|
+
state: TState;
|
|
10
|
+
sessionId: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ScriptResult<TState = unknown> {
|
|
14
|
+
state: TState;
|
|
15
|
+
/** If set, awakens the agent and passes this prompt to the model */
|
|
16
|
+
prompt?: string;
|
|
17
|
+
/** Recoverable error; surfaces in UI row without stopping or prompting LLM */
|
|
18
|
+
error?: string;
|
|
19
|
+
/** Explicitly stop further recurrences */
|
|
20
|
+
stop?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type BackgroundScriptMain<TState = unknown> = (
|
|
24
|
+
ctx: ScriptContext<TState>,
|
|
25
|
+
) => Promise<ScriptResult<TState>> | ScriptResult<TState>;
|
|
26
|
+
|
|
27
|
+
export interface ScheduleScriptPromptPayload {
|
|
28
|
+
readonly kind: typeof SCHEDULE_SCRIPT_KIND;
|
|
29
|
+
readonly scriptPath: string;
|
|
30
|
+
readonly state: unknown;
|
|
31
|
+
readonly timeoutMs?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type ScheduleScriptEventPayload =
|
|
35
|
+
| {
|
|
36
|
+
readonly action: "skill";
|
|
37
|
+
readonly timestamp: number;
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
readonly action: "start";
|
|
41
|
+
readonly scriptPath: string;
|
|
42
|
+
readonly state: unknown;
|
|
43
|
+
readonly timestamp: number;
|
|
44
|
+
}
|
|
45
|
+
| {
|
|
46
|
+
readonly action: "iteration";
|
|
47
|
+
readonly scheduleId?: string;
|
|
48
|
+
readonly scriptPath: string;
|
|
49
|
+
readonly iteration: number;
|
|
50
|
+
readonly state: unknown;
|
|
51
|
+
readonly durationMs: number;
|
|
52
|
+
readonly timestamp: number;
|
|
53
|
+
readonly prompt?: string;
|
|
54
|
+
readonly error?: string;
|
|
55
|
+
}
|
|
56
|
+
| {
|
|
57
|
+
readonly action: "error";
|
|
58
|
+
readonly scheduleId?: string;
|
|
59
|
+
readonly scriptPath: string;
|
|
60
|
+
readonly iteration: number;
|
|
61
|
+
readonly error: string;
|
|
62
|
+
readonly timestamp: number;
|
|
63
|
+
readonly fatal?: boolean;
|
|
64
|
+
}
|
|
65
|
+
| {
|
|
66
|
+
readonly action: "stop";
|
|
67
|
+
readonly scheduleId?: string;
|
|
68
|
+
readonly reason: string;
|
|
69
|
+
readonly timestamp: number;
|
|
70
|
+
}
|
|
71
|
+
| {
|
|
72
|
+
readonly action: "cleanup";
|
|
73
|
+
readonly error?: string;
|
|
74
|
+
readonly timestamp: number;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const scriptExecutionStatusSchema = z.enum([
|
|
78
|
+
"idle",
|
|
79
|
+
"running",
|
|
80
|
+
"warning",
|
|
81
|
+
"error",
|
|
82
|
+
"stopped",
|
|
83
|
+
]);
|
|
84
|
+
export type ScriptExecutionStatus = z.infer<typeof scriptExecutionStatusSchema>;
|
|
85
|
+
|
|
86
|
+
export const scheduleSystemStatusSchema = z.enum([
|
|
87
|
+
"active",
|
|
88
|
+
"paused",
|
|
89
|
+
"ended",
|
|
90
|
+
"deleted",
|
|
91
|
+
]);
|
|
92
|
+
export type ScheduleSystemStatus = z.infer<typeof scheduleSystemStatusSchema>;
|
|
93
|
+
|
|
94
|
+
export const scheduleScriptSummarySchema = z.object({
|
|
95
|
+
scriptStatus: scriptExecutionStatusSchema,
|
|
96
|
+
skillInvoked: z.boolean().optional(),
|
|
97
|
+
scheduleId: z.string().optional(),
|
|
98
|
+
cleanupPending: z.boolean().optional(),
|
|
99
|
+
cleanupError: z.string().optional(),
|
|
100
|
+
scriptPath: z.string().optional(),
|
|
101
|
+
totalRuns: z.number(),
|
|
102
|
+
lastRunAt: z.number().optional(),
|
|
103
|
+
lastDurationMs: z.number().optional(),
|
|
104
|
+
state: z.unknown().optional(),
|
|
105
|
+
lastPrompt: z
|
|
106
|
+
.object({
|
|
107
|
+
message: z.string(),
|
|
108
|
+
timestamp: z.number(),
|
|
109
|
+
})
|
|
110
|
+
.optional(),
|
|
111
|
+
lastError: z
|
|
112
|
+
.object({
|
|
113
|
+
message: z.string(),
|
|
114
|
+
timestamp: z.number(),
|
|
115
|
+
fatal: z.boolean().default(false),
|
|
116
|
+
})
|
|
117
|
+
.optional(),
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
export type ScheduleScriptSummary = z.infer<typeof scheduleScriptSummarySchema>;
|
|
121
|
+
|
|
122
|
+
declare module "@deepseek-ai/dsh-session-projection/types" {
|
|
123
|
+
interface SessionProjectionMap {
|
|
124
|
+
dshScheduleScript: ScheduleScriptSummary | null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
declare module "@deepseek-ai/dsh-session-projection" {
|
|
129
|
+
interface SessionProjectionMap {
|
|
130
|
+
dshScheduleScript: ScheduleScriptSummary | null;
|
|
131
|
+
}
|
|
132
|
+
}
|