@nylorun/core 0.18.0-beta → 0.19.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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @nylorun/core
2
2
 
3
+ ## 0.19.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - 212364b: **Credentials for skills (R2c).** A skill's CLI in a pod sandbox authenticates with a vault credential whose value never enters the sandbox.
8
+
9
+ - `@nylorun/core`: vault credentials gain `environment_secret` (`secretName`, `secretValue`, `allowedHosts`, optional `inject: { header, format }`) and `environment_variable` (`variableName`, `variableValue`), in create, rotate and `CredentialInfo` (whose `binding.url` is now optional). `ENVIRONMENT_SECRET_SENTINEL` (`nylorun-managed`), `ENVIRONMENT_SECRET_DEFAULT_INJECT`, `isInjectFormat`, `renderInjectFormat`, `EnvironmentNameSchema` and `RESERVED_ENVIRONMENT_NAMES` are exported; `ERROR_CODES` gains `credential_conflict`; the Harness API's `RunRouting.sandbox` gains `environment`.
10
+ - `@nylorun/runtime`: every sandbox command gets each secret's name set to `nylorun-managed` and each variable's value. egress-gate terminates TLS for port 443 of a host an `environment_secret` of the sandbox's sessions is bound to, with a fresh leaf signed by the installation's egress CA (held by keys; its certificate reaches the pod in the join answer, and the engine points `SSL_CERT_FILE`, `NODE_EXTRA_CA_CERTS`, `REQUESTS_CA_BUNDLE`, `CURL_CA_BUNDLE`, `GIT_SSL_CAINFO` and `AWS_CA_BUNDLE` at a bundle with it), and sets the credential's header on every request from the vault, uncached. Every other host stays an opaque tunnel. Session open answers `409 credential_conflict` for two credentials with one variable name or one host, or two owners' secrets on one sandbox. No protocol change.
11
+ - `@nylorun/studio`: the Credentials page lists shell credentials (their variable and hosts) and deletes them; create and rotate them with the Management API.
12
+
3
13
  ## 0.18.0-beta
4
14
 
5
15
  ### Minor Changes
@@ -145,7 +145,13 @@ export declare const ERROR_CODES: readonly ["not_found",
145
145
  * address the Host refuses, a connection that failed or a server silent past 15 s;
146
146
  * `mcp.forbidden`, `mcp.status`, `mcp.error`).
147
147
  */
148
- "mcp_preview_failed", "internal_error"];
148
+ "mcp_preview_failed",
149
+ /**
150
+ * A session's shell credentials would be ambiguous (R2c, D50): `409`. Two attached
151
+ * `environment_secret` or `environment_variable` credentials share a variable name, two
152
+ * secrets are bound to one host, or the sandbox would serve secrets to sessions of two owners.
153
+ */
154
+ "credential_conflict", "internal_error"];
149
155
  export type ErrorCode = (typeof ERROR_CODES)[number];
150
156
  export declare const TENANT_ID_PATTERN: RegExp;
151
157
  export declare const PRINCIPAL_ID_PATTERN: RegExp;
@@ -168,6 +168,12 @@ export const ERROR_CODES = [
168
168
  * `mcp.forbidden`, `mcp.status`, `mcp.error`).
169
169
  */
170
170
  "mcp_preview_failed",
171
+ /**
172
+ * A session's shell credentials would be ambiguous (R2c, D50): `409`. Two attached
173
+ * `environment_secret` or `environment_variable` credentials share a variable name, two
174
+ * secrets are bound to one host, or the sandbox would serve secrets to sessions of two owners.
175
+ */
176
+ "credential_conflict",
171
177
  "internal_error",
172
178
  ];
173
179
  /** Crockford Base32 alphabet (lowercase); excludes i, l, o, u. */
@@ -496,6 +496,34 @@ export declare const CredentialIdentitySchema: z.ZodObject<{
496
496
  header: z.ZodString;
497
497
  }, z.core.$strict>;
498
498
  export type CredentialIdentity = z.infer<typeof CredentialIdentitySchema>;
