@openlegion/platform 0.0.0-stage → 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/LICENSE +202 -0
- package/README.md +1189 -2
- package/dist/body.d.ts +9 -0
- package/dist/body.js +28 -0
- package/dist/chat-history.d.ts +53 -0
- package/dist/chat-history.js +11 -0
- package/dist/client.d.ts +217 -0
- package/dist/client.js +367 -0
- package/dist/core.d.ts +47 -0
- package/dist/core.js +1 -0
- package/dist/crypto.d.ts +25 -0
- package/dist/crypto.js +81 -0
- package/dist/errors.d.ts +111 -0
- package/dist/errors.js +134 -0
- package/dist/events.d.ts +131 -0
- package/dist/events.js +5 -0
- package/dist/generated/api.d.ts +5505 -0
- package/dist/generated/api.js +446 -0
- package/dist/handler.d.ts +201 -0
- package/dist/handler.js +682 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +12 -0
- package/dist/kit-agents.d.ts +95 -0
- package/dist/kit-agents.js +280 -0
- package/dist/kit-codes.d.ts +279 -0
- package/dist/kit-codes.js +44 -0
- package/dist/kit-connections.d.ts +21 -0
- package/dist/kit-connections.js +189 -0
- package/dist/kit-files.d.ts +8 -0
- package/dist/kit-files.js +117 -0
- package/dist/kit-model-keys.d.ts +8 -0
- package/dist/kit-model-keys.js +86 -0
- package/dist/kit-threads.d.ts +3 -0
- package/dist/kit-threads.js +92 -0
- package/dist/kit-tools.d.ts +21 -0
- package/dist/kit-tools.js +47 -0
- package/dist/kit.d.ts +130 -0
- package/dist/kit.js +155 -0
- package/dist/mcp-server.d.ts +27 -0
- package/dist/mcp-server.js +166 -0
- package/dist/next.d.ts +24 -0
- package/dist/next.js +6 -0
- package/dist/ol-signed.d.ts +82 -0
- package/dist/ol-signed.js +115 -0
- package/dist/react/add-server.d.ts +90 -0
- package/dist/react/add-server.js +183 -0
- package/dist/react/agent-chat.d.ts +925 -0
- package/dist/react/agent-chat.js +1917 -0
- package/dist/react/agent-editor.d.ts +133 -0
- package/dist/react/agent-editor.js +222 -0
- package/dist/react/agent-kit.d.ts +160 -0
- package/dist/react/agent-kit.js +279 -0
- package/dist/react/agent-list.d.ts +247 -0
- package/dist/react/agent-list.js +248 -0
- package/dist/react/approval-card.d.ts +272 -0
- package/dist/react/approval-card.js +372 -0
- package/dist/react/artifact-card.d.ts +38 -0
- package/dist/react/artifact-card.js +39 -0
- package/dist/react/avatar.d.ts +21 -0
- package/dist/react/avatar.js +33 -0
- package/dist/react/card-ledger.d.ts +30 -0
- package/dist/react/card-ledger.js +49 -0
- package/dist/react/chat-timing.d.ts +121 -0
- package/dist/react/chat-timing.js +229 -0
- package/dist/react/computer-view.d.ts +309 -0
- package/dist/react/computer-view.js +543 -0
- package/dist/react/computer-viewer.d.ts +175 -0
- package/dist/react/computer-viewer.js +555 -0
- package/dist/react/computer-wire.d.ts +178 -0
- package/dist/react/computer-wire.js +244 -0
- package/dist/react/connect-button.d.ts +145 -0
- package/dist/react/connect-button.js +212 -0
- package/dist/react/connection-request.d.ts +16 -0
- package/dist/react/connection-request.js +18 -0
- package/dist/react/connections-list.d.ts +90 -0
- package/dist/react/connections-list.js +76 -0
- package/dist/react/errors.d.ts +250 -0
- package/dist/react/errors.js +146 -0
- package/dist/react/files.d.ts +41 -0
- package/dist/react/files.js +78 -0
- package/dist/react/index.d.ts +35 -0
- package/dist/react/index.js +26 -0
- package/dist/react/limit-words.d.ts +80 -0
- package/dist/react/limit-words.js +53 -0
- package/dist/react/markdown.d.ts +42 -0
- package/dist/react/markdown.js +56 -0
- package/dist/react/md-parse.d.ts +106 -0
- package/dist/react/md-parse.js +638 -0
- package/dist/react/model-keys-card.d.ts +94 -0
- package/dist/react/model-keys-card.js +123 -0
- package/dist/react/reload.d.ts +211 -0
- package/dist/react/reload.js +339 -0
- package/dist/react/reveal.d.ts +17 -0
- package/dist/react/reveal.js +22 -0
- package/dist/react/schedule-editor.d.ts +107 -0
- package/dist/react/schedule-editor.js +172 -0
- package/dist/react/schedule-time.d.ts +66 -0
- package/dist/react/schedule-time.js +90 -0
- package/dist/react/styles.css +1274 -0
- package/dist/react/transport.d.ts +49 -0
- package/dist/react/transport.js +380 -0
- package/dist/react/use-connections.d.ts +155 -0
- package/dist/react/use-connections.js +231 -0
- package/dist/react/use-model-keys.d.ts +47 -0
- package/dist/react/use-model-keys.js +57 -0
- package/dist/react/use-threads.d.ts +63 -0
- package/dist/react/use-threads.js +73 -0
- package/dist/react/vault-form.d.ts +92 -0
- package/dist/react/vault-form.js +151 -0
- package/dist/schema.d.ts +47 -0
- package/dist/schema.js +16 -0
- package/dist/secrets.d.ts +15 -0
- package/dist/secrets.js +18 -0
- package/dist/stream.d.ts +129 -0
- package/dist/stream.js +192 -0
- package/dist/testing.d.ts +33 -0
- package/dist/testing.js +40 -0
- package/dist/webhooks.d.ts +31 -0
- package/dist/webhooks.js +72 -0
- package/package.json +85 -3
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<ScheduleEditor>`'s picker, as plain functions: a WEEKLY TIME (some weekdays, one time of day) and the
|
|
3
|
+
* five-field cron it writes. The platform reads the cron in the workspace's time zone, so "09:00" here is
|
|
4
|
+
* 09:00 there, whatever the page's own zone.
|
|
5
|
+
*
|
|
6
|
+
* Only this shape is edited in the picker. A cron of any other shape (the template's, the agent's own, one
|
|
7
|
+
* the partner wrote with its key) is shown as it is and can be paused or removed, never redrawn: a picker
|
|
8
|
+
* that "understood" `*\/20 9-17 * * 1-5` as one time a day would rewrite it on save.
|
|
9
|
+
*
|
|
10
|
+
* The bounds are the template's `customizable.schedules` (on the agent and the template agent). The picker
|
|
11
|
+
* offers only days and hours inside them, and `weeklyOutsideBounds` says why a choice is out, before the API
|
|
12
|
+
* does: the API's 409 `outside_template_bounds` is still the authority.
|
|
13
|
+
*/
|
|
14
|
+
/** 0 = Sunday … 6 = Saturday, as cron and `customizable.schedules.days` count them. */
|
|
15
|
+
export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
16
|
+
export interface WeeklyTime {
|
|
17
|
+
/** At least one, each once, in order. */
|
|
18
|
+
days: Weekday[];
|
|
19
|
+
/** 0–23, in the workspace's time zone. */
|
|
20
|
+
hour: number;
|
|
21
|
+
/** 0–59. */
|
|
22
|
+
minute: number;
|
|
23
|
+
}
|
|
24
|
+
/** `customizable.schedules`, as the agent and the template agent carry it. */
|
|
25
|
+
export interface ScheduleBounds {
|
|
26
|
+
/** The shortest gap between two runs, in seconds. */
|
|
27
|
+
min_interval_seconds?: number;
|
|
28
|
+
/** At most this many of a person's unfinished schedules on the agent. */
|
|
29
|
+
max?: number;
|
|
30
|
+
/** Runs start at or after `from` and before `to` (hours, 0–24). */
|
|
31
|
+
hours?: {
|
|
32
|
+
from: number;
|
|
33
|
+
to: number;
|
|
34
|
+
};
|
|
35
|
+
days?: number[];
|
|
36
|
+
}
|
|
37
|
+
export declare const ALL_DAYS: readonly Weekday[];
|
|
38
|
+
/** The cron a weekly time writes: `m h * * d,d`. Every day is `*`. */
|
|
39
|
+
export declare function weeklyToCron(w: WeeklyTime): string;
|
|
40
|
+
/**
|
|
41
|
+
* The weekly time a cron is, or null when it is any other shape: one minute, one hour, every day of the month
|
|
42
|
+
* and month, and `*` or a list or range of weekdays (`1-5`, `1,3,5`, `0,6`; `7` is Sunday).
|
|
43
|
+
*/
|
|
44
|
+
export declare function cronToWeekly(cron: string | null | undefined): WeeklyTime | null;
|
|
45
|
+
/** The shortest gap between two runs of a weekly time, in minutes: a day between its closest days, a week for one day. */
|
|
46
|
+
export declare function weeklyGapMinutes(w: WeeklyTime): number;
|
|
47
|
+
export type BoundsProblem = "no_days" | "day" | "hour" | "interval";
|
|
48
|
+
/** Why a weekly time is outside the bounds, or null. The same checks as the API, read for this shape only. */
|
|
49
|
+
export declare function weeklyOutsideBounds(w: WeeklyTime, b: ScheduleBounds | null | undefined): BoundsProblem | null;
|
|
50
|
+
/** The days the picker offers: the bounds' days, else every day. */
|
|
51
|
+
export declare function allowedDays(b: ScheduleBounds | null | undefined): Weekday[];
|
|
52
|
+
/** The hours the picker offers: inside the bounds' `[from, to)`, else 0–23. */
|
|
53
|
+
export declare function allowedHours(b: ScheduleBounds | null | undefined): number[];
|
|
54
|
+
/**
|
|
55
|
+
* How the kit writes a time of day in `locale`: its language and its own hour cycle, as Intl resolves it. "9:05 AM"
|
|
56
|
+
* where the clock is 12-hour (en-US); "09:05" where it is 24-hour (en-GB, de-DE), two digits as it always was. Every
|
|
57
|
+
* time of day the kit prints goes through these options.
|
|
58
|
+
*/
|
|
59
|
+
export declare function timeOfDayOptions(locale?: string): Intl.DateTimeFormatOptions;
|
|
60
|
+
/** A moment's time of day, in `timeZone` (default: the browser's) and the page's hour cycle. */
|
|
61
|
+
export declare function timeOfDay(at: Date, o?: {
|
|
62
|
+
locale?: string | undefined;
|
|
63
|
+
timeZone?: string | undefined;
|
|
64
|
+
}): string;
|
|
65
|
+
/** A wall-clock time of day, "9:05 AM" or "09:05", in the page's hour cycle (`locale`; default: the browser's). */
|
|
66
|
+
export declare function clock(hour: number, minute: number, locale?: string): string;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export const ALL_DAYS = [0, 1, 2, 3, 4, 5, 6];
|
|
2
|
+
const INT = /^(0|[1-9]\d?)$/;
|
|
3
|
+
export function weeklyToCron(w) {
|
|
4
|
+
const days = [...new Set(w.days)].sort((a, b) => a - b);
|
|
5
|
+
const dow = days.length === 7 ? "*" : days.join(",");
|
|
6
|
+
return `${w.minute} ${w.hour} * * ${dow}`;
|
|
7
|
+
}
|
|
8
|
+
export function cronToWeekly(cron) {
|
|
9
|
+
const f = (cron ?? "").trim().split(/\s+/);
|
|
10
|
+
if (f.length !== 5)
|
|
11
|
+
return null;
|
|
12
|
+
const [m, h, dom, mon, dow] = f;
|
|
13
|
+
if (!INT.test(m) || !INT.test(h) || dom !== "*" || mon !== "*")
|
|
14
|
+
return null;
|
|
15
|
+
const minute = Number(m);
|
|
16
|
+
const hour = Number(h);
|
|
17
|
+
if (minute > 59 || hour > 23)
|
|
18
|
+
return null;
|
|
19
|
+
const days = new Set();
|
|
20
|
+
if (dow === "*")
|
|
21
|
+
ALL_DAYS.forEach((d) => days.add(d));
|
|
22
|
+
else {
|
|
23
|
+
for (const part of dow.split(",")) {
|
|
24
|
+
const range = /^([0-7])(?:-([0-7]))?$/.exec(part);
|
|
25
|
+
if (!range)
|
|
26
|
+
return null;
|
|
27
|
+
const from = Number(range[1]);
|
|
28
|
+
const to = range[2] === undefined ? from : Number(range[2]);
|
|
29
|
+
if (to < from)
|
|
30
|
+
return null;
|
|
31
|
+
for (let d = from; d <= to; d += 1)
|
|
32
|
+
days.add((d % 7));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return { days: [...days].sort((a, b) => a - b), hour, minute };
|
|
36
|
+
}
|
|
37
|
+
export function weeklyGapMinutes(w) {
|
|
38
|
+
const days = [...new Set(w.days)].sort((a, b) => a - b);
|
|
39
|
+
if (days.length <= 1)
|
|
40
|
+
return 7 * 1440;
|
|
41
|
+
let gap = 7;
|
|
42
|
+
for (let i = 0; i < days.length; i += 1) {
|
|
43
|
+
const next = i + 1 < days.length ? days[i + 1] : days[0] + 7;
|
|
44
|
+
gap = Math.min(gap, next - days[i]);
|
|
45
|
+
}
|
|
46
|
+
return gap * 1440;
|
|
47
|
+
}
|
|
48
|
+
export function weeklyOutsideBounds(w, b) {
|
|
49
|
+
if (w.days.length === 0)
|
|
50
|
+
return "no_days";
|
|
51
|
+
if (b?.days && w.days.some((d) => !b.days.includes(d)))
|
|
52
|
+
return "day";
|
|
53
|
+
if (b?.hours && !(w.hour >= b.hours.from && w.hour < b.hours.to))
|
|
54
|
+
return "hour";
|
|
55
|
+
if (b?.min_interval_seconds && weeklyGapMinutes(w) * 60 < b.min_interval_seconds)
|
|
56
|
+
return "interval";
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
export function allowedDays(b) {
|
|
60
|
+
return ALL_DAYS.filter((d) => !b?.days || b.days.includes(d));
|
|
61
|
+
}
|
|
62
|
+
export function allowedHours(b) {
|
|
63
|
+
const from = b?.hours?.from ?? 0;
|
|
64
|
+
const to = b?.hours?.to ?? 24;
|
|
65
|
+
const out = [];
|
|
66
|
+
for (let h = Math.max(0, from); h < Math.min(24, to); h += 1)
|
|
67
|
+
out.push(h);
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
export function timeOfDayOptions(locale) {
|
|
71
|
+
let cycle;
|
|
72
|
+
try {
|
|
73
|
+
cycle = new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions().hourCycle;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
cycle = "h23";
|
|
77
|
+
}
|
|
78
|
+
return { hour: cycle === "h23" || cycle === "h24" ? "2-digit" : "numeric", minute: "2-digit" };
|
|
79
|
+
}
|
|
80
|
+
export function timeOfDay(at, o = {}) {
|
|
81
|
+
try {
|
|
82
|
+
return new Intl.DateTimeFormat(o.locale, { ...timeOfDayOptions(o.locale), ...(o.timeZone ? { timeZone: o.timeZone } : {}) }).format(at);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return `${String(at.getUTCHours()).padStart(2, "0")}:${String(at.getUTCMinutes()).padStart(2, "0")}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function clock(hour, minute, locale) {
|
|
89
|
+
return timeOfDay(new Date(Date.UTC(2000, 0, 1, hour, minute)), { locale, timeZone: "UTC" });
|
|
90
|
+
}
|