bylua-lspec-subagents 1.0.2
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/CHANGELOG.md +482 -0
- package/LICENSE +21 -0
- package/README.md +123 -0
- package/dist/agent-manager.d.ts +108 -0
- package/dist/agent-manager.js +391 -0
- package/dist/agent-runner.d.ts +95 -0
- package/dist/agent-runner.js +377 -0
- package/dist/agent-types.d.ts +58 -0
- package/dist/agent-types.js +157 -0
- package/dist/context.d.ts +12 -0
- package/dist/context.js +56 -0
- package/dist/cross-extension-rpc.d.ts +46 -0
- package/dist/cross-extension-rpc.js +76 -0
- package/dist/custom-agents.d.ts +14 -0
- package/dist/custom-agents.js +127 -0
- package/dist/default-agents.d.ts +12 -0
- package/dist/default-agents.js +489 -0
- package/dist/env.d.ts +6 -0
- package/dist/env.js +28 -0
- package/dist/group-join.d.ts +32 -0
- package/dist/group-join.js +116 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1863 -0
- package/dist/invocation-config.d.ts +22 -0
- package/dist/invocation-config.js +15 -0
- package/dist/memory.d.ts +49 -0
- package/dist/memory.js +151 -0
- package/dist/model-config-loader.d.ts +58 -0
- package/dist/model-config-loader.js +157 -0
- package/dist/model-resolver.d.ts +19 -0
- package/dist/model-resolver.js +62 -0
- package/dist/output-file.d.ts +24 -0
- package/dist/output-file.js +86 -0
- package/dist/prompts.d.ts +29 -0
- package/dist/prompts.js +65 -0
- package/dist/schedule-store.d.ts +38 -0
- package/dist/schedule-store.js +155 -0
- package/dist/schedule.d.ts +109 -0
- package/dist/schedule.js +338 -0
- package/dist/settings.d.ts +66 -0
- package/dist/settings.js +130 -0
- package/dist/skill-loader.d.ts +24 -0
- package/dist/skill-loader.js +93 -0
- package/dist/types.d.ts +164 -0
- package/dist/types.js +8 -0
- package/dist/ui/agent-widget.d.ts +134 -0
- package/dist/ui/agent-widget.js +451 -0
- package/dist/ui/conversation-viewer.d.ts +35 -0
- package/dist/ui/conversation-viewer.js +252 -0
- package/dist/ui/schedule-menu.d.ts +16 -0
- package/dist/ui/schedule-menu.js +95 -0
- package/dist/usage.d.ts +50 -0
- package/dist/usage.js +49 -0
- package/dist/worktree.d.ts +36 -0
- package/dist/worktree.js +139 -0
- package/install.sh +77 -0
- package/lspec-model-config.example.json +17 -0
- package/package.json +50 -0
- package/src/agent-manager.ts +483 -0
- package/src/agent-runner.ts +486 -0
- package/src/agent-types.ts +188 -0
- package/src/context.ts +58 -0
- package/src/cross-extension-rpc.ts +122 -0
- package/src/custom-agents.ts +136 -0
- package/src/default-agents.ts +501 -0
- package/src/env.ts +33 -0
- package/src/group-join.ts +141 -0
- package/src/index.ts +2032 -0
- package/src/invocation-config.ts +40 -0
- package/src/memory.ts +165 -0
- package/src/model-config-loader.ts +193 -0
- package/src/model-resolver.ts +81 -0
- package/src/output-file.ts +96 -0
- package/src/prompts.ts +91 -0
- package/src/schedule-store.ts +153 -0
- package/src/schedule.ts +365 -0
- package/src/settings.ts +186 -0
- package/src/skill-loader.ts +102 -0
- package/src/types.ts +179 -0
- package/src/ui/agent-widget.ts +533 -0
- package/src/ui/conversation-viewer.ts +261 -0
- package/src/ui/schedule-menu.ts +104 -0
- package/src/usage.ts +60 -0
- package/src/worktree.ts +162 -0
- package/uninstall.sh +55 -0
- package/update.sh +64 -0
package/dist/prompts.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* prompts.ts — System prompt builder for agents.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Build the system prompt for an agent from its config.
|
|
6
|
+
*
|
|
7
|
+
* - "replace" mode: env header + config.systemPrompt (full control, no parent identity)
|
|
8
|
+
* - "append" mode: env header + parent system prompt + sub-agent context + config.systemPrompt
|
|
9
|
+
* - "append" with empty systemPrompt: pure parent clone
|
|
10
|
+
*
|
|
11
|
+
* Both modes prepend an `<active_agent name="${config.name}"/>` tag so downstream
|
|
12
|
+
* extensions (e.g. permission/policy systems) can resolve per-agent policy
|
|
13
|
+
* inside the child session by parsing the system prompt.
|
|
14
|
+
*
|
|
15
|
+
* @param parentSystemPrompt The parent agent's effective system prompt (for append mode).
|
|
16
|
+
* @param extras Optional extra sections to inject (memory, preloaded skills).
|
|
17
|
+
*/
|
|
18
|
+
export function buildAgentPrompt(config, cwd, env, parentSystemPrompt, extras) {
|
|
19
|
+
const activeAgentTag = `<active_agent name="${config.name}"/>\n\n`;
|
|
20
|
+
const envBlock = `# Environment
|
|
21
|
+
Working directory: ${cwd}
|
|
22
|
+
${env.isGitRepo ? `Git repository: yes\nBranch: ${env.branch}` : "Not a git repository"}
|
|
23
|
+
Platform: ${env.platform}`;
|
|
24
|
+
// Build optional extras suffix
|
|
25
|
+
const extraSections = [];
|
|
26
|
+
if (extras?.memoryBlock) {
|
|
27
|
+
extraSections.push(extras.memoryBlock);
|
|
28
|
+
}
|
|
29
|
+
if (extras?.skillBlocks?.length) {
|
|
30
|
+
for (const skill of extras.skillBlocks) {
|
|
31
|
+
extraSections.push(`\n# Preloaded Skill: ${skill.name}\n${skill.content}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const extrasSuffix = extraSections.length > 0 ? "\n\n" + extraSections.join("\n") : "";
|
|
35
|
+
if (config.promptMode === "append") {
|
|
36
|
+
const identity = parentSystemPrompt || genericBase;
|
|
37
|
+
const bridge = `<sub_agent_context>
|
|
38
|
+
You are operating as a sub-agent invoked to handle a specific task.
|
|
39
|
+
- Use the read tool instead of cat/head/tail
|
|
40
|
+
- Use the edit tool instead of sed/awk
|
|
41
|
+
- Use the write tool instead of echo/heredoc
|
|
42
|
+
- Use the find tool instead of bash find/ls for file search
|
|
43
|
+
- Use the grep tool instead of bash grep/rg for content search
|
|
44
|
+
- Make independent tool calls in parallel
|
|
45
|
+
- Use absolute file paths
|
|
46
|
+
- Do not use emojis
|
|
47
|
+
- Be concise but complete
|
|
48
|
+
</sub_agent_context>`;
|
|
49
|
+
const customSection = config.systemPrompt?.trim()
|
|
50
|
+
? `\n\n<agent_instructions>\n${config.systemPrompt}\n</agent_instructions>`
|
|
51
|
+
: "";
|
|
52
|
+
return activeAgentTag + envBlock + "\n\n<inherited_system_prompt>\n" + identity + "\n</inherited_system_prompt>\n\n" + bridge + customSection + extrasSuffix;
|
|
53
|
+
}
|
|
54
|
+
// "replace" mode — env header + the config's full system prompt
|
|
55
|
+
const replaceHeader = `You are a pi coding agent sub-agent.
|
|
56
|
+
You have been invoked to handle a specific task autonomously.
|
|
57
|
+
|
|
58
|
+
${envBlock}`;
|
|
59
|
+
return activeAgentTag + replaceHeader + "\n\n" + config.systemPrompt + extrasSuffix;
|
|
60
|
+
}
|
|
61
|
+
/** Fallback base prompt when parent system prompt is unavailable in append mode. */
|
|
62
|
+
const genericBase = `# Role
|
|
63
|
+
You are a coding agent for complex, multi-step tasks.
|
|
64
|
+
You have full access to read, write, edit files, and execute commands.
|
|
65
|
+
Do what has been asked; nothing more, nothing less.`;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* schedule-store.ts — File-backed store for scheduled subagents.
|
|
3
|
+
*
|
|
4
|
+
* Session-scoped: each pi session owns its own schedules at
|
|
5
|
+
* `<cwd>/.pi/subagent-schedules/<sessionId>.json`. `/new` starts a fresh
|
|
6
|
+
* empty store; `/resume` reloads.
|
|
7
|
+
*
|
|
8
|
+
* Concurrency model lifted from pi-chonky-tasks/src/task-store.ts: every
|
|
9
|
+
* mutation acquires a PID-based exclusion lock, re-reads the latest state
|
|
10
|
+
* from disk, applies the change, atomic-writes via temp+rename, releases.
|
|
11
|
+
*/
|
|
12
|
+
import type { ScheduledSubagent } from "./types.js";
|
|
13
|
+
/** Resolve the storage path for a session-scoped store. */
|
|
14
|
+
export declare function resolveStorePath(cwd: string, sessionId: string): string;
|
|
15
|
+
export declare class ScheduleStore {
|
|
16
|
+
private filePath;
|
|
17
|
+
private lockPath;
|
|
18
|
+
private jobs;
|
|
19
|
+
constructor(filePath: string);
|
|
20
|
+
/** Create the backing directory lazily — only when we're about to persist. */
|
|
21
|
+
private ensureDir;
|
|
22
|
+
/** Load from disk into the in-memory cache. Silent on parse errors. */
|
|
23
|
+
private load;
|
|
24
|
+
/** Atomic write via temp file + rename (POSIX-atomic). */
|
|
25
|
+
private save;
|
|
26
|
+
/** Acquire lock → reload → mutate → save → release. */
|
|
27
|
+
private withLock;
|
|
28
|
+
/** Read-only — returns a snapshot of the in-memory cache. */
|
|
29
|
+
list(): ScheduledSubagent[];
|
|
30
|
+
/** Read-only check — uses the cache. */
|
|
31
|
+
hasName(name: string, exceptId?: string): boolean;
|
|
32
|
+
get(id: string): ScheduledSubagent | undefined;
|
|
33
|
+
add(job: ScheduledSubagent): void;
|
|
34
|
+
update(id: string, patch: Partial<ScheduledSubagent>): ScheduledSubagent | undefined;
|
|
35
|
+
remove(id: string): boolean;
|
|
36
|
+
/** Delete the backing file (used when no jobs remain, optional cleanup). */
|
|
37
|
+
deleteFileIfEmpty(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* schedule-store.ts — File-backed store for scheduled subagents.
|
|
3
|
+
*
|
|
4
|
+
* Session-scoped: each pi session owns its own schedules at
|
|
5
|
+
* `<cwd>/.pi/subagent-schedules/<sessionId>.json`. `/new` starts a fresh
|
|
6
|
+
* empty store; `/resume` reloads.
|
|
7
|
+
*
|
|
8
|
+
* Concurrency model lifted from pi-chonky-tasks/src/task-store.ts: every
|
|
9
|
+
* mutation acquires a PID-based exclusion lock, re-reads the latest state
|
|
10
|
+
* from disk, applies the change, atomic-writes via temp+rename, releases.
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
14
|
+
const LOCK_RETRY_MS = 50;
|
|
15
|
+
const LOCK_MAX_RETRIES = 100;
|
|
16
|
+
function isProcessRunning(pid) {
|
|
17
|
+
try {
|
|
18
|
+
process.kill(pid, 0);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function acquireLock(lockPath) {
|
|
26
|
+
for (let i = 0; i < LOCK_MAX_RETRIES; i++) {
|
|
27
|
+
try {
|
|
28
|
+
writeFileSync(lockPath, `${process.pid}`, { flag: "wx" });
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
if (e.code === "EEXIST") {
|
|
33
|
+
try {
|
|
34
|
+
const pid = parseInt(readFileSync(lockPath, "utf-8"), 10);
|
|
35
|
+
if (pid && !isProcessRunning(pid)) {
|
|
36
|
+
unlinkSync(lockPath);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch { /* ignore — try again */ }
|
|
41
|
+
const start = Date.now();
|
|
42
|
+
while (Date.now() - start < LOCK_RETRY_MS) { /* busy wait */ }
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`Failed to acquire schedule lock: ${lockPath}`);
|
|
49
|
+
}
|
|
50
|
+
function releaseLock(lockPath) {
|
|
51
|
+
try {
|
|
52
|
+
unlinkSync(lockPath);
|
|
53
|
+
}
|
|
54
|
+
catch { /* ignore */ }
|
|
55
|
+
}
|
|
56
|
+
/** Resolve the storage path for a session-scoped store. */
|
|
57
|
+
export function resolveStorePath(cwd, sessionId) {
|
|
58
|
+
return join(cwd, ".pi", "subagent-schedules", `${sessionId}.json`);
|
|
59
|
+
}
|
|
60
|
+
export class ScheduleStore {
|
|
61
|
+
filePath;
|
|
62
|
+
lockPath;
|
|
63
|
+
jobs = new Map();
|
|
64
|
+
constructor(filePath) {
|
|
65
|
+
this.filePath = filePath;
|
|
66
|
+
this.lockPath = filePath + ".lock";
|
|
67
|
+
this.load();
|
|
68
|
+
}
|
|
69
|
+
/** Create the backing directory lazily — only when we're about to persist. */
|
|
70
|
+
ensureDir() {
|
|
71
|
+
mkdirSync(dirname(this.filePath), { recursive: true });
|
|
72
|
+
}
|
|
73
|
+
/** Load from disk into the in-memory cache. Silent on parse errors. */
|
|
74
|
+
load() {
|
|
75
|
+
if (!existsSync(this.filePath))
|
|
76
|
+
return;
|
|
77
|
+
try {
|
|
78
|
+
const data = JSON.parse(readFileSync(this.filePath, "utf-8"));
|
|
79
|
+
this.jobs.clear();
|
|
80
|
+
for (const j of data.jobs ?? [])
|
|
81
|
+
this.jobs.set(j.id, j);
|
|
82
|
+
}
|
|
83
|
+
catch { /* corrupt — start fresh, next save rewrites */ }
|
|
84
|
+
}
|
|
85
|
+
/** Atomic write via temp file + rename (POSIX-atomic). */
|
|
86
|
+
save() {
|
|
87
|
+
const data = { version: 1, jobs: [...this.jobs.values()] };
|
|
88
|
+
const tmp = this.filePath + ".tmp";
|
|
89
|
+
writeFileSync(tmp, JSON.stringify(data, null, 2));
|
|
90
|
+
renameSync(tmp, this.filePath);
|
|
91
|
+
}
|
|
92
|
+
/** Acquire lock → reload → mutate → save → release. */
|
|
93
|
+
withLock(fn) {
|
|
94
|
+
this.ensureDir();
|
|
95
|
+
acquireLock(this.lockPath);
|
|
96
|
+
try {
|
|
97
|
+
this.load();
|
|
98
|
+
const result = fn();
|
|
99
|
+
this.save();
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
releaseLock(this.lockPath);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** Read-only — returns a snapshot of the in-memory cache. */
|
|
107
|
+
list() {
|
|
108
|
+
return [...this.jobs.values()];
|
|
109
|
+
}
|
|
110
|
+
/** Read-only check — uses the cache. */
|
|
111
|
+
hasName(name, exceptId) {
|
|
112
|
+
for (const j of this.jobs.values()) {
|
|
113
|
+
if (j.id !== exceptId && j.name === name)
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
get(id) {
|
|
119
|
+
return this.jobs.get(id);
|
|
120
|
+
}
|
|
121
|
+
add(job) {
|
|
122
|
+
this.withLock(() => {
|
|
123
|
+
this.jobs.set(job.id, job);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
update(id, patch) {
|
|
127
|
+
// No-op fast path — an unknown id changes nothing, so don't lock or touch
|
|
128
|
+
// disk (which would otherwise lazily create the backing directory).
|
|
129
|
+
if (!this.jobs.has(id))
|
|
130
|
+
return undefined;
|
|
131
|
+
return this.withLock(() => {
|
|
132
|
+
const existing = this.jobs.get(id);
|
|
133
|
+
if (!existing)
|
|
134
|
+
return undefined;
|
|
135
|
+
const updated = { ...existing, ...patch };
|
|
136
|
+
this.jobs.set(id, updated);
|
|
137
|
+
return updated;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
remove(id) {
|
|
141
|
+
// No-op fast path — see update().
|
|
142
|
+
if (!this.jobs.has(id))
|
|
143
|
+
return false;
|
|
144
|
+
return this.withLock(() => this.jobs.delete(id));
|
|
145
|
+
}
|
|
146
|
+
/** Delete the backing file (used when no jobs remain, optional cleanup). */
|
|
147
|
+
deleteFileIfEmpty() {
|
|
148
|
+
if (this.jobs.size === 0 && existsSync(this.filePath)) {
|
|
149
|
+
try {
|
|
150
|
+
unlinkSync(this.filePath);
|
|
151
|
+
}
|
|
152
|
+
catch { /* ignore */ }
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* schedule.ts — `SubagentScheduler`: timer-driven dispatcher of scheduled subagents.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the engine shape of pi-cron-schedule/src/scheduler.ts:
|
|
5
|
+
* - two-Map split (jobs = croner Cron, intervals = setInterval/setTimeout)
|
|
6
|
+
* - addJob/removeJob/updateJob/scheduleJob/unscheduleJob/executeJob
|
|
7
|
+
* - static parsers for cron / "+10m" / "5m" / ISO formats
|
|
8
|
+
*
|
|
9
|
+
* Differences vs pi-cron-schedule:
|
|
10
|
+
* - Persistence is via ScheduleStore (PID-locked, session-scoped, atomic).
|
|
11
|
+
* - `executeJob` calls `manager.spawn(..., { bypassQueue: true })` instead
|
|
12
|
+
* of dispatching a user message — schedule fires bypass maxConcurrent so
|
|
13
|
+
* a 5-minute interval can't be deferred behind 4 long-running agents.
|
|
14
|
+
* - Result delivery is implicit: spawn → background completion → existing
|
|
15
|
+
* `subagent-notification` followUp path. No new delivery code.
|
|
16
|
+
*/
|
|
17
|
+
import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
|
|
18
|
+
import type { AgentManager } from "./agent-manager.js";
|
|
19
|
+
import type { ScheduleStore } from "./schedule-store.js";
|
|
20
|
+
import type { IsolationMode, ScheduledSubagent, SubagentType, ThinkingLevel } from "./types.js";
|
|
21
|
+
/** Event emitted on `pi.events` for cross-extension consumers. */
|
|
22
|
+
export type ScheduleChangeEvent = {
|
|
23
|
+
type: "added";
|
|
24
|
+
job: ScheduledSubagent;
|
|
25
|
+
} | {
|
|
26
|
+
type: "removed";
|
|
27
|
+
jobId: string;
|
|
28
|
+
} | {
|
|
29
|
+
type: "updated";
|
|
30
|
+
job: ScheduledSubagent;
|
|
31
|
+
} | {
|
|
32
|
+
type: "fired";
|
|
33
|
+
jobId: string;
|
|
34
|
+
agentId: string;
|
|
35
|
+
name: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: "error";
|
|
38
|
+
jobId: string;
|
|
39
|
+
error: string;
|
|
40
|
+
};
|
|
41
|
+
/** Params accepted at job creation — ID, timestamps, and state are derived. */
|
|
42
|
+
export interface NewJobInput {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
schedule: string;
|
|
46
|
+
subagent_type: SubagentType;
|
|
47
|
+
prompt: string;
|
|
48
|
+
model?: string;
|
|
49
|
+
thinking?: ThinkingLevel;
|
|
50
|
+
max_turns?: number;
|
|
51
|
+
isolated?: boolean;
|
|
52
|
+
isolation?: IsolationMode;
|
|
53
|
+
}
|
|
54
|
+
export declare class SubagentScheduler {
|
|
55
|
+
private jobs;
|
|
56
|
+
private intervals;
|
|
57
|
+
private store;
|
|
58
|
+
private pi;
|
|
59
|
+
private ctx;
|
|
60
|
+
private manager;
|
|
61
|
+
/** Start the scheduler: bind to a session's store and arm enabled jobs. */
|
|
62
|
+
start(pi: ExtensionAPI, ctx: ExtensionContext, manager: AgentManager, store: ScheduleStore): void;
|
|
63
|
+
/** Stop all timers; drop refs. Safe to call repeatedly. */
|
|
64
|
+
stop(): void;
|
|
65
|
+
/** True if start() has bound a store and the scheduler is active. */
|
|
66
|
+
isActive(): boolean;
|
|
67
|
+
list(): ScheduledSubagent[];
|
|
68
|
+
/**
|
|
69
|
+
* Build a `ScheduledSubagent` from user input. Validates the schedule
|
|
70
|
+
* format and tags `scheduleType`. Throws on invalid input.
|
|
71
|
+
*/
|
|
72
|
+
buildJob(input: NewJobInput): ScheduledSubagent;
|
|
73
|
+
/** Add a job, persist, and arm if enabled. Returns the stored job. */
|
|
74
|
+
addJob(input: NewJobInput): ScheduledSubagent;
|
|
75
|
+
removeJob(id: string): boolean;
|
|
76
|
+
/** Toggle / mutate a job. Re-arms based on the new `enabled` state. */
|
|
77
|
+
updateJob(id: string, patch: Partial<ScheduledSubagent>): ScheduledSubagent | undefined;
|
|
78
|
+
/** Next-run time as ISO, or undefined if not currently armed. */
|
|
79
|
+
getNextRun(jobId: string): string | undefined;
|
|
80
|
+
private scheduleJob;
|
|
81
|
+
private unscheduleJob;
|
|
82
|
+
/**
|
|
83
|
+
* Fire a job: persist running state, spawn (bypassing the concurrency
|
|
84
|
+
* queue), persist completion. Fire-and-forget: the timer tick returns
|
|
85
|
+
* immediately so other jobs keep firing.
|
|
86
|
+
*/
|
|
87
|
+
private executeJob;
|
|
88
|
+
private emit;
|
|
89
|
+
private requireStore;
|
|
90
|
+
/**
|
|
91
|
+
* Sniff a schedule string and tag its type. Throws on invalid input.
|
|
92
|
+
* Order matters: relative ("+10m") and interval ("5m") both match digit+unit;
|
|
93
|
+
* relative requires the leading "+" to disambiguate.
|
|
94
|
+
*/
|
|
95
|
+
static detectSchedule(s: string): {
|
|
96
|
+
type: "cron" | "once" | "interval";
|
|
97
|
+
intervalMs?: number;
|
|
98
|
+
normalized: string;
|
|
99
|
+
};
|
|
100
|
+
/** 6-field cron — 'second minute hour dom month dow'. */
|
|
101
|
+
static validateCronExpression(expr: string): {
|
|
102
|
+
valid: boolean;
|
|
103
|
+
error?: string;
|
|
104
|
+
};
|
|
105
|
+
/** "+10s"/"+5m"/"+1h"/"+2d" → ISO timestamp. */
|
|
106
|
+
static parseRelativeTime(s: string): string | null;
|
|
107
|
+
/** "10s"/"5m"/"1h"/"2d" → milliseconds. */
|
|
108
|
+
static parseInterval(s: string): number | null;
|
|
109
|
+
}
|