499
+ /**
500
+ * An environment variable name a shell secret or plain variable may take (R2c, D50): a POSIX
501
+ * name. Names the sandbox needs for itself (the proxy, the trust store, `PATH`, `HOME`) and
502
+ * `NYLORUN_*` are reserved.
503
+ */
504
+ export declare const ENVIRONMENT_NAME_PATTERN: RegExp;
505
+ export declare const RESERVED_ENVIRONMENT_NAMES: ReadonlySet<string>;
506
+ export declare function isReservedEnvironmentName(name: string): boolean;
507
+ /** The value a sandbox sees for every `environment_secret` (R2c, D50): never the secret. */
508
+ export declare const ENVIRONMENT_SECRET_SENTINEL = "nylorun-managed";
509
+ /**
510
+ * How egress-gate writes an `environment_secret` into a request (R2c, D50): one header, set on
511
+ * every request to a bound host. `format` is text with `{value}` once, optionally inside a
512
+ * `{base64:…}` group, for example `Bearer {value}` (the default),
513
+ * `Basic {base64:x-access-token:{value}}` or `{value}`.
514
+ */
515
+ export declare const ENVIRONMENT_SECRET_DEFAULT_INJECT: {
516
+ readonly header: "Authorization";
517
+ readonly format: "Bearer {value}";
518
+ };
519
+ export declare function isInjectFormat(format: string): boolean;
520
+ /** `format` with `{value}` replaced, and each `{base64:…}` group encoded. */
521
+ export declare function renderInjectFormat(format: string, value: string): string;
522
+ export declare const EnvironmentSecretInjectSchema: z.ZodObject<{
523
+ header: z.ZodString;
524
+ format: z.ZodString;
525
+ }, z.core.$strict>;
526
+ export type EnvironmentSecretInject = z.infer<typeof EnvironmentSecretInjectSchema>;
499
527
  /**
500
528
  * A credential for the server at `url` (the URL a manifest names): `bearer` sends
501
529
  * `Authorization: Bearer <token>`, `headers` its header map (R2b C2). The header names may not be
@@ -521,6 +549,19 @@ export declare const CreateCredentialRequestSchema: z.ZodObject<{
521
549
  type: z.ZodLiteral<"headers">;
522
550
  url: z.ZodString;
523
551
  headers: z.ZodRecord<z.ZodString, z.ZodString>;
552
+ }, z.core.$strict>, z.ZodObject<{
553
+ type: z.ZodLiteral<"environment_secret">;
554
+ secretName: z.ZodString;
555
+ secretValue: z.ZodString;
556
+ allowedHosts: z.ZodArray<z.ZodString>;
557
+ inject: z.ZodOptional<z.ZodObject<{
558
+ header: z.ZodString;
559
+ format: z.ZodString;
560
+ }, z.core.$strict>>;
561
+ }, z.core.$strict>, z.ZodObject<{
562
+ type: z.ZodLiteral<"environment_variable">;
563
+ variableName: z.ZodString;
564
+ variableValue: z.ZodString;
524
565
  }, z.core.$strict>], "type">;
525
566
  }, z.core.$strict>;
526
567
  export type CreateCredentialRequest = z.infer<typeof CreateCredentialRequestSchema>;
@@ -545,6 +586,12 @@ export declare const RotateCredentialRequestSchema: z.ZodObject<{
545
586
  }, z.core.$strict>>>;
546
587
  type: z.ZodLiteral<"headers">;
547
588
  headers: z.ZodRecord<z.ZodString, z.ZodString>;
589
+ }, z.core.$strict>, z.ZodObject<{
590
+ type: z.ZodLiteral<"environment_secret">;
591
+ secretValue: z.ZodString;
592
+ }, z.core.$strict>, z.ZodObject<{
593
+ type: z.ZodLiteral<"environment_variable">;
594
+ variableValue: z.ZodString;
548
595
  }, z.core.$strict>], "type">;
549
596
  }, z.core.$strict>;
550
597
  export type RotateCredentialRequest = z.infer<typeof RotateCredentialRequestSchema>;
@@ -617,10 +664,20 @@ export declare const CredentialInfoSchema: z.ZodObject<{
617
664
  name: z.ZodString;
618
665
  type: z.ZodEnum<{
619
666
  bearer: "bearer";
667
+ environment_secret: "environment_secret";
668
+ environment_variable: "environment_variable";
620
669
  headers: "headers";
621
670
  }>;
622
671
  binding: z.ZodObject<{
623
- url: z.ZodString;
672
+ url: z.ZodOptional<z.ZodString>;
673
+ secretName: z.ZodOptional<z.ZodString>;
674
+ allowedHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
675
+ inject: z.ZodOptional<z.ZodObject<{
676
+ header: z.ZodString;
677
+ format: z.ZodString;
678
+ }, z.core.$strict>>;
679
+ variableName: z.ZodOptional<z.ZodString>;
680
+ variableValue: z.ZodOptional<z.ZodString>;
624
681
  }, z.core.$strict>;
625
682
  headerNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
626
683
  via: z.ZodOptional<z.ZodString>;
@@ -999,6 +1056,7 @@ export declare const RejectedResponseSchema: z.ZodObject<{
999
1056
  status: z.ZodLiteral<"rejected">;
1000
1057
  code: z.ZodEnum<{
1001
1058
  connection_missing: "connection_missing";
1059
+ credential_conflict: "credential_conflict";
1002
1060
  credential_invalid: "credential_invalid";
1003
1061
  credential_rejected: "credential_rejected";
1004
1062
  credential_required: "credential_required";
@@ -2929,10 +2987,20 @@ export declare const ListCredentialsResponseSchema: z.ZodObject<{
2929
2987
  name: z.ZodString;
2930
2988
  type: z.ZodEnum<{
2931
2989
  bearer: "bearer";
2990
+ environment_secret: "environment_secret";
2991
+ environment_variable: "environment_variable";
2932
2992
  headers: "headers";
2933
2993
  }>;
2934
2994
  binding: z.ZodObject<{
2935
- url: z.ZodString;
2995
+ url: z.ZodOptional<z.ZodString>;
2996
+ secretName: z.ZodOptional<z.ZodString>;
2997
+ allowedHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
2998
+ inject: z.ZodOptional<z.ZodObject<{
2999
+ header: z.ZodString;
3000
+ format: z.ZodString;
3001
+ }, z.core.$strict>>;
3002
+ variableName: z.ZodOptional<z.ZodString>;
3003
+ variableValue: z.ZodOptional<z.ZodString>;
2936
3004
  }, z.core.$strict>;
2937
3005
  headerNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
2938
3006
  via: z.ZodOptional<z.ZodString>;
@@ -2965,6 +3033,7 @@ export type StreamClosedFrame = z.infer<typeof StreamClosedFrameSchema>;
2965
3033
  */
