@amaster.ai/pi-task-scheduler 0.1.0-beta.0 → 0.1.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/dist/stores.js ADDED
@@ -0,0 +1,134 @@
1
+ import { mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { normalizeScheduledTask, } from './index.js';
4
+ import { readJsonFile, writeJsonFile } from './json-file.js';
5
+ export class JsonScheduledTaskStore {
6
+ filePath;
7
+ loaded = false;
8
+ tasks = new Map();
9
+ constructor(filePath) {
10
+ this.filePath = filePath;
11
+ }
12
+ async list(_scope = {}) {
13
+ await this.load();
14
+ return Array.from(this.tasks.values());
15
+ }
16
+ async get(taskId, _scope = {}) {
17
+ await this.load();
18
+ return this.tasks.get(taskId);
19
+ }
20
+ async create(task) {
21
+ await this.load();
22
+ const normalized = normalizeScheduledTask(task);
23
+ this.tasks.set(normalized.id, normalized);
24
+ await this.save();
25
+ return normalized;
26
+ }
27
+ async update(taskId, task, _scope = {}) {
28
+ await this.load();
29
+ if (!this.tasks.has(taskId)) {
30
+ return undefined;
31
+ }
32
+ const normalized = normalizeScheduledTask(task);
33
+ this.tasks.set(taskId, normalized);
34
+ await this.save();
35
+ return normalized;
36
+ }
37
+ async delete(taskId, _scope = {}) {
38
+ await this.load();
39
+ if (!this.tasks.has(taskId)) {
40
+ return false;
41
+ }
42
+ const deleted = this.tasks.delete(taskId);
43
+ await this.save();
44
+ return deleted;
45
+ }
46
+ async load() {
47
+ if (this.loaded) {
48
+ return;
49
+ }
50
+ const tasks = await readJsonFile(this.filePath, []);
51
+ this.tasks.clear();
52
+ for (const rawTask of tasks) {
53
+ const task = normalizeScheduledTask(rawTask);
54
+ this.tasks.set(task.id, task);
55
+ }
56
+ this.loaded = true;
57
+ }
58
+ async save() {
59
+ await writeJsonFile(this.filePath, Array.from(this.tasks.values()));
60
+ }
61
+ }
62
+ export class FileSchedulerLock {
63
+ path;
64
+ acquired = false;
65
+ constructor(path) {
66
+ this.path = path;
67
+ }
68
+ acquire() {
69
+ mkdirSync(path.dirname(this.path), { recursive: true });
70
+ const holder = this.holderPid();
71
+ if (holder && holder !== process.pid) {
72
+ return false;
73
+ }
74
+ try {
75
+ unlinkSync(this.path);
76
+ }
77
+ catch {
78
+ // Lock did not exist or was already removed between checks.
79
+ }
80
+ try {
81
+ writeFileSync(this.path, String(process.pid), { flag: 'wx' });
82
+ this.acquired = true;
83
+ return true;
84
+ }
85
+ catch (error) {
86
+ if (error.code === 'EEXIST') {
87
+ this.acquired = false;
88
+ return false;
89
+ }
90
+ throw error;
91
+ }
92
+ }
93
+ release() {
94
+ if (!this.acquired) {
95
+ return;
96
+ }
97
+ try {
98
+ const pid = Number(readFileSync(this.path, 'utf8').trim());
99
+ if (pid === process.pid) {
100
+ unlinkSync(this.path);
101
+ }
102
+ }
103
+ catch {
104
+ // Lock was already gone; the scheduler is stopping anyway.
105
+ }
106
+ this.acquired = false;
107
+ }
108
+ isAcquired() {
109
+ return this.acquired;
110
+ }
111
+ holderPid() {
112
+ try {
113
+ const pid = Number(readFileSync(this.path, 'utf8').trim());
114
+ if (Number.isInteger(pid) && pid > 0 && isProcessAlive(pid)) {
115
+ return pid;
116
+ }
117
+ unlinkSync(this.path);
118
+ return undefined;
119
+ }
120
+ catch {
121
+ return undefined;
122
+ }
123
+ }
124
+ }
125
+ function isProcessAlive(pid) {
126
+ try {
127
+ process.kill(pid, 0);
128
+ return true;
129
+ }
130
+ catch {
131
+ return false;
132
+ }
133
+ }
134
+ //# sourceMappingURL=stores.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores.js","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,sBAAsB,GAKv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C7D,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,SAAS;QACP,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAC3D,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC5D,OAAO,GAAG,CAAC;YACb,CAAC;YACD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAED,SAAS,cAAc,CAAC,GAAW;IACjC,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ToolDefinition } from '@earendil-works/pi-coding-agent';
2
+ import { type TaskScheduler } from './index.js';
3
+ export declare function createSchedulerTools(scheduler: TaskScheduler): ToolDefinition[];
4
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,cAAc,EACf,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AA0BpB,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,aAAa,GAAG,cAAc,EAAE,CAmL/E"}
package/dist/tools.js ADDED
@@ -0,0 +1,168 @@
1
+ import { Type } from 'typebox';
2
+ import { resolveScheduledTaskDefinition, } from './index.js';
3
+ function textResult(text) {
4
+ return { content: [{ type: 'text', text }], details: undefined };
5
+ }
6
+ function formatTaskSummary(task) {
7
+ return {
8
+ id: task.id,
9
+ name: task.name,
10
+ type: task.type,
11
+ schedule: task.schedule,
12
+ enabled: task.enabled,
13
+ lastStatus: task.lastStatus ?? 'pending',
14
+ nextRunAt: task.nextRunAt,
15
+ runCount: task.runCount,
16
+ prompt: task.prompt.length > 100 ? `${task.prompt.slice(0, 100)}…` : task.prompt,
17
+ };
18
+ }
19
+ const taskTypeSchema = Type.Union([
20
+ Type.Literal('cron'),
21
+ Type.Literal('once'),
22
+ Type.Literal('interval'),
23
+ ]);
24
+ export function createSchedulerTools(scheduler) {
25
+ return [
26
+ {
27
+ name: 'scheduler_create',
28
+ label: 'Scheduler',
29
+ description: 'Schedule a prompt to be executed automatically at a future time or on a recurring basis. Supports cron expressions, one-time (ISO timestamp or relative like "+10m"), and interval (e.g. "30s", "5m", "1h"). Use this when the user wants something to run later, repeatedly, or on a timer.',
30
+ promptSnippet: 'Schedule prompts to run automatically via cron, one-time delay, or fixed interval.',
31
+ parameters: Type.Object({
32
+ type: taskTypeSchema,
33
+ schedule: Type.String({
34
+ description: 'Schedule expression. Cron: "0 9 * * 1-5"; Once: ISO timestamp or "+10m"; Interval: "30s", "5m", "1h".',
35
+ }),
36
+ prompt: Type.String({ description: 'The prompt to execute when triggered.' }),
37
+ name: Type.Optional(Type.String({ description: 'Human-readable name for this scheduled prompt.' })),
38
+ description: Type.Optional(Type.String({ description: 'Description of this scheduled prompt.' })),
39
+ enabled: Type.Optional(Type.Boolean({ description: 'Whether this scheduled prompt is enabled. Default true.' })),
40
+ }),
41
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
42
+ try {
43
+ const definition = resolveScheduledTaskDefinition({
44
+ type: params.type,
45
+ schedule: params.schedule,
46
+ });
47
+ const input = {
48
+ ...definition,
49
+ prompt: params.prompt,
50
+ sessionId: ctx.sessionManager?.getSessionId?.() ?? 'unknown',
51
+ model: {
52
+ provider: 'anthropic',
53
+ model: ctx.model?.id ?? 'unknown',
54
+ },
55
+ toolPolicyProfile: 'default',
56
+ enabled: params.enabled !== false,
57
+ ...(params.name ? { name: params.name } : {}),
58
+ ...(params.description ? { description: params.description } : {}),
59
+ };
60
+ const task = await scheduler.create(input);
61
+ return textResult(JSON.stringify(formatTaskSummary(task), null, 2));
62
+ }
63
+ catch (error) {
64
+ return textResult(`Failed to create task: ${error instanceof Error ? error.message : String(error)}`);
65
+ }
66
+ },
67
+ },
68
+ {
69
+ name: 'scheduler_list',
70
+ label: 'Scheduler',
71
+ description: 'List all scheduled prompts with their status and next run time.',
72
+ promptSnippet: 'List all scheduled prompts.',
73
+ parameters: Type.Object({}),
74
+ async execute() {
75
+ const tasks = await scheduler.list();
76
+ if (tasks.length === 0) {
77
+ return textResult('No scheduled tasks.');
78
+ }
79
+ const summary = tasks.map(formatTaskSummary);
80
+ return textResult(JSON.stringify(summary, null, 2));
81
+ },
82
+ },
83
+ {
84
+ name: 'scheduler_get',
85
+ label: 'Scheduler',
86
+ description: 'Get detailed information about a scheduled prompt, including its schedule and run history.',
87
+ parameters: Type.Object({
88
+ taskId: Type.String({ description: 'The scheduled-prompt ID to query.' }),
89
+ }),
90
+ async execute(_toolCallId, params) {
91
+ const task = await scheduler.get(params.taskId);
92
+ if (!task) {
93
+ return textResult(`Task not found: ${params.taskId}`);
94
+ }
95
+ return textResult(JSON.stringify(task, null, 2));
96
+ },
97
+ },
98
+ {
99
+ name: 'scheduler_update',
100
+ label: 'Scheduler',
101
+ description: 'Update a scheduled prompt. Can change schedule, prompt text, name, or enable/disable.',
102
+ parameters: Type.Object({
103
+ taskId: Type.String({ description: 'The scheduled-prompt ID to update.' }),
104
+ type: Type.Optional(taskTypeSchema),
105
+ schedule: Type.Optional(Type.String({ description: 'New schedule expression.' })),
106
+ prompt: Type.Optional(Type.String({ description: 'New prompt.' })),
107
+ name: Type.Optional(Type.String({ description: 'New name.' })),
108
+ description: Type.Optional(Type.String({ description: 'New description.' })),
109
+ enabled: Type.Optional(Type.Boolean({ description: 'Enable or disable.' })),
110
+ }),
111
+ async execute(_toolCallId, params) {
112
+ const { taskId, type, schedule, ...rest } = params;
113
+ const update = { ...rest };
114
+ if (type !== undefined || schedule !== undefined) {
115
+ try {
116
+ const existing = await scheduler.get(taskId);
117
+ if (!existing) {
118
+ return textResult(`Task not found: ${taskId}`);
119
+ }
120
+ const definition = resolveScheduledTaskDefinition({
121
+ type: (type ?? existing.type),
122
+ schedule: schedule ?? existing.schedule,
123
+ });
124
+ Object.assign(update, definition);
125
+ }
126
+ catch (error) {
127
+ return textResult(`Invalid schedule: ${error instanceof Error ? error.message : String(error)}`);
128
+ }
129
+ }
130
+ const task = await scheduler.update(taskId, update);
131
+ if (!task) {
132
+ return textResult(`Task not found: ${taskId}`);
133
+ }
134
+ return textResult(JSON.stringify(formatTaskSummary(task), null, 2));
135
+ },
136
+ },
137
+ {
138
+ name: 'scheduler_delete',
139
+ label: 'Scheduler',
140
+ description: 'Delete a scheduled prompt.',
141
+ parameters: Type.Object({
142
+ taskId: Type.String({ description: 'The scheduled-prompt ID to delete.' }),
143
+ }),
144
+ async execute(_toolCallId, params) {
145
+ const taskId = params.taskId;
146
+ const deleted = await scheduler.delete(taskId);
147
+ return textResult(deleted ? `Deleted task: ${taskId}` : `Task not found: ${taskId}`);
148
+ },
149
+ },
150
+ {
151
+ name: 'scheduler_run_now',
152
+ label: 'Scheduler',
153
+ description: 'Trigger immediate execution of a scheduled prompt, ignoring its schedule.',
154
+ parameters: Type.Object({
155
+ taskId: Type.String({ description: 'The scheduled-prompt ID to run immediately.' }),
156
+ }),
157
+ async execute(_toolCallId, params) {
158
+ const taskId = params.taskId;
159
+ const task = await scheduler.runNow(taskId);
160
+ if (!task) {
161
+ return textResult(`Task not found: ${taskId}`);
162
+ }
163
+ return textResult(`Triggered: ${task.name ?? task.id}`);
164
+ },
165
+ },
166
+ ];
167
+ }
168
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EACL,8BAA8B,GAK/B,MAAM,YAAY,CAAC;AAEpB,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAC5E,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAmB;IAC5C,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;QACxC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM;KACjF,CAAC;AACJ,CAAC;AAED,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC;IAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACpB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACpB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,UAAU,oBAAoB,CAAC,SAAwB;IAC3D,OAAO;QACL;YACE,IAA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AM,EAAE,CAAC,CAAC;gBACjD,CAAC;gBACD,OAAO,UAAU,CAAC,cAAc,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1D,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "name": "@amaster.ai/pi-task-scheduler",
3
- "version": "0.1.0-beta.0",
3
+ "version": "0.1.0",
4
+ "description": "Pi extension for cron-based scheduled task management with LLM-callable tools",
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi",
8
+ "extension",
9
+ "scheduler",
10
+ "cron",
11
+ "tasks"
12
+ ],
4
13
  "license": "Apache-2.0",
