@runappsai/agent 0.1.10 → 0.1.15
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 +1 -1
- package/dist/agent-core.umd.js +90 -87
- package/dist/agent.d.ts +21 -1
- package/dist/agent.js +48 -14
- package/dist/agent.umd.js +135 -109
- package/dist/chat.d.ts +40 -1
- package/dist/chat.js +441 -26
- package/dist/compaction.d.ts +10 -0
- package/dist/dom.d.ts +28 -1
- package/dist/dom.js +38 -1
- package/dist/files-panel.js +2 -2
- package/dist/index.cjs +541 -38
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/schedule.d.ts +152 -0
- package/dist/schedule.js +505 -0
- package/dist/types.d.ts +3 -0
- package/dist/ui.cjs +1021 -20
- package/dist/ui.d.ts +1 -0
- package/docs/agent.md +3 -1
- package/docs/chat-ui.md +25 -3
- package/docs/reference.md +2 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -19,10 +19,11 @@ export declare function createAgent(provider: ModelProvider | RunAppsClientLike,
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function openWorkspace(provider: ModelProvider | RunAppsClientLike | null, opts?: WorkspaceOptions): Promise<Workspace>;
|
|
21
21
|
export { Workspace, memoryFS, normalizePath, guessType, decodeText, titleOf, UNTITLED, DEFAULT_SKILLS_DIR, DEFAULT_USER_SKILLS_DIR, type SkillSource, type LazySkill, type WorkspaceOptions, type WorkspaceRead, type WorkspaceChange, type SessionStore, type WorkspaceStore, type WorkspaceStoreFactory, type FileRecord } from "./workspace.js";
|
|
22
|
-
export { planCut, serializeConversation, splitForSummary, summaryOf, summaryMessage, type CompactionSettings, type CutPlan } from "./compaction.js";
|
|
22
|
+
export { planCut, serializeConversation, splitForSummary, summaryOf, summaryMessage, DEFAULT_COMPACTION, type CompactionChoice, type CompactionSettings, type CutPlan } from "./compaction.js";
|
|
23
23
|
export { parseCommandArgs, substituteArgs, listTemplates, expandSlash, type PromptTemplate } from "./templates.js";
|
|
24
24
|
export { applyEdits, normalizeForFuzzyMatch, type TextEdit } from "./edit.js";
|
|
25
25
|
export { defineTool, normalizeResult } from "./tool.js";
|
|
26
|
+
export { Scheduler, scheduleTools, localSchedules, memorySchedules, makeTask, changeTask, nextRun, checkSchedule, describeSchedule, parseCron, parseLocalTime, formatLocalTime, type Schedule, type ScheduledTask, type ScheduleStore, type ScheduleLimits, type ScheduleRunStatus, type SchedulerOptions } from "./schedule.js";
|
|
26
27
|
export { domUI, nullUI, askUserTool } from "./dialogs.js";
|
|
27
28
|
export { configurePdf, extractPdfText, formatPdfText, isPdf, type PdfLib } from "./pdf.js";
|
|
28
29
|
export { fileTools, type FileToolsOptions } from "./file-tools.js";
|
package/dist/index.js
CHANGED
|
@@ -27,10 +27,11 @@ export function openWorkspace(provider, opts = {}) {
|
|
|
27
27
|
return Workspace.open(p, { ...opts, project: opts.project ?? p?.name ?? undefined });
|
|
28
28
|
}
|
|
29
29
|
export { Workspace, memoryFS, normalizePath, guessType, decodeText, titleOf, UNTITLED, DEFAULT_SKILLS_DIR, DEFAULT_USER_SKILLS_DIR } from "./workspace.js";
|
|
30
|
-
export { planCut, serializeConversation, splitForSummary, summaryOf, summaryMessage } from "./compaction.js";
|
|
30
|
+
export { planCut, serializeConversation, splitForSummary, summaryOf, summaryMessage, DEFAULT_COMPACTION } from "./compaction.js";
|
|
31
31
|
export { parseCommandArgs, substituteArgs, listTemplates, expandSlash } from "./templates.js";
|
|
32
32
|
export { applyEdits, normalizeForFuzzyMatch } from "./edit.js";
|
|
33
33
|
export { defineTool, normalizeResult } from "./tool.js";
|
|
34
|
+
export { Scheduler, scheduleTools, localSchedules, memorySchedules, makeTask, changeTask, nextRun, checkSchedule, describeSchedule, parseCron, parseLocalTime, formatLocalTime } from "./schedule.js";
|
|
34
35
|
export { domUI, nullUI, askUserTool } from "./dialogs.js";
|
|
35
36
|
export { configurePdf, extractPdfText, formatPdfText, isPdf } from "./pdf.js";
|
|
36
37
|
export { fileTools } from "./file-tools.js";
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { Tool } from "./types.js";
|
|
2
|
+
/** When a task runs. Times are the user's local time. */
|
|
3
|
+
export type Schedule =
|
|
4
|
+
/** Once, at `at` (local "YYYY-MM-DDTHH:mm", or an ISO time with a zone). */
|
|
5
|
+
{
|
|
6
|
+
type: "once";
|
|
7
|
+
at: string;
|
|
8
|
+
}
|
|
9
|
+
/** Every `minutes` minutes, the first `minutes` after it is set. */
|
|
10
|
+
| {
|
|
11
|
+
type: "every";
|
|
12
|
+
minutes: number;
|
|
13
|
+
}
|
|
14
|
+
/** Daily at `time` ("HH:mm"), only on `days` (0 = Sunday … 6 = Saturday) when given. */
|
|
15
|
+
| {
|
|
16
|
+
type: "daily";
|
|
17
|
+
time: string;
|
|
18
|
+
days?: number[];
|
|
19
|
+
}
|
|
20
|
+
/** A five-field cron expression (minute hour day-of-month month day-of-week), local time. */
|
|
21
|
+
| {
|
|
22
|
+
type: "cron";
|
|
23
|
+
cron: string;
|
|
24
|
+
};
|
|
25
|
+
export type ScheduleRunStatus = "ok" | "error" | "stopped";
|
|
26
|
+
export interface ScheduledTask {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
/** What the agent is told each time it runs. */
|
|
30
|
+
prompt: string;
|
|
31
|
+
schedule: Schedule;
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
/** Next run (ms since epoch); null when it will not run again (a past one-off, or off). */
|
|
34
|
+
next: number | null;
|
|
35
|
+
/** Who set it up. */
|
|
36
|
+
by: "agent" | "user";
|
|
37
|
+
created: number;
|
|
38
|
+
updated: number;
|
|
39
|
+
runs: number;
|
|
40
|
+
last?: {
|
|
41
|
+
at: number;
|
|
42
|
+
status: ScheduleRunStatus;
|
|
43
|
+
note?: string;
|
|
44
|
+
cost?: number;
|
|
45
|
+
};
|
|
46
|
+
/** The conversation its runs go to (the chat's choice; one per task). */
|
|
47
|
+
session?: string;
|
|
48
|
+
}
|
|
49
|
+
/** Where tasks are kept. `localSchedules` (the default) keeps them in localStorage. */
|
|
50
|
+
export interface ScheduleStore {
|
|
51
|
+
list(): Promise<ScheduledTask[]>;
|
|
52
|
+
get(id: string): Promise<ScheduledTask | undefined>;
|
|
53
|
+
put(task: ScheduledTask): Promise<void>;
|
|
54
|
+
delete(id: string): Promise<void>;
|
|
55
|
+
/** Called when another tab changed the tasks. */
|
|
56
|
+
subscribe?(fn: () => void): () => void;
|
|
57
|
+
}
|
|
58
|
+
/** Tasks in localStorage under `key` (one JSON list); other tabs' changes arrive through the `storage` event. */
|
|
59
|
+
export declare function localSchedules(key: string): ScheduleStore;
|
|
60
|
+
/** Tasks in memory (tests, or an app that keeps them itself). */
|
|
61
|
+
export declare function memorySchedules(initial?: ScheduledTask[]): ScheduleStore;
|
|
62
|
+
/** A local "YYYY-MM-DD HH:mm" / "YYYY-MM-DDTHH:mm[:ss]" (or an ISO time with a zone) → ms; NaN when it is not one. */
|
|
63
|
+
export declare function parseLocalTime(s: string): number;
|
|
64
|
+
/** "2026-11-28 09:00" in local time. */
|
|
65
|
+
export declare function formatLocalTime(ms: number): string;
|
|
66
|
+
interface Cron {
|
|
67
|
+
min: Set<number>;
|
|
68
|
+
hour: Set<number>;
|
|
69
|
+
dom: Set<number>;
|
|
70
|
+
mon: Set<number>;
|
|
71
|
+
dow: Set<number>;
|
|
72
|
+
domAny: boolean;
|
|
73
|
+
dowAny: boolean;
|
|
74
|
+
}
|
|
75
|
+
/** Parses a five-field cron expression; throws a readable error. */
|
|
76
|
+
export declare function parseCron(expr: string): Cron;
|
|
77
|
+
/** Checks a schedule; returns a readable problem, or undefined when it is fine. `minMinutes` is the shortest repeat allowed. */
|
|
78
|
+
export declare function checkSchedule(s: Schedule, minMinutes?: number): string | undefined;
|
|
79
|
+
/** The first run of `s` after `after` (ms); null when there is none (a one-off already past). `from` is when an "every" schedule last ran or was set. */
|
|
80
|
+
export declare function nextRun(s: Schedule, after: number, from?: number): number | null;
|
|
81
|
+
/** The schedule in words: "Every 30 min", "Daily 09:00", "Mon–Fri 09:00", "Once 2026-11-28 09:00", "cron 0 9 * * 1". */
|
|
82
|
+
export declare function describeSchedule(s: Schedule, locale?: "en" | "zh"): string;
|
|
83
|
+
export interface ScheduleLimits {
|
|
84
|
+
/** Shortest repeat, in minutes (default 5): a task that runs every minute would spend the user's money fast. */
|
|
85
|
+
minMinutes?: number;
|
|
86
|
+
/** Most tasks at once (default 20). */
|
|
87
|
+
maxTasks?: number;
|
|
88
|
+
}
|
|
89
|
+
/** Builds a task from a schedule and fields, checking them; throws a readable error. */
|
|
90
|
+
export declare function makeTask(fields: {
|
|
91
|
+
name: string;
|
|
92
|
+
prompt: string;
|
|
93
|
+
schedule: Schedule;
|
|
94
|
+
enabled?: boolean;
|
|
95
|
+
by: "agent" | "user";
|
|
96
|
+
}, limits?: ScheduleLimits, now?: number): ScheduledTask;
|
|
97
|
+
/** Applies a change to a task, checking it; throws a readable error. */
|
|
98
|
+
export declare function changeTask(task: ScheduledTask, patch: {
|
|
99
|
+
name?: string;
|
|
100
|
+
prompt?: string;
|
|
101
|
+
schedule?: Schedule;
|
|
102
|
+
enabled?: boolean;
|
|
103
|
+
}, limits?: ScheduleLimits, now?: number): ScheduledTask;
|
|
104
|
+
/** What the model reads about a task. */
|
|
105
|
+
export declare function taskLine(t: ScheduledTask, now?: number): Record<string, unknown>;
|
|
106
|
+
/**
|
|
107
|
+
* The agent's tools over the tasks: `schedule_list`, `schedule_add`,
|
|
108
|
+
* `schedule_update`, `schedule_remove`. None asks first — the user set the
|
|
109
|
+
* agent free to manage them, and sees them in the Scheduled panel.
|
|
110
|
+
* `onChange` runs after each change (the chat redraws its panel).
|
|
111
|
+
*/
|
|
112
|
+
export declare function scheduleTools(store: ScheduleStore, opts?: ScheduleLimits & {
|
|
113
|
+
onChange?: () => void;
|
|
114
|
+
now?: () => number;
|
|
115
|
+
}): Tool[];
|
|
116
|
+
export interface SchedulerOptions {
|
|
117
|
+
store: ScheduleStore;
|
|
118
|
+
/** Runs one task; resolves how it went. The scheduler runs one task at a time. */
|
|
119
|
+
run: (task: ScheduledTask) => Promise<{
|
|
120
|
+
status: ScheduleRunStatus;
|
|
121
|
+
note?: string;
|
|
122
|
+
cost?: number;
|
|
123
|
+
}>;
|
|
124
|
+
/** Whether a task may start now (the chat: nothing running, no question open). */
|
|
125
|
+
idle: () => boolean;
|
|
126
|
+
/** Names the per-task locks, so tabs of the same app agree (e.g. the app's project). */
|
|
127
|
+
lockPrefix: string;
|
|
128
|
+
/** How often to look, ms (default 20 s; also on focus and when told). */
|
|
129
|
+
interval?: number;
|
|
130
|
+
now?: () => number;
|
|
131
|
+
/** After a task changed (ran, or was claimed). */
|
|
132
|
+
onChange?: () => void;
|
|
133
|
+
}
|
|
134
|
+
/** Fires due tasks while `idle()`: one at a time, each in one tab only. */
|
|
135
|
+
export declare class Scheduler {
|
|
136
|
+
private readonly opts;
|
|
137
|
+
private timer;
|
|
138
|
+
private busy;
|
|
139
|
+
private unsub;
|
|
140
|
+
/** Ids of tasks this tab is running now. */
|
|
141
|
+
readonly running: Set<string>;
|
|
142
|
+
constructor(opts: SchedulerOptions);
|
|
143
|
+
start(): void;
|
|
144
|
+
stop(): void;
|
|
145
|
+
private poke;
|
|
146
|
+
/** Looks for a due task and runs it when idle. Resolves once that run is over. */
|
|
147
|
+
tick(): Promise<void>;
|
|
148
|
+
/** Runs a task now (the user's "Run now"), whatever its time; false when it is already running somewhere. */
|
|
149
|
+
runNow(id: string): Promise<boolean>;
|
|
150
|
+
private fire;
|
|
151
|
+
}
|
|
152
|
+
export {};
|