2966
3034
  export declare const AgUiRunErrorCodeSchema: z.ZodEnum<{
2967
3035
  connection_missing: "connection_missing";
3036
+ credential_conflict: "credential_conflict";
2968
3037
  credential_invalid: "credential_invalid";
2969
3038
  credential_rejected: "credential_rejected";
2970
3039
  credential_required: "credential_required";
package/dist/contracts.js CHANGED
@@ -921,6 +921,87 @@ const credentialRoutingChange = {
921
921
  via: CredentialViaSchema.nullable().optional(),
922
922
  identity: CredentialIdentitySchema.nullable().optional(),
923
923
  };
924
+ /**
925
+ * An environment variable name a shell secret or plain variable may take (R2c, D50): a POSIX
926
+ * name. Names the sandbox needs for itself (the proxy, the trust store, `PATH`, `HOME`) and
927
+ * `NYLORUN_*` are reserved.
928
+ */
929
+ export const ENVIRONMENT_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
930
+ export const RESERVED_ENVIRONMENT_NAMES = new Set([
931
+ "PATH",
932
+ "HOME",
933
+ "PWD",
934
+ "SHELL",
935
+ "USER",
936
+ "HTTPS_PROXY",
937
+ "HTTP_PROXY",
938
+ "NO_PROXY",
939
+ "ALL_PROXY",
940
+ "SSL_CERT_FILE",
941
+ "SSL_CERT_DIR",
942
+ "NODE_EXTRA_CA_CERTS",
943
+ "REQUESTS_CA_BUNDLE",
944
+ "CURL_CA_BUNDLE",
945
+ "GIT_SSL_CAINFO",
946
+ "AWS_CA_BUNDLE",
947
+ ]);
948
+ export function isReservedEnvironmentName(name) {
949
+ const upper = name.toUpperCase();
950
+ return RESERVED_ENVIRONMENT_NAMES.has(upper) || upper.startsWith("NYLORUN_");
951
+ }
952
+ const EnvironmentNameSchema = z
953
+ .string()
954
+ .regex(ENVIRONMENT_NAME_PATTERN, "An environment variable name is a letter or _ followed by letters, digits or _")
955
+ .refine((name) => !isReservedEnvironmentName(name), "That environment variable name is reserved");
956
+ /** The value a sandbox sees for every `environment_secret` (R2c, D50): never the secret. */
957
+ export const ENVIRONMENT_SECRET_SENTINEL = "nylorun-managed";
958
+ /**
959
+ * How egress-gate writes an `environment_secret` into a request (R2c, D50): one header, set on
960
+ * every request to a bound host. `format` is text with `{value}` once, optionally inside a
961
+ * `{base64:…}` group, for example `Bearer {value}` (the default),
962
+ * `Basic {base64:x-access-token:{value}}` or `{value}`.
963
+ */
964
+ export const ENVIRONMENT_SECRET_DEFAULT_INJECT = { header: "Authorization", format: "Bearer {value}" };
965
+ const BASE64_GROUP = /\{base64:((?:[^{}]|\{value\})*)\}/g;
966
+ export function isInjectFormat(format) {
967
+ if (/[\r\n\0]/.test(format))
968
+ return false;
969
+ const values = format.match(/\{value\}/g)?.length ?? 0;
970
+ const rest = format.replace(BASE64_GROUP, (_, inner) => inner.replace(/\{value\}/g, "")).replace(/\{value\}/g, "");
971
+ return values === 1 && !/[{}]/.test(rest);
972
+ }
973
+ /** `format` with `{value}` replaced, and each `{base64:…}` group encoded. */
974
+ export function renderInjectFormat(format, value) {
975
+ return format
976
+ .replace(BASE64_GROUP, (_, inner) => base64Utf8(inner.replace(/\{value\}/g, () => value)))
977
+ .replace(/\{value\}/g, () => value);
978
+ }
979
+ function base64Utf8(text) {
980
+ let binary = "";
981
+ for (const byte of new TextEncoder().encode(text))
982
+ binary += String.fromCharCode(byte);
983
+ return btoa(binary);
984
+ }
985
+ export const EnvironmentSecretInjectSchema = z
986
+ .object({
987
+ header: CredentialHeaderNameSchema,
988
+ format: z.string().min(1).refine(isInjectFormat, "format has {value} exactly once, optionally inside one {base64:…} group"),
989
+ })
990
+ .strict();
991
+ /** Exact host names an `environment_secret` may be sent to: no wildcards, no IP literals. */
992
+ const AllowedHostsSchema = z
993
+ .array(z
994
+ .string()
995
+ .toLowerCase()
996
+ .refine((host) => /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/.test(host) && !/^\d+(\.\d+){3}$/.test(host), "allowedHosts takes exact host names such as api.github.com: no wildcard, port or IP address"))
997
+ .min(1)
998
+ .max(32)
999
+ .refine((hosts) => new Set(hosts).size === hosts.length, "allowedHosts lists each host once");
1000
+ const EnvironmentValueSchema = z
1001
+ .string()
1002
+ .min(1)
1003
+ .max(8192)
1004
+ .refine((value) => !/[\r\n\0]/.test(value), "A value has no CR, LF or NUL");
924
1005
  /**
925
1006
  * A credential for the server at `url` (the URL a manifest names): `bearer` sends
926
1007
  * `Authorization: Bearer <token>`, `headers` its header map (R2b C2). The header names may not be
@@ -947,6 +1028,22 @@ export const CreateCredentialRequestSchema = z
947
1028
  ...credentialRouting,
948
1029
  })
949
1030
  .strict(),
1031
+ z
1032
+ .object({
1033
+ type: z.literal("environment_secret"),
1034
+ secretName: EnvironmentNameSchema,
1035
+ secretValue: EnvironmentValueSchema,
1036
+ allowedHosts: AllowedHostsSchema,
1037
+ inject: EnvironmentSecretInjectSchema.optional(),
1038
+ })
1039
+ .strict(),
1040
+ z
1041
+ .object({
1042
+ type: z.literal("environment_variable"),
1043
+ variableName: EnvironmentNameSchema,
1044
+ variableValue: EnvironmentValueSchema,
1045
+ })
1046
+ .strict(),
950
1047
  ]),
951
1048
  })
952
1049
  .strict();
@@ -972,6 +1069,8 @@ export const RotateCredentialRequestSchema = z
972
1069
  ...credentialRoutingChange,
973
1070
  })
974
1071
  .strict(),
1072
+ z.object({ type: z.literal("environment_secret"), secretValue: EnvironmentValueSchema }).strict(),
1073
+ z.object({ type: z.literal("environment_variable"), variableValue: EnvironmentValueSchema }).strict(),
975
1074
  ]),
976
1075
  })
977
1076
  .strict();
@@ -1036,8 +1135,22 @@ export const CredentialInfoSchema = z
1036
1135
  id: z.string(),
1037
1136
  vaultId: z.string(),
1038
1137
  name: z.string(),
1039
- type: z.enum(["bearer", "headers"]),
1040
- binding: z.object({ url: z.string() }).strict(),
1138
+ type: z.enum(["bearer", "headers", "environment_secret", "environment_variable"]),
1139
+ /**
1140
+ * What the credential is bound to: the server `url` for `bearer` and `headers`; the variable
1141
+ * name and hosts for `environment_secret` (R2c); the name and its plain value for
1142
+ * `environment_variable`, which is not a secret. A secret's value is never shown.
1143
+ */
1144
+ binding: z
1145
+ .object({
1146
+ url: z.string().optional(),
1147
+ secretName: z.string().optional(),
1148
+ allowedHosts: z.array(z.string()).optional(),
1149
+ inject: EnvironmentSecretInjectSchema.optional(),
1150
+ variableName: z.string().optional(),
1151
+ variableValue: z.string().optional(),
1152
+ })
1153
+ .strict(),
1041
1154
  /** A `headers` credential's header names (lower case), never their values. */
1042
1155
  headerNames: z.array(z.string()).optional(),
1043
1156
  via: z.string().optional(),
@@ -172,6 +172,7 @@ export declare const RunRoutingSchema: z.ZodObject<{
172
172
  ownerId: z.ZodString;
173
173
  sandboxId: z.ZodOptional<z.ZodString>;
174
174
  spec: z.ZodOptional<z.ZodUnknown>;
175
+ environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
175
176
  }, z.core.$strict>>;
176
177
  }, z.core.$strict>;