5
14
  "type": "module",
6
15
  "sideEffects": false,
@@ -11,12 +20,31 @@
11
20
  "types": "./dist/index.d.ts",
12
21
  "default": "./dist/index.js"
13
22
  },
23
+ "./stores": {
24
+ "types": "./dist/stores.d.ts",
25
+ "default": "./dist/stores.js"
26
+ },
27
+ "./extension": {
28
+ "types": "./dist/extension.d.ts",
29
+ "default": "./dist/extension.js"
30
+ },
31
+ "./tools": {
32
+ "types": "./dist/tools.d.ts",
33
+ "default": "./dist/tools.js"
34
+ },
14
35
  "./package.json": {
15
36
  "default": "./package.json"
16
37
  }
17
38
  },
39
+ "pi": {
40
+ "image": "https://raw.githubusercontent.com/TGYD-helige/pi/master/packages/pi-task-scheduler/preview.png",
41
+ "extensions": [
42
+ "./dist/index.js"
43
+ ]
44
+ },
18
45
  "files": [
19
46
  "dist",
47
+ "preview.png",
20
48
  "README.md"
21
49
  ],
22
50
  "publishConfig": {
@@ -25,12 +53,27 @@
25
53
  "repository": {
26
54
  "type": "git",
27
55
  "url": "https://github.com/TGYD-helige/pi.git",
28
- "directory": "packages/task-scheduler"
56
+ "directory": "packages/pi-task-scheduler"
29
57
  },
30
58
  "dependencies": {
31
- "croner": "^10.0.1"
59
+ "croner": "^10.0.1",
60
+ "@amaster.ai/pi-shared": "0.1.0"
61
+ },
62
+ "peerDependencies": {
63
+ "@earendil-works/pi-coding-agent": ">=0.74.0",
64
+ "typebox": "*"
65
+ },
66
+ "peerDependenciesMeta": {
67
+ "@earendil-works/pi-coding-agent": {
68
+ "optional": true
69
+ },
70
+ "typebox": {
71
+ "optional": true
72
+ }
32
73
  },
33
74
  "devDependencies": {
75
+ "@earendil-works/pi-coding-agent": "0.74.0",
76
+ "typebox": "*",
34
77
  "vitest": "^4.0.0"
35
78
  },
36
79
  "scripts": {
package/preview.png ADDED
Binary file