@nylorun/core 0.26.0-beta → 0.28.0-beta
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 +54 -0
- package/README.md +6 -0
- package/dist/compatibility.d.ts +11 -2
- package/dist/compatibility.js +10 -0
- package/dist/contracts.d.ts +362 -0
- package/dist/contracts.js +131 -5
- package/dist/define.d.ts +2 -1
- package/dist/define.js +2 -1
- package/dist/definition/cron.d.ts +15 -0
- package/dist/definition/cron.js +155 -0
- package/dist/definition/sections.d.ts +11 -0
- package/dist/definition/sections.js +29 -20
- package/dist/folder/compile.d.ts +87 -0
- package/dist/folder/compile.js +1280 -0
- package/dist/folder/context.d.ts +97 -0
- package/dist/folder/context.js +79 -0
- package/dist/folder/decompile.d.ts +18 -0
- package/dist/folder/decompile.js +660 -0
- package/dist/folder/fix.d.ts +22 -0
- package/dist/folder/fix.js +191 -0
- package/dist/folder/flow.d.ts +42 -0
- package/dist/folder/flow.js +215 -0
- package/dist/folder/frontmatter.d.ts +21 -0
- package/dist/folder/frontmatter.js +91 -0
- package/dist/folder/index.d.ts +12 -0
- package/dist/folder/index.js +12 -0
- package/dist/folder/json-schema.d.ts +15 -0
- package/dist/folder/json-schema.js +212 -0
- package/dist/folder/json.d.ts +28 -0
- package/dist/folder/json.js +183 -0
- package/dist/folder/nested.d.ts +24 -0
- package/dist/folder/nested.js +378 -0
- package/dist/folder/plugins.d.ts +23 -0
- package/dist/folder/plugins.js +155 -0
- package/dist/folder/schemas.d.ts +8 -0
- package/dist/folder/schemas.js +238 -0
- package/dist/folder/suggest.d.ts +13 -0
- package/dist/folder/suggest.js +63 -0
- package/dist/schemas/agent-folder/agent-md.schema.json +143 -0
- package/dist/schemas/agent-folder/flow.schema.json +466 -0
- package/dist/schemas/agent-folder/mcp.schema.json +59 -0
- package/dist/schemas/agent-folder/runtime.schema.json +447 -0
- package/dist/schemas/agent-folder/tool.schema.json +77 -0
- package/dist/schemas/agent-folder/trigger-md.schema.json +65 -0
- package/dist/utils/runtime-limits.d.ts +8 -0
- package/dist/utils/runtime-limits.js +19 -0
- package/package.json +14 -3
package/dist/contracts.js
CHANGED
|
@@ -61,6 +61,8 @@ const mcpToolSettingsSchema = z
|
|
|
61
61
|
})
|
|
62
62
|
.strict()
|
|
63
63
|
.meta({ id: "McpToolSettings" });
|
|
64
|
+
/** One tool's settings on an MCP server: `enabled`, `approval` and `deferred`. */
|
|
65
|
+
export const McpToolSettingsSchema = mcpToolSettingsSchema;
|
|
64
66
|
/** Per-tool settings keyed by the server's tool names, `"*"` for the rest. */
|
|
65
67
|
const mcpServerSettings = {
|
|
66
68
|
deferred: z.boolean().optional(),
|
|
@@ -160,6 +162,8 @@ const httpToolTargetSchema = z
|
|
|
160
162
|
timeoutMs: z.number().int().positive().max(TIMER_MAX_MS).optional(),
|
|
161
163
|
})
|
|
162
164
|
.strict();
|
|
165
|
+
/** An HTTP tool's request: its `url` (a template of the input's fields), `method`, `credential` and `timeoutMs`. */
|
|
166
|
+
export const HttpToolTargetSchema = httpToolTargetSchema;
|
|
163
167
|
/** A name kept for a later kind of `what` (tool, verifier), refused for now. */
|
|
164
168
|
const reservedKind = (what) => z
|
|
165
169
|
.unknown()
|
|
@@ -635,7 +639,7 @@ export const EnvironmentFileSchema = z.union([
|
|
|
635
639
|
* letter or digit, such as `triage`; a version is at most 9 digits. Manifest names and Agent ids
|
|
636
640
|
* are separate namespaces.
|
|
637
641
|
*/
|
|
638
|
-
const AGENT_MANIFEST_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
642
|
+
export const AGENT_MANIFEST_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
639
643
|
export function isAgentManifestName(value) {
|
|
640
644
|
return typeof value === "string" && AGENT_MANIFEST_NAME_PATTERN.test(value);
|
|
641
645
|
}
|
|
@@ -1604,16 +1608,15 @@ const harnessLoopField = definitionJson
|
|
|
1604
1608
|
* `harness.memory`: turns the Agent's memory on. Its `access` holds in every turn,
|
|
1605
1609
|
* whoever starts it; `instructions` follow the engine's own memory rules.
|
|
1606
1610
|
*/
|
|
1607
|
-
const
|
|
1608
|
-
.strictObject({
|
|
1611
|
+
export const HarnessMemorySchema = z.strictObject({
|
|
1609
1612
|
access: z.enum(MEMORY_ACCESS).optional().meta({ description: "`read_write` (the default) or `read_only`" }),
|
|
1610
1613
|
instructions: z
|
|
1611
1614
|
.string()
|
|
1612
1615
|
.max(MEMORY_INSTRUCTIONS_MAX)
|
|
1613
1616
|
.optional()
|
|
1614
1617
|
.meta({ description: "What this agent should remember, after the engine's own memory rules" }),
|
|
1615
|
-
})
|
|
1616
|
-
|
|
1618
|
+
});
|
|
1619
|
+
const harnessMemoryField = HarnessMemorySchema.optional()
|
|
1617
1620
|
.meta({ description: "The Agent's memory: Markdown files under /memories it keeps across sessions" });
|
|
1618
1621
|
/** Fields the harness section refuses with where they went. */
|
|
1619
1622
|
const REMOVED_HARNESS_FIELDS = Object.freeze({
|
|
@@ -1999,6 +2002,55 @@ export const PutAgentManifestRequestSchema = AgentManifestV8Schema.extend({
|
|
|
1999
2002
|
/** Who saved a version: the subject a request acted for, else `application`. */
|
|
2000
2003
|
export const AgentManifestSavedBySchema = z.object({ actor: z.string() }).strict();
|
|
2001
2004
|
/** One version of an agent manifest. */
|
|
2005
|
+
/**
|
|
2006
|
+
* The edit that fixes a diagnostic, when only one edit can (track T7, `nylorun check --fix`):
|
|
2007
|
+
* `rename_key` renames the key at `line` and `column` of `file` from `from` to `to`, the one known
|
|
2008
|
+
* key it is close to; `crlf` makes `file`'s CRLF line ends LF; `move_skill_secrets` moves a
|
|
2009
|
+
* `SKILL.md`'s `secrets` to `AGENT.md`'s `skills` block, as `skills: { <skill>: { secrets } }`.
|
|
2010
|
+
*/
|
|
2011
|
+
export const AgentFolderFixSchema = z
|
|
2012
|
+
.discriminatedUnion("kind", [
|
|
2013
|
+
z
|
|
2014
|
+
.object({
|
|
2015
|
+
kind: z.literal("rename_key"),
|
|
2016
|
+
file: z.string(),
|
|
2017
|
+
line: z.number().int().positive(),
|
|
2018
|
+
column: z.number().int().positive(),
|
|
2019
|
+
from: z.string(),
|
|
2020
|
+
to: z.string(),
|
|
2021
|
+
})
|
|
2022
|
+
.strict(),
|
|
2023
|
+
z.object({ kind: z.literal("crlf"), file: z.string() }).strict(),
|
|
2024
|
+
z.object({ kind: z.literal("move_skill_secrets"), file: z.string(), skill: z.string(), secrets: z.array(z.string()) }).strict(),
|
|
2025
|
+
])
|
|
2026
|
+
.meta({ id: "AgentFolderFix" });
|
|
2027
|
+
/**
|
|
2028
|
+
* One problem or remark about an agent folder (track T6): an `error` keeps it from compiling.
|
|
2029
|
+
* `file` is the path in the folder, with the line and column when known; `pointer` the field in
|
|
2030
|
+
* the manifest; `fix` the edit that fixes it, when only one edit can.
|
|
2031
|
+
*/
|
|
2032
|
+
export const AgentFolderDiagnosticSchema = z
|
|
2033
|
+
.object({
|
|
2034
|
+
severity: z.enum(["error", "warning", "info", "note"]),
|
|
2035
|
+
code: z.string(),
|
|
2036
|
+
message: z.string(),
|
|
2037
|
+
file: z.string().optional(),
|
|
2038
|
+
line: z.number().int().positive().optional(),
|
|
2039
|
+
column: z.number().int().positive().optional(),
|
|
2040
|
+
pointer: z.string().optional(),
|
|
2041
|
+
fix: AgentFolderFixSchema.optional(),
|
|
2042
|
+
})
|
|
2043
|
+
.strict()
|
|
2044
|
+
.meta({ id: "AgentFolderDiagnostic" });
|
|
2045
|
+
/** The folder a version was compiled from (track T6): the compiler that built it, and its size. */
|
|
2046
|
+
export const AgentManifestSourceSummarySchema = z
|
|
2047
|
+
.object({
|
|
2048
|
+
/** The compiler format, such as `agent-folder/1`. */
|
|
2049
|
+
compiler: z.string(),
|
|
2050
|
+
files: z.number().int().nonnegative(),
|
|
2051
|
+
bytes: z.number().int().nonnegative(),
|
|
2052
|
+
})
|
|
2053
|
+
.strict();
|
|
2002
2054
|
export const AgentManifestViewSchema = z
|
|
2003
2055
|
.object({
|
|
2004
2056
|
name: z.string(),
|
|
@@ -2010,6 +2062,72 @@ export const AgentManifestViewSchema = z
|
|
|
2010
2062
|
createdAt: z.string(),
|
|
2011
2063
|
/** How many Agents were made from this version. */
|
|
2012
2064
|
agents: z.number().int().nonnegative(),
|
|
2065
|
+
/** The folder it was compiled from; absent for a version saved as JSON. */
|
|
2066
|
+
source: AgentManifestSourceSummarySchema.optional(),
|
|
2067
|
+
})
|
|
2068
|
+
.strict();
|
|
2069
|
+
/** One file of an agent folder: its path, size and SHA-256 (lowercase hex). */
|
|
2070
|
+
export const AgentFolderEntrySchema = z
|
|
2071
|
+
.object({
|
|
2072
|
+
path: z.string().min(1).max(1024),
|
|
2073
|
+
size: z.number().int().nonnegative(),
|
|
2074
|
+
sha256: z.string().regex(/^[0-9a-f]{64}$/, { message: "sha256 is 64 lowercase hex digits" }),
|
|
2075
|
+
contentType: z.string().optional(),
|
|
2076
|
+
mode: z.number().int().nonnegative().max(0o7777).optional(),
|
|
2077
|
+
})
|
|
2078
|
+
.strict();
|
|
2079
|
+
/** The media type of an agent folder sent by hash to `PUT /v1/agent-manifests/{name}`. */
|
|
2080
|
+
export const AGENT_FOLDER_MEDIA_TYPE = "application/vnd.nylorun.folder+json";
|
|
2081
|
+
/**
|
|
2082
|
+
* `PUT /v1/agent-manifests/{name}` with `Content-Type: application/vnd.nylorun.folder+json`
|
|
2083
|
+
* (track T6): an agent folder by hash, each file uploaded first with `PUT /v1/files/sha256:<hex>`.
|
|
2084
|
+
*/
|
|
2085
|
+
export const PutAgentFolderRequestSchema = z
|
|
2086
|
+
.object({
|
|
2087
|
+
requestId: RequestIdSchema.optional(),
|
|
2088
|
+
format: z.literal("nylorun.folder.v2"),
|
|
2089
|
+
entries: z.array(AgentFolderEntrySchema),
|
|
2090
|
+
})
|
|
2091
|
+
.strict();
|
|
2092
|
+
/** One file of a version's source: its path, size and SHA-256 (lowercase hex). */
|
|
2093
|
+
const AgentManifestSourceEntrySchema = z
|
|
2094
|
+
.object({ path: z.string(), size: z.number().int().nonnegative(), sha256: z.string() })
|
|
2095
|
+
.strict();
|
|
2096
|
+
/** `GET /v1/agent-manifests/{name}/versions/{v}/source`: the folder a version was compiled from. */
|
|
2097
|
+
export const AgentManifestSourceSchema = z
|
|
2098
|
+
.object({
|
|
2099
|
+
name: z.string(),
|
|
2100
|
+
version: z.number().int().positive(),
|
|
2101
|
+
compiler: z.string(),
|
|
2102
|
+
files: z.number().int().nonnegative(),
|
|
2103
|
+
bytes: z.number().int().nonnegative(),
|
|
2104
|
+
/** Every file, sorted by path. */
|
|
2105
|
+
entries: z.array(AgentManifestSourceEntrySchema),
|
|
2106
|
+
})
|
|
2107
|
+
.strict();
|
|
2108
|
+
/**
|
|
2109
|
+
* `GET /v1/agent-manifests/{name}/source/diff?from=&to=` (track T7): what changed between two
|
|
2110
|
+
* versions' sources, by path and SHA-256. Each list is sorted by path; `unchanged` counts the
|
|
2111
|
+
* files both hold with the same bytes.
|
|
2112
|
+
*/
|
|
2113
|
+
export const AgentManifestSourceDiffSchema = z
|
|
2114
|
+
.object({
|
|
2115
|
+
name: z.string(),
|
|
2116
|
+
from: z.number().int().positive(),
|
|
2117
|
+
to: z.number().int().positive(),
|
|
2118
|
+
/** Files only `to` holds. */
|
|
2119
|
+
added: z.array(AgentManifestSourceEntrySchema),
|
|
2120
|
+
/** Files only `from` holds. */
|
|
2121
|
+
removed: z.array(AgentManifestSourceEntrySchema),
|
|
2122
|
+
/** Files both hold with other bytes: each as `from` held it and as `to` does. */
|
|
2123
|
+
changed: z.array(z
|
|
2124
|
+
.object({
|
|
2125
|
+
path: z.string(),
|
|
2126
|
+
from: z.object({ size: z.number().int().nonnegative(), sha256: z.string() }).strict(),
|
|
2127
|
+
to: z.object({ size: z.number().int().nonnegative(), sha256: z.string() }).strict(),
|
|
2128
|
+
})
|
|
2129
|
+
.strict()),
|
|
2130
|
+
unchanged: z.number().int().nonnegative(),
|
|
2013
2131
|
})
|
|
2014
2132
|
.strict();
|
|
2015
2133
|
/** `GET /v1/agent-manifests`: each manifest's latest version, by name. */
|
|
@@ -2074,6 +2192,12 @@ export const AgentManifestPlanSchema = z
|
|
|
2074
2192
|
secrets: z.number().int().nonnegative(),
|
|
2075
2193
|
})
|
|
2076
2194
|
.strict(),
|
|
2195
|
+
/** An agent folder's only: the manifest it compiles to. */
|
|
2196
|
+
manifest: AgentManifestV8Schema.optional(),
|
|
2197
|
+
/** An agent folder's only: what the compiler noted, none of them errors. */
|
|
2198
|
+
diagnostics: z.array(AgentFolderDiagnosticSchema).optional(),
|
|
2199
|
+
/** An agent folder's only: the compiler format, such as `agent-folder/1`. */
|
|
2200
|
+
compiler: z.string().optional(),
|
|
2077
2201
|
})
|
|
2078
2202
|
.strict();
|
|
2079
2203
|
/** `PUT /v1/agent-manifests/{name}`: the version saved (or the latest, unchanged). */
|
|
@@ -2082,6 +2206,8 @@ export const SaveAgentManifestResponseSchema = z
|
|
|
2082
2206
|
manifest: AgentManifestViewSchema,
|
|
2083
2207
|
unchanged: z.boolean(),
|
|
2084
2208
|
warnings: z.array(AgentManifestWarningSchema),
|
|
2209
|
+
/** An agent folder's only: what the compiler noted, none of them errors. */
|
|
2210
|
+
diagnostics: z.array(AgentFolderDiagnosticSchema).optional(),
|
|
2085
2211
|
})
|
|
2086
2212
|
.strict();
|
|
2087
2213
|
export const DeleteAgentManifestResponseSchema = z
|
package/dist/define.d.ts
CHANGED
|
@@ -44,7 +44,8 @@ export { bindTool } from "./definition/bind-tool.js";
|
|
|
44
44
|
export { bindOutputContract } from "./definition/output-contract.js";
|
|
45
45
|
export type { TurnOutputContract } from "./definition/output-contract.js";
|
|
46
46
|
export { agentFrom } from "./definition/from.js";
|
|
47
|
-
export { harnessIdOf, harnessSectionOf, isWorkflowHarness, kindMeets, loopManifestOf, normalizeCredentialUrl, pluginsOf, runtimeOf, sandboxNeedOf, sectionGaps, type SandboxNeed, } from "./definition/sections.js";
|
|
47
|
+
export { harnessIdOf, harnessSectionOf, isWorkflowHarness, kindMeets, loopManifestOf, normalizeCredentialUrl, pluginsOf, runtimeOf, sandboxNeedOf, sectionGaps, sectionGapsAt, type SandboxNeed, type SectionGap, } from "./definition/sections.js";
|
|
48
|
+
export { cronScheduleIssue, isTimeZone, timeZoneNames } from "./definition/cron.js";
|
|
48
49
|
export { mediaReferenceOf, type MediaReference } from "./definition/media-reference.js";
|
|
49
50
|
export type { SessionToolRef } from "./definition/from.js";
|
|
50
51
|
export { schemaFromJSON } from "./definition/schema-json.js";
|
package/dist/define.js
CHANGED
|
@@ -23,7 +23,8 @@ export { isVariantOf } from "./definition/variant.js";
|
|
|
23
23
|
export { bindTool } from "./definition/bind-tool.js";
|
|
24
24
|
export { bindOutputContract } from "./definition/output-contract.js";
|
|
25
25
|
export { agentFrom } from "./definition/from.js";
|
|
26
|
-
export { harnessIdOf, harnessSectionOf, isWorkflowHarness, kindMeets, loopManifestOf, normalizeCredentialUrl, pluginsOf, runtimeOf, sandboxNeedOf, sectionGaps, } from "./definition/sections.js";
|
|
26
|
+
export { harnessIdOf, harnessSectionOf, isWorkflowHarness, kindMeets, loopManifestOf, normalizeCredentialUrl, pluginsOf, runtimeOf, sandboxNeedOf, sectionGaps, sectionGapsAt, } from "./definition/sections.js";
|
|
27
|
+
export { cronScheduleIssue, isTimeZone, timeZoneNames } from "./definition/cron.js";
|
|
27
28
|
export { mediaReferenceOf } from "./definition/media-reference.js";
|
|
28
29
|
export { schemaFromJSON } from "./definition/schema-json.js";
|
|
29
30
|
export { normalizeSchema } from "./definition/schema.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A trigger's `schedule` and `timezone`, checked with no clock and no Node API, so the CLI's
|
|
3
|
+
* offline check, the compiler and the Runtime read them alike. The cron is five fields (minute,
|
|
4
|
+
* hour, day of the month, month, day of the week), each `*`, a value, a range `a-b`, a step `/n`
|
|
5
|
+
* on any of those, or a list of them; months and days of the week also take their three-letter
|
|
6
|
+
* names (`JAN`, `MON`), in any case. Day 7 of the week is Sunday, as 0 is. The day of the month
|
|
7
|
+
* also takes `L` (its last day), and the day of the week `5L` (the month's last Friday) and
|
|
8
|
+
* `1#2` (its second Monday). `?` stands for `*` in either day field.
|
|
9
|
+
*/
|
|
10
|
+
/** Why `schedule` is not a five-field cron, worded for a person; undefined when it is one. */
|
|
11
|
+
export declare function cronScheduleIssue(schedule: string): string | undefined;
|
|
12
|
+
/** Whether `zone` is a time zone this platform knows: an IANA name, such as `Asia/Kolkata`. */
|
|
13
|
+
export declare function isTimeZone(zone: string): boolean;
|
|
14
|
+
/** The IANA time zones this platform knows, for a "did you mean"; empty where it cannot list them. */
|
|
15
|
+
export declare function timeZoneNames(): readonly string[];
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A trigger's `schedule` and `timezone`, checked with no clock and no Node API, so the CLI's
|
|
3
|
+
* offline check, the compiler and the Runtime read them alike. The cron is five fields (minute,
|
|
4
|
+
* hour, day of the month, month, day of the week), each `*`, a value, a range `a-b`, a step `/n`
|
|
5
|
+
* on any of those, or a list of them; months and days of the week also take their three-letter
|
|
6
|
+
* names (`JAN`, `MON`), in any case. Day 7 of the week is Sunday, as 0 is. The day of the month
|
|
7
|
+
* also takes `L` (its last day), and the day of the week `5L` (the month's last Friday) and
|
|
8
|
+
* `1#2` (its second Monday). `?` stands for `*` in either day field.
|
|
9
|
+
*/
|
|
10
|
+
const MONTHS = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
|
|
11
|
+
const DAYS = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
|
|
12
|
+
/** The most days each month can have, for a day of the month no listed month reaches. */
|
|
13
|
+
const MONTH_DAYS = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
14
|
+
const FIELDS = [
|
|
15
|
+
{ name: "minute", min: 0, max: 59 },
|
|
16
|
+
{ name: "hour", min: 0, max: 23 },
|
|
17
|
+
{ name: "day of the month", min: 1, max: 31 },
|
|
18
|
+
{ name: "month", min: 1, max: 12, names: MONTHS },
|
|
19
|
+
{ name: "day of the week", min: 0, max: 7, names: DAYS },
|
|
20
|
+
];
|
|
21
|
+
const DAY_OF_MONTH = 2;
|
|
22
|
+
const MONTH = 3;
|
|
23
|
+
const DAY_OF_WEEK = 4;
|
|
24
|
+
/** Why `schedule` is not a five-field cron, worded for a person; undefined when it is one. */
|
|
25
|
+
export function cronScheduleIssue(schedule) {
|
|
26
|
+
const parts = schedule.trim().split(/\s+/);
|
|
27
|
+
if (schedule.trim() === "" || parts.length !== 5)
|
|
28
|
+
return `schedule is five cron fields, minute hour day-of-month month day-of-week, such as "0 9 * * MON-FRI"; ${JSON.stringify(schedule)} has ${schedule.trim() === "" ? "none" : parts.length}`;
|
|
29
|
+
const fields = [];
|
|
30
|
+
for (const [index, field] of FIELDS.entries()) {
|
|
31
|
+
const read = readField(parts[index], index, field);
|
|
32
|
+
if (typeof read === "string")
|
|
33
|
+
return `schedule ${JSON.stringify(schedule)}: ${read}`;
|
|
34
|
+
fields.push(read);
|
|
35
|
+
}
|
|
36
|
+
// A day of the month no listed month has never comes, unless a day of the week is listed too
|
|
37
|
+
// (the cron then runs on either).
|
|
38
|
+
const days = fields[DAY_OF_MONTH];
|
|
39
|
+
const months = fields[MONTH];
|
|
40
|
+
if (!days.every && !days.special && fields[DAY_OF_WEEK].every) {
|
|
41
|
+
const longest = Math.max(...(months.every ? MONTH_DAYS : [...months.values].map((month) => MONTH_DAYS[month - 1])));
|
|
42
|
+
const first = Math.min(...days.values);
|
|
43
|
+
if (first > longest)
|
|
44
|
+
return `schedule ${JSON.stringify(schedule)} never runs: no month it lists has day ${first}`;
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
/** What a field lists, or why it is not valid. */
|
|
49
|
+
function readField(text, index, field) {
|
|
50
|
+
const values = new Set();
|
|
51
|
+
let every = false;
|
|
52
|
+
let special = false;
|
|
53
|
+
for (const item of text.split(",")) {
|
|
54
|
+
if (item === "")
|
|
55
|
+
return `the ${field.name} has an empty entry between commas`;
|
|
56
|
+
if ((item === "?" || item === "*") && (item === "*" || index === DAY_OF_MONTH || index === DAY_OF_WEEK)) {
|
|
57
|
+
every = true;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (index === DAY_OF_MONTH && item.toUpperCase() === "L") {
|
|
61
|
+
special = true;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (index === DAY_OF_WEEK) {
|
|
65
|
+
const last = /^(\w+)L$/i.exec(item);
|
|
66
|
+
const nth = /^(\w+)#(\w+)$/.exec(item);
|
|
67
|
+
if (last || nth) {
|
|
68
|
+
const day = valueOf(last ? last[1] : nth[1], field);
|
|
69
|
+
if (typeof day === "string")
|
|
70
|
+
return day;
|
|
71
|
+
if (nth && !/^(?:[1-5]|L)$/i.test(nth[2]))
|
|
72
|
+
return `#${nth[2]} in ${item} is which ${DAYS[day % 7]} of the month: 1 to 5, or L for the last`;
|
|
73
|
+
special = true;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const slash = item.split("/");
|
|
78
|
+
if (slash.length > 2)
|
|
79
|
+
return `${item} has two steps: write one, such as */15`;
|
|
80
|
+
const [base, step] = slash;
|
|
81
|
+
if (step !== undefined && !/^\d+$/.test(step))
|
|
82
|
+
return `the step in ${item} is a whole number, such as */15`;
|
|
83
|
+
if (step !== undefined && Number(step) === 0)
|
|
84
|
+
return `the step in ${item} is 0: a step is 1 or more`;
|
|
85
|
+
let from = field.min;
|
|
86
|
+
let to = field.max;
|
|
87
|
+
if (base !== "*" && !(base === "?" && (index === DAY_OF_MONTH || index === DAY_OF_WEEK))) {
|
|
88
|
+
const range = base.split("-");
|
|
89
|
+
if (range.length > 2 || range.some((part) => part === ""))
|
|
90
|
+
return `${item} is not a value or a range of the ${field.name}, such as ${field.names ? `${field.names[1]}-${field.names[3]}` : `${field.min}-${field.min + 2}`}`;
|
|
91
|
+
const low = valueOf(range[0], field);
|
|
92
|
+
if (typeof low === "string")
|
|
93
|
+
return low;
|
|
94
|
+
const high = range.length === 2 ? valueOf(range[1], field) : step === undefined ? low : field.max;
|
|
95
|
+
if (typeof high === "string")
|
|
96
|
+
return high;
|
|
97
|
+
if (low > high)
|
|
98
|
+
return `the range ${base} runs backwards: write it from the lower value`;
|
|
99
|
+
from = low;
|
|
100
|
+
to = high;
|
|
101
|
+
}
|
|
102
|
+
else if (step === undefined)
|
|
103
|
+
every = true;
|
|
104
|
+
for (let value = from; value <= to; value += Number(step ?? 1))
|
|
105
|
+
values.add(value);
|
|
106
|
+
}
|
|
107
|
+
return { values, every, special };
|
|
108
|
+
}
|
|
109
|
+
/** The number a field's value stands for, or why it is none. */
|
|
110
|
+
function valueOf(text, field) {
|
|
111
|
+
if (/^\d+$/.test(text)) {
|
|
112
|
+
const value = Number(text);
|
|
113
|
+
if (value < field.min || value > field.max)
|
|
114
|
+
return `the ${field.name} is ${field.min}-${field.max}, and ${text} is not`;
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
const names = field.names;
|
|
118
|
+
const at = names?.indexOf(text.toUpperCase()) ?? -1;
|
|
119
|
+
if (names && at >= 0)
|
|
120
|
+
return field.min + at;
|
|
121
|
+
const close = names?.find((name) => text.toUpperCase().startsWith(name));
|
|
122
|
+
return `${JSON.stringify(text)} is not a ${field.name}: write ${field.min}-${field.max}${names ? ` or ${names[0]}-${names.at(-1)}` : ""}${close ? `. Did you mean ${close}?` : ""}`;
|
|
123
|
+
}
|
|
124
|
+
/** Whether `zone` is a time zone this platform knows: an IANA name, such as `Asia/Kolkata`. */
|
|
125
|
+
export function isTimeZone(zone) {
|
|
126
|
+
try {
|
|
127
|
+
new Intl.DateTimeFormat(undefined, { timeZone: zone });
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Current IANA names that platforms list under an older one (`Intl.supportedValuesOf` gives
|
|
136
|
+
* `Asia/Calcutta`), so a "did you mean" offers the name people write today.
|
|
137
|
+
*/
|
|
138
|
+
const CURRENT_ZONE_NAMES = [
|
|
139
|
+
"Asia/Kolkata",
|
|
140
|
+
"Asia/Ho_Chi_Minh",
|
|
141
|
+
"Asia/Kathmandu",
|
|
142
|
+
"Asia/Yangon",
|
|
143
|
+
"Europe/Kyiv",
|
|
144
|
+
"America/Argentina/Buenos_Aires",
|
|
145
|
+
"America/Nuuk",
|
|
146
|
+
"Atlantic/Faroe",
|
|
147
|
+
"Pacific/Chuuk",
|
|
148
|
+
"Pacific/Pohnpei",
|
|
149
|
+
];
|
|
150
|
+
/** The IANA time zones this platform knows, for a "did you mean"; empty where it cannot list them. */
|
|
151
|
+
export function timeZoneNames() {
|
|
152
|
+
if (typeof Intl.supportedValuesOf !== "function")
|
|
153
|
+
return [];
|
|
154
|
+
return [...CURRENT_ZONE_NAMES.filter(isTimeZone), ...Intl.supportedValuesOf("timeZone")];
|
|
155
|
+
}
|
|
@@ -41,6 +41,17 @@ export declare function runtimeOf(manifest: Pick<AgentManifestV8, "runtime">): R
|
|
|
41
41
|
* 3. The runtime's kind gives the harness the sandbox it needs (`sandboxNeedOf`).
|
|
42
42
|
*/
|
|
43
43
|
export declare function sectionGaps(manifest: Pick<AgentManifestV8, "harness" | "runtime">): string[];
|
|
44
|
+
/** One gap of `sectionGapsAt`: the manifest field it is about, and why. */
|
|
45
|
+
export interface SectionGap {
|
|
46
|
+
/** The field in the manifest, such as `["harness", "tools", 0, "http", "credential"]`. */
|
|
47
|
+
readonly path: readonly (string | number)[];
|
|
48
|
+
readonly message: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `sectionGaps`, each with the manifest field it is about, so a caller that knows where each
|
|
52
|
+
* field came from (the agent folder compiler) can point at the file that wrote it.
|
|
53
|
+
*/
|
|
54
|
+
export declare function sectionGapsAt(manifest: Pick<AgentManifestV8, "harness" | "runtime">): SectionGap[];
|
|
44
55
|
/**
|
|
45
56
|
* The loop manifest the harness runs for a version of an agent manifest: the harness section
|
|
46
57
|
* with the manifest's name as its id, in the shape the engine reads (agent manifest v7, workflow
|
|
@@ -76,76 +76,85 @@ export function runtimeOf(manifest) {
|
|
|
76
76
|
* 3. The runtime's kind gives the harness the sandbox it needs (`sandboxNeedOf`).
|
|
77
77
|
*/
|
|
78
78
|
export function sectionGaps(manifest) {
|
|
79
|
+
return sectionGapsAt(manifest).map((gap) => gap.message);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* `sectionGaps`, each with the manifest field it is about, so a caller that knows where each
|
|
83
|
+
* field came from (the agent folder compiler) can point at the file that wrote it.
|
|
84
|
+
*/
|
|
85
|
+
export function sectionGapsAt(manifest) {
|
|
79
86
|
const { harness } = manifest;
|
|
80
87
|
const runtime = runtimeOf(manifest);
|
|
81
88
|
const gaps = [];
|
|
89
|
+
const gap = (path, message) => gaps.push({ path, message });
|
|
82
90
|
const kindText = manifest.runtime === undefined ? "the manifest has no runtime section" : `the runtime is ${quoted(runtime.kind)}`;
|
|
83
91
|
// 1. A custom harness runs from its pod's image.
|
|
84
92
|
const harnessId = harnessIdOf(harness);
|
|
85
93
|
if (harnessId !== DEFAULT_HARNESS) {
|
|
86
94
|
if (runtime.kind !== "pod")
|
|
87
|
-
|
|
95
|
+
gap(["harness", "id"], `harness.id ${quoted(harnessId)} needs runtime.kind "pod"; ${kindText}`);
|
|
88
96
|
else if (runtime.image === undefined)
|
|
89
|
-
|
|
97
|
+
gap(["harness", "id"], `harness.id ${quoted(harnessId)} needs runtime.image: a custom harness runs from its pod's image`);
|
|
90
98
|
}
|
|
91
99
|
// 2. Credentials name declared slots of the right type.
|
|
92
100
|
const slots = runtime.secrets ?? {};
|
|
93
|
-
const urlSlot = (where, name, url, what) => {
|
|
101
|
+
const urlSlot = (where, path, name, url, what) => {
|
|
94
102
|
const slot = slots[name];
|
|
95
103
|
if (slot === undefined) {
|
|
96
|
-
|
|
104
|
+
gap(path, `${where} ${quoted(name)} is not a secret slot in runtime.secrets`);
|
|
97
105
|
return;
|
|
98
106
|
}
|
|
99
107
|
if (slot.type !== "bearer" && slot.type !== "headers") {
|
|
100
|
-
|
|
108
|
+
gap(path, `${where} ${quoted(name)} is a slot of type ${slot.type}; ${what} needs a bearer or headers slot`);
|
|
101
109
|
return;
|
|
102
110
|
}
|
|
103
111
|
const want = normalizeCredentialUrl(url);
|
|
104
112
|
if (want === undefined || normalizeCredentialUrl(slot.url) !== want)
|
|
105
|
-
|
|
113
|
+
gap(path, `${where} ${quoted(name)} is bound to ${slot.url}, not to ${what}'s URL ${url}`);
|
|
106
114
|
};
|
|
107
115
|
// The Tool Gate sends an HTTP target's `credential` from the vault by that name, wherever the
|
|
108
116
|
// target sits: an agent's HTTP tool, a flow's HTTP stage or HTTP verifier, or one of an
|
|
109
117
|
// embedded agent's.
|
|
110
|
-
const agentTools = (tools, at) => {
|
|
111
|
-
for (const tool of tools ?? []) {
|
|
118
|
+
const agentTools = (tools, at, path) => {
|
|
119
|
+
for (const [index, tool] of (tools ?? []).entries()) {
|
|
112
120
|
if (tool.http?.credential !== undefined)
|
|
113
|
-
urlSlot(`${at}.tools.${tool.name}.http.credential`, tool.http.credential, tool.http.url, "an HTTP tool");
|
|
121
|
+
urlSlot(`${at}.tools.${tool.name}.http.credential`, [...path, "tools", index, "http", "credential"], tool.http.credential, tool.http.url, "an HTTP tool");
|
|
114
122
|
if (tool.agent !== undefined)
|
|
115
|
-
embedded(tool.agent, `${at}.tools.${tool.name}.agent
|
|
123
|
+
embedded(tool.agent, `${at}.tools.${tool.name}.agent`, [...path, "tools", index, "agent"]);
|
|
116
124
|
}
|
|
117
125
|
};
|
|
118
|
-
const flowStages = (flow, at) => {
|
|
126
|
+
const flowStages = (flow, at, path) => {
|
|
119
127
|
forEachFlowNode(flow.root, ({ node, key, role }) => {
|
|
120
128
|
const http = "http" in node ? node.http : "tool" in node ? node.tool.http : undefined;
|
|
121
129
|
if (http?.credential !== undefined)
|
|
122
|
-
urlSlot(`${at}.root stage ${quoted(key)} http.credential`, http.credential, http.url, role === "verify" ? "an HTTP verifier" : "an HTTP stage");
|
|
130
|
+
urlSlot(`${at}.root stage ${quoted(key)} http.credential`, [...path, "root"], http.credential, http.url, role === "verify" ? "an HTTP verifier" : "an HTTP stage");
|
|
123
131
|
});
|
|
124
132
|
for (const [id, agent] of Object.entries(flow.agents))
|
|
125
|
-
embedded(agent, `${at}.agents.${id}
|
|
133
|
+
embedded(agent, `${at}.agents.${id}`, [...path, "agents", id]);
|
|
126
134
|
};
|
|
127
|
-
const embedded = (agent, at) => "kind" in agent ? flowStages(agent, at) : agentTools(agent.tools, at);
|
|
135
|
+
const embedded = (agent, at, path) => "kind" in agent ? flowStages(agent, at, path) : agentTools(agent.tools, at, path);
|
|
128
136
|
if (isWorkflowHarness(harness))
|
|
129
|
-
flowStages(harness, "harness");
|
|
137
|
+
flowStages(harness, "harness", ["harness"]);
|
|
130
138
|
else {
|
|
131
139
|
for (const [key, server] of Object.entries(harness.mcpServers ?? {}))
|
|
132
140
|
if (server.credential !== undefined)
|
|
133
|
-
urlSlot(`harness.mcpServers.${key}.credential`, server.credential, server.url, "an MCP server");
|
|
134
|
-
agentTools(harness.tools, "harness");
|
|
141
|
+
urlSlot(`harness.mcpServers.${key}.credential`, ["harness", "mcpServers", key, "credential"], server.credential, server.url, "an MCP server");
|
|
142
|
+
agentTools(harness.tools, "harness", ["harness"]);
|
|
135
143
|
for (const [key, skill] of Object.entries(harness.skills ?? {}))
|
|
136
144
|
for (const name of skill.secrets ?? []) {
|
|
137
145
|
const slot = slots[name];
|
|
146
|
+
const path = ["harness", "skills", key, "secrets"];
|
|
138
147
|
if (slot === undefined)
|
|
139
|
-
|
|
148
|
+
gap(path, `harness.skills.${key}.secrets ${quoted(name)} is not a secret slot in runtime.secrets`);
|
|
140
149
|
else if (slot.type !== "environment_secret" && slot.type !== "environment_variable")
|
|
141
|
-
|
|
150
|
+
gap(path, `harness.skills.${key}.secrets ${quoted(name)} is a slot of type ${slot.type}; a skill reads environment_secret or environment_variable slots`);
|
|
142
151
|
}
|
|
143
152
|
}
|
|
144
153
|
// 3. The sandbox the loop needs. A custom harness's pod is gap 1.
|
|
145
154
|
const need = sandboxNeedOf(harness);
|
|
146
155
|
if (need === "sandbox" && !kindMeets(runtime.kind, need)) {
|
|
147
156
|
const what = isWorkflowHarness(harness) ? "harness.agents carry skills, which need" : "harness.skills needs";
|
|
148
|
-
|
|
157
|
+
gap(["harness", isWorkflowHarness(harness) ? "agents" : "skills"], manifest.runtime === undefined
|
|
149
158
|
? `${what} a sandbox; the manifest has no runtime section, so an Agent made from it has none`
|
|
150
159
|
: `${what} a sandbox; runtime.kind ${quoted(runtime.kind)} has none`);
|
|
151
160
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type AgentFolderFix, type AgentManifestV8 } from "../contracts.js";
|
|
2
|
+
import { type FolderScope } from "./nested.js";
|
|
3
|
+
/** The compiler format this version builds: a folder with no `format`, or `format: 1`. */
|
|
4
|
+
export declare const AGENT_FOLDER_COMPILER = "agent-folder/1";
|
|
5
|
+
/**
|
|
6
|
+
* What a folder may hold, unless `compileAgentFolder` is given other limits (a Tenant's Runtime
|
|
7
|
+
* limits `folderFiles`, `folderBytes` and `folderTextFileBytes`, which default to these).
|
|
8
|
+
*/
|
|
9
|
+
export declare const AGENT_FOLDER_LIMITS: Readonly<{
|
|
10
|
+
/** Files in one folder. */
|
|
11
|
+
files: 2000;
|
|
12
|
+
/** Every file's bytes together. */
|
|
13
|
+
totalBytes: number;
|
|
14
|
+
/** One Markdown or JSON file the compiler reads. */
|
|
15
|
+
textFileBytes: number;
|
|
16
|
+
}>;
|
|
17
|
+
/** One file of a folder: its `/`-separated path, size and SHA-256 (lowercase hex). */
|
|
18
|
+
export interface AgentFolderEntry {
|
|
19
|
+
readonly path: string;
|
|
20
|
+
readonly size: number;
|
|
21
|
+
readonly sha256: string;
|
|
22
|
+
}
|
|
23
|
+
export type { AgentFolderFix };
|
|
24
|
+
/**
|
|
25
|
+
* One problem or remark: an `error` keeps the folder from compiling; `warning`, `info` and
|
|
26
|
+
* `note` do not. `file` is the folder path it is about, with the line and column when known,
|
|
27
|
+
* and `pointer` the field in the manifest when it is about one. `fix` is the edit that fixes it
|
|
28
|
+
* (`nylorun check --fix`), only where one edit can: an unknown key with one did-you-mean, CRLF
|
|
29
|
+
* line ends, and a `SKILL.md`'s `secrets`. It changes no manifest.
|
|
30
|
+
*/
|
|
31
|
+
export interface AgentFolderDiagnostic {
|
|
32
|
+
readonly severity: "error" | "warning" | "info" | "note";
|
|
33
|
+
readonly code: string;
|
|
34
|
+
readonly message: string;
|
|
35
|
+
readonly file?: string;
|
|
36
|
+
readonly line?: number;
|
|
37
|
+
readonly column?: number;
|
|
38
|
+
readonly pointer?: string;
|
|
39
|
+
readonly fix?: AgentFolderFix;
|
|
40
|
+
}
|
|
41
|
+
export interface CompileAgentFolderInput {
|
|
42
|
+
readonly entries: readonly AgentFolderEntry[];
|
|
43
|
+
/** The bytes of each file `folderTextPaths(entries)` names. */
|
|
44
|
+
readonly files: ReadonlyMap<string, Uint8Array>;
|
|
45
|
+
/** The name the manifest must have: the path's, or the folder's. */
|
|
46
|
+
readonly name?: string;
|
|
47
|
+
/** What the folder may hold; each left out is `AGENT_FOLDER_LIMITS`'. */
|
|
48
|
+
readonly limits?: Partial<AgentFolderLimits>;
|
|
49
|
+
}
|
|
50
|
+
/** What a folder may hold: its files, their bytes together, and one Markdown or JSON file. */
|
|
51
|
+
export interface AgentFolderLimits {
|
|
52
|
+
readonly files: number;
|
|
53
|
+
readonly totalBytes: number;
|
|
54
|
+
readonly textFileBytes: number;
|
|
55
|
+
}
|
|
56
|
+
export interface CompiledAgentFolder {
|
|
57
|
+
/** The manifest, when nothing is an error. */
|
|
58
|
+
readonly manifest?: AgentManifestV8;
|
|
59
|
+
readonly diagnostics: readonly AgentFolderDiagnostic[];
|
|
60
|
+
readonly compiler: typeof AGENT_FOLDER_COMPILER;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The schemas a JSON file of a folder may name in `$schema`, by the kind of file: ours first,
|
|
64
|
+
* whose documents `schemas.ts` builds from the key lists below.
|
|
65
|
+
*/
|
|
66
|
+
export declare const FOLDER_SCHEMAS = "https://docs.nylorun.com/schemas/agent-folder/v1/";
|
|
67
|
+
export declare const SCHEMA_URLS: {
|
|
68
|
+
readonly runtime: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/runtime.json", "https://docs.nylorun.com/schemas/runtime-manifest/v1.json"];
|
|
69
|
+
readonly tool: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/tool.json"];
|
|
70
|
+
readonly mcp: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/mcp.json", "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json"];
|
|
71
|
+
readonly flow: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/flow.json"];
|
|
72
|
+
};
|
|
73
|
+
export declare const AGENT_KEYS: readonly ["name", "description", "format", "harness", "inputSchema", "outputSchema", "mcpServers", "skills", "memory", "loop", "metadata"];
|
|
74
|
+
export declare const TRIGGER_KEYS: readonly ["schedule", "timezone", "at", "webhook", "session"];
|
|
75
|
+
export declare const MCP_KEYS: readonly ["$schema", "mcpServers"];
|
|
76
|
+
export declare const SERVER_KEYS: readonly ["type", "url", "headers"];
|
|
77
|
+
export declare const SERVER_SETTING_KEYS: readonly ["deferred", "tools"];
|
|
78
|
+
/** What `AGENT.md` may also set for a plugin's server, which cannot know the agent's slot names. */
|
|
79
|
+
export declare const PLUGIN_SERVER_SETTING_KEYS: readonly ["deferred", "tools", "credential"];
|
|
80
|
+
export declare const TOOL_KEYS: readonly ["description", "inputSchema", "outputSchema", "http"];
|
|
81
|
+
/** The files the compiler reads: the Runtime and the CLI pass their bytes in. */
|
|
82
|
+
export declare function folderTextPaths(entries: readonly AgentFolderEntry[]): string[];
|
|
83
|
+
/**
|
|
84
|
+
* Compiles an agent folder into agent manifest v8, with every diagnostic. `scope` is internal: the
|
|
85
|
+
* compiler sets it when it compiles a folder inside another (`agents/<id>/`, a plugin's parts).
|
|
86
|
+
*/
|
|
87
|
+
export declare function compileAgentFolder(input: CompileAgentFolderInput, scope?: FolderScope): CompiledAgentFolder;
|