177
178
  /** What a run starts from: `turn.start` (message, continue, resume) or `approval.answer`. */
@@ -213,6 +214,7 @@ export declare const TurnStartSchema: z.ZodObject<{
213
214
  ownerId: z.ZodString;
214
215
  sandboxId: z.ZodOptional<z.ZodString>;
215
216
  spec: z.ZodOptional<z.ZodUnknown>;
217
+ environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
216
218
  }, z.core.$strict>>;
217
219
  }, z.core.$strict>;
218
220
  }, z.core.$strict>;
@@ -364,6 +366,7 @@ export declare const harnessRequests: {
364
366
  ownerId: z.ZodString;
365
367
  sandboxId: z.ZodOptional<z.ZodString>;
366
368
  spec: z.ZodOptional<z.ZodUnknown>;
369
+ environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
367
370
  }, z.core.$strict>>;
368
371
  }, z.core.$strict>;
369
372
  }, z.core.$strict>;
@@ -130,7 +130,16 @@ export const RunRoutingSchema = z
130
130
  mcpSnapshot: z.unknown().optional(),
131
131
  /** The session that owns the tree's sandbox, and the sandbox resource it is attached to. */
132
132
  sandbox: z
133
- .object({ ownerId: id, sandboxId: id.optional(), spec: z.unknown().optional() })
133
+ .object({
134
+ ownerId: id,
135
+ sandboxId: id.optional(),
136
+ spec: z.unknown().optional(),
137
+ /**
138
+ * Variables every sandbox command gets (R2c, D50): each `environment_secret` name set to
139
+ * the sentinel `nylorun-managed`, and each `environment_variable`'s value. Never a secret.
140
+ */
141
+ environment: z.record(z.string(), z.string()).optional(),
142
+ })
134
143
  .strict()
135
144
  .optional(),
136
145
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/core",
3
- "version": "0.18.0-beta",
3
+ "version": "0.19.0-beta",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Shared agent definitions and wire contracts",