@nylorun/core 0.25.0-beta → 0.27.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 +15 -0
- package/README.md +4 -0
- package/dist/compatibility.d.ts +14 -2
- package/dist/compatibility.js +14 -0
- package/dist/contracts.d.ts +339 -6
- package/dist/contracts.js +148 -6
- package/dist/folder/compile.d.ts +49 -0
- package/dist/folder/compile.js +869 -0
- package/dist/folder/frontmatter.d.ts +18 -0
- package/dist/folder/frontmatter.js +87 -0
- package/dist/folder/index.d.ts +7 -0
- package/dist/folder/index.js +7 -0
- package/dist/folder/json.d.ts +28 -0
- package/dist/folder/json.js +183 -0
- package/package.json +7 -2
package/dist/contracts.js
CHANGED
|
@@ -1320,11 +1320,29 @@ export const CredentialViaSchema = z.string().superRefine((value, ctx) => {
|
|
|
1320
1320
|
* owner (the reserved `installation`) sends none.
|
|
1321
1321
|
*/
|
|
1322
1322
|
export const CredentialIdentitySchema = z.object({ header: CredentialHeaderNameSchema }).strict();
|
|
1323
|
+
/**
|
|
1324
|
+
* `toolPrefix`: what the gateway at `via` puts before each tool name it lists, such as
|
|
1325
|
+
* LiteLLM's `github-` (Host feature `gateway-credentials`). The Runtime lists the server's tools
|
|
1326
|
+
* without it, so tool names, a manifest's `tools` settings and tool policy rules name the server's
|
|
1327
|
+
* own tools, and calls a tool by the name the gateway listed. Only with `via`, and only on an
|
|
1328
|
+
* Agent's secret: how a gateway names tools is the installation's routing, never a manifest's.
|
|
1329
|
+
*/
|
|
1330
|
+
export const CredentialToolPrefixSchema = z
|
|
1331
|
+
.string()
|
|
1332
|
+
.min(1)
|
|
1333
|
+
.max(64)
|
|
1334
|
+
.regex(/^[\x21-\x7e]+$/, "A tool prefix is printable ASCII with no spaces");
|
|
1323
1335
|
/** Where a credential's requests go, and whom they name. Neither is secret. */
|
|
1324
1336
|
const credentialRouting = {
|
|
1325
1337
|
via: CredentialViaSchema.optional(),
|
|
1326
1338
|
identity: CredentialIdentitySchema.optional(),
|
|
1327
1339
|
};
|
|
1340
|
+
/** A `toolPrefix` names how a gateway lists tools, so it needs the gateway's `via`. */
|
|
1341
|
+
const prefixNeedsVia = (routing) => routing.toolPrefix === undefined || routing.via !== undefined;
|
|
1342
|
+
const PREFIX_NEEDS_VIA = {
|
|
1343
|
+
message: "toolPrefix needs via: it is how the gateway there names tools",
|
|
1344
|
+
path: ["toolPrefix"],
|
|
1345
|
+
};
|
|
1328
1346
|
/** On rotate: absent keeps the current value, `null` removes it. */
|
|
1329
1347
|
const credentialRoutingChange = {
|
|
1330
1348
|
via: CredentialViaSchema.nullable().optional(),
|
|
@@ -1448,8 +1466,10 @@ export const PutAgentSecretRequestSchema = z.discriminatedUnion("type", [
|
|
|
1448
1466
|
url: z.string().min(1),
|
|
1449
1467
|
value: z.string().min(1),
|
|
1450
1468
|
...credentialRouting,
|
|
1469
|
+
toolPrefix: CredentialToolPrefixSchema.optional(),
|
|
1451
1470
|
})
|
|
1452
|
-
.strict()
|
|
1471
|
+
.strict()
|
|
1472
|
+
.refine(prefixNeedsVia, PREFIX_NEEDS_VIA),
|
|
1453
1473
|
z
|
|
1454
1474
|
.object({
|
|
1455
1475
|
requestId: RequestIdSchema.optional(),
|
|
@@ -1457,18 +1477,38 @@ export const PutAgentSecretRequestSchema = z.discriminatedUnion("type", [
|
|
|
1457
1477
|
url: z.string().min(1),
|
|
1458
1478
|
headers: CredentialHeadersSchema,
|
|
1459
1479
|
...credentialRouting,
|
|
1480
|
+
toolPrefix: CredentialToolPrefixSchema.optional(),
|
|
1481
|
+
})
|
|
1482
|
+
.strict()
|
|
1483
|
+
.refine(prefixNeedsVia, PREFIX_NEEDS_VIA),
|
|
1484
|
+
/**
|
|
1485
|
+
* The Runtime's workload token as the bearer (#496): no value is stored. Each request reads
|
|
1486
|
+
* `NYLORUN_WORKLOAD_TOKEN_FILE` and sends `Authorization: Bearer <token>` to `via` only, a
|
|
1487
|
+
* gateway whose origin the operator lists in `NYLORUN_WORKLOAD_TOKEN_ORIGINS`.
|
|
1488
|
+
*/
|
|
1489
|
+
z
|
|
1490
|
+
.object({
|
|
1491
|
+
requestId: RequestIdSchema.optional(),
|
|
1492
|
+
type: z.literal("workload"),
|
|
1493
|
+
url: z.string().min(1),
|
|
1494
|
+
via: CredentialViaSchema,
|
|
1495
|
+
identity: CredentialIdentitySchema.optional(),
|
|
1496
|
+
toolPrefix: CredentialToolPrefixSchema.optional(),
|
|
1460
1497
|
})
|
|
1461
1498
|
.strict(),
|
|
1462
1499
|
]);
|
|
1463
1500
|
/**
|
|
1464
1501
|
* A secret write on an Environment whose manifest declares the secret's slot: only the
|
|
1465
|
-
* value, `value` (or `headers` for a `headers` slot). Its type and binding come from the slot
|
|
1502
|
+
* value, `value` (or `headers` for a `headers` slot). Its type and binding come from the slot,
|
|
1503
|
+
* except the gateway's `toolPrefix`, which this installation's write may add to a slot with `via`.
|
|
1466
1504
|
*/
|
|
1467
1505
|
export const PutAgentSecretValueRequestSchema = z
|
|
1468
1506
|
.object({
|
|
1469
1507
|
requestId: RequestIdSchema.optional(),
|
|
1470
1508
|
value: z.string().min(1).optional(),
|
|
1471
1509
|
headers: CredentialHeadersSchema.optional(),
|
|
1510
|
+
/** A `bearer` or `headers` slot with `via`: how the gateway there prefixes tool names. */
|
|
1511
|
+
toolPrefix: CredentialToolPrefixSchema.optional(),
|
|
1472
1512
|
})
|
|
1473
1513
|
.strict()
|
|
1474
1514
|
.refine((body) => (body.value === undefined) !== (body.headers === undefined), {
|
|
@@ -1959,6 +1999,32 @@ export const PutAgentManifestRequestSchema = AgentManifestV8Schema.extend({
|
|
|
1959
1999
|
/** Who saved a version: the subject a request acted for, else `application`. */
|
|
1960
2000
|
export const AgentManifestSavedBySchema = z.object({ actor: z.string() }).strict();
|
|
1961
2001
|
/** One version of an agent manifest. */
|
|
2002
|
+
/**
|
|
2003
|
+
* One problem or remark about an agent folder (track T6): an `error` keeps it from compiling.
|
|
2004
|
+
* `file` is the path in the folder, with the line and column when known; `pointer` the field in
|
|
2005
|
+
* the manifest.
|
|
2006
|
+
*/
|
|
2007
|
+
export const AgentFolderDiagnosticSchema = z
|
|
2008
|
+
.object({
|
|
2009
|
+
severity: z.enum(["error", "warning", "info", "note"]),
|
|
2010
|
+
code: z.string(),
|
|
2011
|
+
message: z.string(),
|
|
2012
|
+
file: z.string().optional(),
|
|
2013
|
+
line: z.number().int().positive().optional(),
|
|
2014
|
+
column: z.number().int().positive().optional(),
|
|
2015
|
+
pointer: z.string().optional(),
|
|
2016
|
+
})
|
|
2017
|
+
.strict()
|
|
2018
|
+
.meta({ id: "AgentFolderDiagnostic" });
|
|
2019
|
+
/** The folder a version was compiled from (track T6): the compiler that built it, and its size. */
|
|
2020
|
+
export const AgentManifestSourceSummarySchema = z
|
|
2021
|
+
.object({
|
|
2022
|
+
/** The compiler format, such as `agent-folder/1`. */
|
|
2023
|
+
compiler: z.string(),
|
|
2024
|
+
files: z.number().int().nonnegative(),
|
|
2025
|
+
bytes: z.number().int().nonnegative(),
|
|
2026
|
+
})
|
|
2027
|
+
.strict();
|
|
1962
2028
|
export const AgentManifestViewSchema = z
|
|
1963
2029
|
.object({
|
|
1964
2030
|
name: z.string(),
|
|
@@ -1970,6 +2036,43 @@ export const AgentManifestViewSchema = z
|
|
|
1970
2036
|
createdAt: z.string(),
|
|
1971
2037
|
/** How many Agents were made from this version. */
|
|
1972
2038
|
agents: z.number().int().nonnegative(),
|
|
2039
|
+
/** The folder it was compiled from; absent for a version saved as JSON. */
|
|
2040
|
+
source: AgentManifestSourceSummarySchema.optional(),
|
|
2041
|
+
})
|
|
2042
|
+
.strict();
|
|
2043
|
+
/** One file of an agent folder: its path, size and SHA-256 (lowercase hex). */
|
|
2044
|
+
export const AgentFolderEntrySchema = z
|
|
2045
|
+
.object({
|
|
2046
|
+
path: z.string().min(1).max(1024),
|
|
2047
|
+
size: z.number().int().nonnegative(),
|
|
2048
|
+
sha256: z.string().regex(/^[0-9a-f]{64}$/, { message: "sha256 is 64 lowercase hex digits" }),
|
|
2049
|
+
contentType: z.string().optional(),
|
|
2050
|
+
mode: z.number().int().nonnegative().max(0o7777).optional(),
|
|
2051
|
+
})
|
|
2052
|
+
.strict();
|
|
2053
|
+
/** The media type of an agent folder sent by hash to `PUT /v1/agent-manifests/{name}`. */
|
|
2054
|
+
export const AGENT_FOLDER_MEDIA_TYPE = "application/vnd.nylorun.folder+json";
|
|
2055
|
+
/**
|
|
2056
|
+
* `PUT /v1/agent-manifests/{name}` with `Content-Type: application/vnd.nylorun.folder+json`
|
|
2057
|
+
* (track T6): an agent folder by hash, each file uploaded first with `PUT /v1/files/sha256:<hex>`.
|
|
2058
|
+
*/
|
|
2059
|
+
export const PutAgentFolderRequestSchema = z
|
|
2060
|
+
.object({
|
|
2061
|
+
requestId: RequestIdSchema.optional(),
|
|
2062
|
+
format: z.literal("nylorun.folder.v2"),
|
|
2063
|
+
entries: z.array(AgentFolderEntrySchema),
|
|
2064
|
+
})
|
|
2065
|
+
.strict();
|
|
2066
|
+
/** `GET /v1/agent-manifests/{name}/versions/{v}/source`: the folder a version was compiled from. */
|
|
2067
|
+
export const AgentManifestSourceSchema = z
|
|
2068
|
+
.object({
|
|
2069
|
+
name: z.string(),
|
|
2070
|
+
version: z.number().int().positive(),
|
|
2071
|
+
compiler: z.string(),
|
|
2072
|
+
files: z.number().int().nonnegative(),
|
|
2073
|
+
bytes: z.number().int().nonnegative(),
|
|
2074
|
+
/** Every file, sorted by path. */
|
|
2075
|
+
entries: z.array(z.object({ path: z.string(), size: z.number().int().nonnegative(), sha256: z.string() }).strict()),
|
|
1973
2076
|
})
|
|
1974
2077
|
.strict();
|
|
1975
2078
|
/** `GET /v1/agent-manifests`: each manifest's latest version, by name. */
|
|
@@ -2034,6 +2137,12 @@ export const AgentManifestPlanSchema = z
|
|
|
2034
2137
|
secrets: z.number().int().nonnegative(),
|
|
2035
2138
|
})
|
|
2036
2139
|
.strict(),
|
|
2140
|
+
/** An agent folder's only: the manifest it compiles to. */
|
|
2141
|
+
manifest: AgentManifestV8Schema.optional(),
|
|
2142
|
+
/** An agent folder's only: what the compiler noted, none of them errors. */
|
|
2143
|
+
diagnostics: z.array(AgentFolderDiagnosticSchema).optional(),
|
|
2144
|
+
/** An agent folder's only: the compiler format, such as `agent-folder/1`. */
|
|
2145
|
+
compiler: z.string().optional(),
|
|
2037
2146
|
})
|
|
2038
2147
|
.strict();
|
|
2039
2148
|
/** `PUT /v1/agent-manifests/{name}`: the version saved (or the latest, unchanged). */
|
|
@@ -2042,6 +2151,8 @@ export const SaveAgentManifestResponseSchema = z
|
|
|
2042
2151
|
manifest: AgentManifestViewSchema,
|
|
2043
2152
|
unchanged: z.boolean(),
|
|
2044
2153
|
warnings: z.array(AgentManifestWarningSchema),
|
|
2154
|
+
/** An agent folder's only: what the compiler noted, none of them errors. */
|
|
2155
|
+
diagnostics: z.array(AgentFolderDiagnosticSchema).optional(),
|
|
2045
2156
|
})
|
|
2046
2157
|
.strict();
|
|
2047
2158
|
export const DeleteAgentManifestResponseSchema = z
|
|
@@ -2165,11 +2276,24 @@ export const ModelInputSchema = z.enum(MODEL_INPUTS);
|
|
|
2165
2276
|
* failed call.
|
|
2166
2277
|
*/
|
|
2167
2278
|
export const CUSTOM_MODEL_SETTING_DEFAULTS = Object.freeze({ contextWindow: 32_768, maxTokens: 8_192 });
|
|
2279
|
+
/**
|
|
2280
|
+
* Where a custom endpoint's per-call header takes its value from the call (#493): one of the
|
|
2281
|
+
* calling Agent's labels (`key`, such as `org`), the Agent's id, or the session's owner when it
|
|
2282
|
+
* is a person. A call whose source has no value sends no header.
|
|
2283
|
+
*/
|
|
2284
|
+
export const ModelCallHeaderSourceSchema = z.discriminatedUnion("from", [
|
|
2285
|
+
z.object({ from: z.literal("agent.label"), key: z.string().min(1) }).strict(),
|
|
2286
|
+
z.object({ from: z.literal("agent.id") }).strict(),
|
|
2287
|
+
z.object({ from: z.literal("session.owner") }).strict(),
|
|
2288
|
+
]);
|
|
2168
2289
|
/**
|
|
2169
2290
|
* What the Runtime cannot learn from a custom OpenAI-compatible endpoint (Model Calls §7):
|
|
2170
2291
|
* its context window and output limit (default `CUSTOM_MODEL_SETTING_DEFAULTS`), whether it
|
|
2171
2292
|
* reasons, what it reads (`inputs`; default text only) and pi-ai `compat` settings
|
|
2172
|
-
* (`thinkingFormat`, `thinkingTokenBudgetField`, `chatTemplateKwargs`, …).
|
|
2293
|
+
* (`thinkingFormat`, `thinkingTokenBudgetField`, `chatTemplateKwargs`, …). `headers` are sent on
|
|
2294
|
+
* every call and `callHeaders` resolved per call from the calling Agent, for a gateway that
|
|
2295
|
+
* attributes or budgets each call (#493): they are settings, never secrets, and read back as such,
|
|
2296
|
+
* so neither may set `authorization`.
|
|
2173
2297
|
*/
|
|
2174
2298
|
export const CustomModelSettingsSchema = z
|
|
2175
2299
|
.object({
|
|
@@ -2178,8 +2302,16 @@ export const CustomModelSettingsSchema = z
|
|
|
2178
2302
|
reasoning: z.boolean().optional(),
|
|
2179
2303
|
inputs: z.array(ModelInputSchema).optional(),
|
|
2180
2304
|
compat: z.record(z.string(), z.unknown()).optional(),
|
|
2305
|
+
headers: z.record(CredentialHeaderNameSchema, CredentialHeaderValueSchema).optional(),
|
|
2306
|
+
callHeaders: z.record(CredentialHeaderNameSchema, ModelCallHeaderSourceSchema).optional(),
|
|
2181
2307
|
})
|
|
2182
2308
|
.strict();
|
|
2309
|
+
/**
|
|
2310
|
+
* How the Runtime authenticates to the model: a stored key, a stored OAuth grant, or (a custom
|
|
2311
|
+
* endpoint only) the Runtime's workload token, read from `NYLORUN_WORKLOAD_TOKEN_FILE` on every
|
|
2312
|
+
* call and never stored (#496).
|
|
2313
|
+
*/
|
|
2314
|
+
export const HOST_MODEL_AUTH_TYPES = ["api_key", "oauth", "workload"];
|
|
2183
2315
|
export const PutHostModelRequestSchema = z
|
|
2184
2316
|
.object({
|
|
2185
2317
|
...vaultWriteBase,
|
|
@@ -2203,6 +2335,7 @@ export const PutHostModelRequestSchema = z
|
|
|
2203
2335
|
expires: z.number(),
|
|
2204
2336
|
})
|
|
2205
2337
|
.passthrough(),
|
|
2338
|
+
z.object({ type: z.literal("workload") }).strict(),
|
|
2206
2339
|
]),
|
|
2207
2340
|
})
|
|
2208
2341
|
.strict();
|
|
@@ -2217,6 +2350,7 @@ export const SelectHostModelRequestSchema = z
|
|
|
2217
2350
|
export const ENVIRONMENT_SECRET_TYPES = [
|
|
2218
2351
|
"bearer",
|
|
2219
2352
|
"headers",
|
|
2353
|
+
"workload",
|
|
2220
2354
|
"environment_secret",
|
|
2221
2355
|
"environment_variable",
|
|
2222
2356
|
];
|
|
@@ -2238,6 +2372,8 @@ export const AgentSecretViewSchema = z
|
|
|
2238
2372
|
/** A `headers` credential's header names (lower case), never their values. */
|
|
2239
2373
|
headerNames: z.array(z.string()).optional(),
|
|
2240
2374
|
via: z.string().optional(),
|
|
2375
|
+
/** How the gateway at `via` prefixes tool names (Host feature `gateway-credentials`). */
|
|
2376
|
+
toolPrefix: z.string().optional(),
|
|
2241
2377
|
identity: CredentialIdentitySchema.optional(),
|
|
2242
2378
|
createdAt: z.string(),
|
|
2243
2379
|
rotatedAt: z.string().optional(),
|
|
@@ -2795,9 +2931,15 @@ export const ToolCompletedPayloadSchema = z
|
|
|
2795
2931
|
message: z.string(),
|
|
2796
2932
|
/**
|
|
2797
2933
|
* With `credential_rejected`: the MCP server, or the HTTP tool's `credential`,
|
|
2798
|
-
* whose server answered `401
|
|
2934
|
+
* whose server answered `401` (or, through a credential's `via`, whose gateway
|
|
2935
|
+
* reported that the server behind it did): the integration refused the credential.
|
|
2799
2936
|
*/
|
|
2800
2937
|
server: z.string().optional(),
|
|
2938
|
+
/**
|
|
2939
|
+
* With `credential_rejected` of the Runtime's workload token: the origin of the gateway
|
|
2940
|
+
* that refused it (#496), an expired or unrotated token.
|
|
2941
|
+
*/
|
|
2942
|
+
gateway: z.string().optional(),
|
|
2801
2943
|
/** An MCP tool error: true when calling again may work, as for `mcp.unreachable`. */
|
|
2802
2944
|
retryable: z.boolean().optional(),
|
|
2803
2945
|
})
|
|
@@ -3448,7 +3590,7 @@ export const HostModelViewSchema = z.union([
|
|
|
3448
3590
|
configured: z.literal(true),
|
|
3449
3591
|
provider: z.string(),
|
|
3450
3592
|
model: z.string(),
|
|
3451
|
-
authType: z.enum(
|
|
3593
|
+
authType: z.enum(HOST_MODEL_AUTH_TYPES),
|
|
3452
3594
|
baseUrl: z.string().optional(),
|
|
3453
3595
|
settings: CustomModelSettingsSchema.optional(),
|
|
3454
3596
|
})
|
|
@@ -3855,7 +3997,7 @@ export const HostModelProviderInfoSchema = z
|
|
|
3855
3997
|
id: z.string(),
|
|
3856
3998
|
name: z.string(),
|
|
3857
3999
|
model: z.string(),
|
|
3858
|
-
authType: z.enum(
|
|
4000
|
+
authType: z.enum(HOST_MODEL_AUTH_TYPES),
|
|
3859
4001
|
baseUrl: z.string().optional(),
|
|
3860
4002
|
settings: CustomModelSettingsSchema.optional(),
|
|
3861
4003
|
/** What the provider's selected model reads (protocol 12); absent for a model unknown here. */
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type AgentManifestV8 } from "../contracts.js";
|
|
2
|
+
/** The compiler format this version builds: a folder with no `format`, or `format: 1`. */
|
|
3
|
+
export declare const AGENT_FOLDER_COMPILER = "agent-folder/1";
|
|
4
|
+
/** What a folder may hold. Fixed in this version; Tenant settings come later. */
|
|
5
|
+
export declare const AGENT_FOLDER_LIMITS: Readonly<{
|
|
6
|
+
/** Files in one folder. */
|
|
7
|
+
files: 2000;
|
|
8
|
+
/** Every file's bytes together. */
|
|
9
|
+
totalBytes: number;
|
|
10
|
+
/** One Markdown or JSON file the compiler reads. */
|
|
11
|
+
textFileBytes: number;
|
|
12
|
+
}>;
|
|
13
|
+
/** One file of a folder: its `/`-separated path, size and SHA-256 (lowercase hex). */
|
|
14
|
+
export interface AgentFolderEntry {
|
|
15
|
+
readonly path: string;
|
|
16
|
+
readonly size: number;
|
|
17
|
+
readonly sha256: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* One problem or remark: an `error` keeps the folder from compiling; `warning`, `info` and
|
|
21
|
+
* `note` do not. `file` is the folder path it is about, with the line and column when known,
|
|
22
|
+
* and `pointer` the field in the manifest when it is about one.
|
|
23
|
+
*/
|
|
24
|
+
export interface AgentFolderDiagnostic {
|
|
25
|
+
readonly severity: "error" | "warning" | "info" | "note";
|
|
26
|
+
readonly code: string;
|
|
27
|
+
readonly message: string;
|
|
28
|
+
readonly file?: string;
|
|
29
|
+
readonly line?: number;
|
|
30
|
+
readonly column?: number;
|
|
31
|
+
readonly pointer?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface CompileAgentFolderInput {
|
|
34
|
+
readonly entries: readonly AgentFolderEntry[];
|
|
35
|
+
/** The bytes of each file `folderTextPaths(entries)` names. */
|
|
36
|
+
readonly files: ReadonlyMap<string, Uint8Array>;
|
|
37
|
+
/** The name the manifest must have: the path's, or the folder's. */
|
|
38
|
+
readonly name?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface CompiledAgentFolder {
|
|
41
|
+
/** The manifest, when nothing is an error. */
|
|
42
|
+
readonly manifest?: AgentManifestV8;
|
|
43
|
+
readonly diagnostics: readonly AgentFolderDiagnostic[];
|
|
44
|
+
readonly compiler: typeof AGENT_FOLDER_COMPILER;
|
|
45
|
+
}
|
|
46
|
+
/** The files the compiler reads: the Runtime and the CLI pass their bytes in. */
|
|
47
|
+
export declare function folderTextPaths(entries: readonly AgentFolderEntry[]): string[];
|
|
48
|
+
/** Compiles an agent folder into agent manifest v8, with every diagnostic. */
|
|
49
|
+
export declare function compileAgentFolder(input: CompileAgentFolderInput): CompiledAgentFolder;
|