@nylorun/runtime 0.16.0-beta → 0.17.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 +58 -0
- package/README.md +39 -27
- package/dist/admin-openapi.json +307 -7
- package/dist/api/ag-ui/endpoint.js +1 -2
- package/dist/api/ag-ui/routes.d.ts +1 -1
- package/dist/api/ag-ui/routes.js +10 -12
- package/dist/api/components.d.ts +54 -116
- package/dist/api/components.js +8 -11
- package/dist/api/http/app.js +2 -0
- package/dist/api/http/define.d.ts +9 -12
- package/dist/api/http/define.js +11 -26
- package/dist/api/http/routes/access.d.ts +3 -19
- package/dist/api/http/routes/access.js +12 -172
- package/dist/api/http/routes/actions.js +0 -1
- package/dist/api/http/routes/artifacts.js +1 -3
- package/dist/api/http/routes/me.d.ts +13 -0
- package/dist/api/http/routes/me.js +45 -0
- package/dist/api/http/routes/sandboxes.d.ts +2 -2
- package/dist/api/http/routes/sandboxes.js +1 -3
- package/dist/api/http/routes/sessions.js +6 -12
- package/dist/api/http/routes/vaults.d.ts +12 -3
- package/dist/api/http/routes/vaults.js +122 -54
- package/dist/api/openapi.js +4 -10
- package/dist/artifacts/links.js +6 -6
- package/dist/artifacts/service.js +1 -1
- package/dist/gates/mcp-handler.js +5 -1
- package/dist/gates/tenant-vaults.d.ts +18 -9
- package/dist/gates/tenant-vaults.js +17 -12
- package/dist/host/admin-api.d.ts +12 -5
- package/dist/host/admin-api.js +72 -6
- package/dist/host/app.d.ts +0 -1
- package/dist/host/app.js +13 -23
- package/dist/host/config-for.d.ts +4 -0
- package/dist/host/config-for.js +2 -0
- package/dist/host/config.d.ts +0 -6
- package/dist/host/create-host.d.ts +3 -10
- package/dist/host/create-host.js +4 -1
- package/dist/host/gates.js +6 -1
- package/dist/host/main.js +32 -10
- package/dist/host/stack-config.d.ts +11 -8
- package/dist/host/stack-config.js +23 -12
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/keys/client.js +9 -1
- package/dist/keys/keys.d.ts +12 -2
- package/dist/keys/keys.js +8 -0
- package/dist/mcp/connect.js +2 -1
- package/dist/mcp/pool.d.ts +1 -0
- package/dist/mcp/pool.js +1 -0
- package/dist/openapi.json +2359 -4096
- package/dist/store/postgres/drizzle/0008_installation_vaults.sql +2 -0
- package/dist/store/postgres/drizzle/0009_oauth_pending.sql +19 -0
- package/dist/store/postgres/drizzle/0010_oss_auth_removals.sql +3 -0
- package/dist/store/postgres/drizzle/meta/_journal.json +21 -0
- package/dist/store/postgres/schema.d.ts +194 -170
- package/dist/store/postgres/schema.js +46 -28
- package/dist/store/postgres/store.js +51 -100
- package/dist/store/postgres/tenant.d.ts +1 -1
- package/dist/store/postgres/tenant.js +2 -2
- package/dist/store/types.d.ts +24 -30
- package/dist/streams/control.d.ts +0 -5
- package/dist/streams/control.js +0 -8
- package/dist/streams/types.d.ts +2 -11
- package/dist/streams/types.js +1 -1
- package/dist/tenant/auth.d.ts +13 -9
- package/dist/tenant/auth.js +25 -32
- package/dist/tenant/commands.js +3 -7
- package/dist/tenant/context.d.ts +20 -22
- package/dist/tenant/delivery-token.js +4 -4
- package/dist/tenant/effects.d.ts +5 -1
- package/dist/tenant/effects.js +5 -16
- package/dist/tenant/ephemeral.d.ts +14 -2
- package/dist/tenant/ephemeral.js +8 -1
- package/dist/tenant/host-token.js +5 -5
- package/dist/tenant/identity-file.d.ts +75 -0
- package/dist/tenant/identity-file.js +202 -0
- package/dist/tenant/issuers.d.ts +48 -0
- package/dist/tenant/issuers.js +311 -0
- package/dist/tenant/jwt.js +3 -3
- package/dist/tenant/operator-keys.d.ts +18 -0
- package/dist/tenant/operator-keys.js +55 -0
- package/dist/tenant/outbound.d.ts +30 -0
- package/dist/tenant/outbound.js +142 -10
- package/dist/tenant/principals.d.ts +2 -11
- package/dist/tenant/principals.js +10 -30
- package/dist/tenant/run-token.js +3 -3
- package/dist/tenant/runtime.d.ts +4 -0
- package/dist/tenant/runtime.js +14 -1
- package/dist/tenant/sandboxes.d.ts +5 -5
- package/dist/tenant/sandboxes.js +5 -5
- package/dist/tenant/session-streams.d.ts +6 -10
- package/dist/tenant/session-streams.js +9 -27
- package/dist/tenant/sessions.d.ts +2 -2
- package/dist/tenant/sessions.js +1 -1
- package/dist/tenant/signing-keys.d.ts +2 -1
- package/dist/tenant/signing-keys.js +2 -2
- package/dist/tenant/streams.d.ts +2 -3
- package/dist/tenant/streams.js +1 -5
- package/dist/tenant/types.d.ts +21 -0
- package/dist/vault/crypto.d.ts +7 -0
- package/dist/vault/crypto.js +16 -0
- package/dist/vault/oauth.d.ts +55 -0
- package/dist/vault/oauth.js +186 -0
- package/dist/vault/service.d.ts +54 -7
- package/dist/vault/service.js +261 -17
- package/dist/vault/sources.d.ts +54 -0
- package/dist/vault/sources.js +185 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
- package/dist/host/cors.d.ts +0 -27
- package/dist/host/cors.js +0 -64
- package/dist/tenant/access-policy.d.ts +0 -30
- package/dist/tenant/access-policy.js +0 -52
- package/dist/tenant/browser.d.ts +0 -15
- package/dist/tenant/browser.js +0 -39
- package/dist/tenant/subject-limits.d.ts +0 -16
- package/dist/tenant/subject-limits.js +0 -45
- package/dist/tenant/tokens.d.ts +0 -14
- package/dist/tenant/tokens.js +0 -187
package/dist/api/ag-ui/routes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Runtime's AG-UI endpoint (Host feature `ag-ui-endpoint`): the Tenant's agents served to
|
|
3
|
-
* AG-UI clients, for a person named by a
|
|
3
|
+
* AG-UI clients, for a person named by a trusted issuer's token (a browser or app) or by subject headers
|
|
4
4
|
* (an app server's `createAgUiHandler`, which forwards here). One implementation for both, so
|
|
5
5
|
* a thread is the same session whichever way it is reached.
|
|
6
6
|
*
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* idempotency key, approvals become interrupts resumed through `resume`, and the last AG-UI
|
|
16
16
|
* event made from each Runtime event carries its cursor as the SSE id. A run's session is
|
|
17
17
|
* created on its first run with the options in `forwardedProps.nylorun.session` and never
|
|
18
|
-
* changed afterwards. A stream opened with
|
|
19
|
-
*
|
|
18
|
+
* changed afterwards. A stream opened with an issuer token ends at the token's expiry with
|
|
19
|
+
* `CUSTOM nylorun.stream_closed`, and the client reattaches with a new token.
|
|
20
20
|
*/
|
|
21
21
|
import { randomUUID } from "node:crypto";
|
|
22
22
|
import { EventType, } from "@ag-ui/core";
|
|
@@ -30,9 +30,9 @@ import { accessOf } from "../../tenant/auth.js";
|
|
|
30
30
|
import { command } from "../../tenant/commands.js";
|
|
31
31
|
import { loadSession, sessionOf, } from "../../tenant/context.js";
|
|
32
32
|
import { fail, HttpError } from "../../tenant/http.js";
|
|
33
|
-
import { observeSession, readHistory, StreamClosed, } from "../../tenant/session-streams.js";
|
|
33
|
+
import { observeSession, readHistory, StreamClosed, streamHolderOf, } from "../../tenant/session-streams.js";
|
|
34
34
|
import { putSession, sessionView } from "../../tenant/sessions.js";
|
|
35
|
-
import { mayUseAgent } from "../../tenant/
|
|
35
|
+
import { mayUseAgent } from "../../tenant/auth.js";
|
|
36
36
|
import { sandboxGrantsOf } from "../../tenant/sandboxes.js";
|
|
37
37
|
const HEARTBEAT_MS = 15_000;
|
|
38
38
|
const TERMINAL = new Set([
|
|
@@ -41,16 +41,14 @@ const TERMINAL = new Set([
|
|
|
41
41
|
"turn.failed",
|
|
42
42
|
"turn.cancelled",
|
|
43
43
|
]);
|
|
44
|
-
/** The person a request acts for:
|
|
44
|
+
/** The person a request acts for: an issuer token's subject, or `Nylorun-Subject`. */
|
|
45
45
|
function personOf(scope) {
|
|
46
46
|
if (scope.kind === "token" || scope.kind === "subject")
|
|
47
47
|
return scope.subject;
|
|
48
|
-
return fail(400, "AG-UI runs act for a person: send a
|
|
48
|
+
return fail(400, "AG-UI runs act for a person: send a trusted issuer's token, or Nylorun-Subject with the application key", { code: "invalid_request" });
|
|
49
49
|
}
|
|
50
50
|
function holderOf(scope) {
|
|
51
|
-
return scope
|
|
52
|
-
? { subject: scope.subject, epoch: scope.epoch, expiresAt: scope.expiresAt }
|
|
53
|
-
: undefined;
|
|
51
|
+
return streamHolderOf(scope);
|
|
54
52
|
}
|
|
55
53
|
/** A refusal a client can act on, streamed as `RUN_ERROR` rather than an HTTP error. */
|
|
56
54
|
function runError(error) {
|
|
@@ -96,7 +94,7 @@ function sessionOptions(input, scope) {
|
|
|
96
94
|
});
|
|
97
95
|
// Agent code may trust `info`: only an app server sets it.
|
|
98
96
|
if (scope.kind === "token" && parsed.data.info !== undefined)
|
|
99
|
-
return fail(403, "A
|
|
97
|
+
return fail(403, "A token caller cannot set session info", {
|
|
100
98
|
code: "scope_required",
|
|
101
99
|
});
|
|
102
100
|
return parsed.data;
|
|
@@ -220,7 +218,7 @@ async function historyFrom(ctx, id, cursor) {
|
|
|
220
218
|
return items;
|
|
221
219
|
}
|
|
222
220
|
/**
|
|
223
|
-
* Who an AG-UI request acts for, once its agent is known: a person (
|
|
221
|
+
* Who an AG-UI request acts for, once its agent is known: a person (an issuer token's subject,
|
|
224
222
|
* or `Nylorun-Subject`), who may use the agent; else 400, or the 404 of a missing agent.
|
|
225
223
|
*/
|
|
226
224
|
export function agUiCaller(scope, agentId) {
|
package/dist/api/components.d.ts
CHANGED
|
@@ -14,8 +14,12 @@ export declare const Rejected: z.ZodObject<{
|
|
|
14
14
|
incompatible_host: "incompatible_host";
|
|
15
15
|
internal_error: "internal_error";
|
|
16
16
|
invalid_request: "invalid_request";
|
|
17
|
+
issuer_unavailable: "issuer_unavailable";
|
|
17
18
|
limit_exceeded: "limit_exceeded";
|
|
18
19
|
not_found: "not_found";
|
|
20
|
+
oauth_client_required: "oauth_client_required";
|
|
21
|
+
oauth_failed: "oauth_failed";
|
|
22
|
+
oauth_state_invalid: "oauth_state_invalid";
|
|
19
23
|
origin_rejected: "origin_rejected";
|
|
20
24
|
placement_refused: "placement_refused";
|
|
21
25
|
protocol_unsupported: "protocol_unsupported";
|
|
@@ -114,6 +118,29 @@ export declare const AdminStatus: z.ZodObject<{
|
|
|
114
118
|
export declare const HostShutdownResponse: z.ZodObject<{
|
|
115
119
|
status: z.ZodLiteral<"shutting_down">;
|
|
116
120
|
}, z.core.$strict>;
|
|
121
|
+
export declare const OperatorKey: z.ZodObject<{
|
|
122
|
+
id: z.ZodString;
|
|
123
|
+
role: z.ZodString;
|
|
124
|
+
createdAt: z.ZodString;
|
|
125
|
+
}, z.core.$strict>;
|
|
126
|
+
export declare const ListOperatorKeysResponse: z.ZodObject<{
|
|
127
|
+
keys: z.ZodArray<z.ZodObject<{
|
|
128
|
+
id: z.ZodString;
|
|
129
|
+
role: z.ZodString;
|
|
130
|
+
createdAt: z.ZodString;
|
|
131
|
+
}, z.core.$strict>>;
|
|
132
|
+
}, z.core.$strict>;
|
|
133
|
+
export declare const PutOperatorKeyResponse: z.ZodObject<{
|
|
134
|
+
id: z.ZodString;
|
|
135
|
+
role: z.ZodString;
|
|
136
|
+
createdAt: z.ZodString;
|
|
137
|
+
key: z.ZodString;
|
|
138
|
+
rotated: z.ZodBoolean;
|
|
139
|
+
}, z.core.$strict>;
|
|
140
|
+
export declare const DeleteOperatorKeyResponse: z.ZodObject<{
|
|
141
|
+
id: z.ZodString;
|
|
142
|
+
deleted: z.ZodLiteral<true>;
|
|
143
|
+
}, z.core.$strict>;
|
|
117
144
|
export declare const SandboxToolOutcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
118
145
|
kind: z.ZodLiteral<"completed">;
|
|
119
146
|
output: z.ZodUnknown;
|
|
@@ -9373,7 +9400,6 @@ export declare const SessionItemsResponse: z.ZodObject<{
|
|
|
9373
9400
|
}, z.core.$strip>;
|
|
9374
9401
|
export declare const StreamClosedFrame: z.ZodObject<{
|
|
9375
9402
|
reason: z.ZodEnum<{
|
|
9376
|
-
revoked: "revoked";
|
|
9377
9403
|
token_expired: "token_expired";
|
|
9378
9404
|
}>;
|
|
9379
9405
|
}, z.core.$strict>;
|
|
@@ -9805,7 +9831,11 @@ export declare const CreateVaultRequest: z.ZodObject<{
|
|
|
9805
9831
|
requestId: z.ZodString;
|
|
9806
9832
|
idempotencyKey: z.ZodString;
|
|
9807
9833
|
name: z.ZodString;
|
|
9808
|
-
|
|
9834
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
9835
|
+
installation: "installation";
|
|
9836
|
+
user: "user";
|
|
9837
|
+
}>>;
|
|
9838
|
+
ownerUserId: z.ZodOptional<z.ZodString>;
|
|
9809
9839
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
9810
9840
|
}, z.core.$strict>;
|
|
9811
9841
|
export declare const VaultInfo: z.ZodObject<{
|
|
@@ -9897,6 +9927,15 @@ export declare const RotateCredentialRequest: z.ZodObject<{
|
|
|
9897
9927
|
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
9898
9928
|
}, z.core.$strict>], "type">;
|
|
9899
9929
|
}, z.core.$strict>;
|
|
9930
|
+
export declare const StartOAuthRequest: z.ZodObject<{
|
|
9931
|
+
url: z.ZodString;
|
|
9932
|
+
server: z.ZodString;
|
|
9933
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
9934
|
+
}, z.core.$strict>;
|
|
9935
|
+
export declare const StartOAuthResponse: z.ZodObject<{
|
|
9936
|
+
authorizeUrl: z.ZodString;
|
|
9937
|
+
expiresAt: z.ZodString;
|
|
9938
|
+
}, z.core.$strict>;
|
|
9900
9939
|
export declare const DeletedResponse: z.ZodObject<{
|
|
9901
9940
|
id: z.ZodString;
|
|
9902
9941
|
}, z.core.$strict>;
|
|
@@ -9911,86 +9950,6 @@ export declare const Jwks: z.ZodObject<{
|
|
|
9911
9950
|
use: z.ZodLiteral<"sig">;
|
|
9912
9951
|
}, z.core.$strict>>;
|
|
9913
9952
|
}, z.core.$strict>;
|
|
9914
|
-
export declare const CreateTokenRequest: z.ZodObject<{
|
|
9915
|
-
requestId: z.ZodString;
|
|
9916
|
-
subject: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
9917
|
-
role: z.ZodString;
|
|
9918
|
-
scopes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
9919
|
-
"agents:read": "agents:read";
|
|
9920
|
-
"sandboxes:write": "sandboxes:write";
|
|
9921
|
-
"sessions:own": "sessions:own";
|
|
9922
|
-
"vaults:own": "vaults:own";
|
|
9923
|
-
}>>>;
|
|
9924
|
-
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
9925
|
-
sandboxes: z.ZodOptional<z.ZodArray<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>>;
|
|
9926
|
-
ttlSeconds: z.ZodOptional<z.ZodNumber>;
|
|
9927
|
-
}, z.core.$strict>;
|
|
9928
|
-
export declare const CreateTokenResponse: z.ZodObject<{
|
|
9929
|
-
token: z.ZodString;
|
|
9930
|
-
expiresAt: z.ZodString;
|
|
9931
|
-
subject: z.ZodString;
|
|
9932
|
-
role: z.ZodString;
|
|
9933
|
-
scopes: z.ZodArray<z.ZodEnum<{
|
|
9934
|
-
"agents:read": "agents:read";
|
|
9935
|
-
"sandboxes:write": "sandboxes:write";
|
|
9936
|
-
"sessions:own": "sessions:own";
|
|
9937
|
-
"vaults:own": "vaults:own";
|
|
9938
|
-
}>>;
|
|
9939
|
-
agents: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>;
|
|
9940
|
-
sandboxes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
9941
|
-
keyId: z.ZodString;
|
|
9942
|
-
}, z.core.$strict>;
|
|
9943
|
-
export declare const AccessPolicyResponse: z.ZodObject<{
|
|
9944
|
-
policy: z.ZodObject<{
|
|
9945
|
-
version: z.ZodLiteral<1>;
|
|
9946
|
-
roles: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
9947
|
-
scopes: z.ZodArray<z.ZodEnum<{
|
|
9948
|
-
"agents:read": "agents:read";
|
|
9949
|
-
"sandboxes:write": "sandboxes:write";
|
|
9950
|
-
"sessions:own": "sessions:own";
|
|
9951
|
-
"vaults:own": "vaults:own";
|
|
9952
|
-
}>>;
|
|
9953
|
-
agents: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>;
|
|
9954
|
-
limits: z.ZodOptional<z.ZodObject<{
|
|
9955
|
-
turnsPerHour: z.ZodOptional<z.ZodNumber>;
|
|
9956
|
-
concurrentTurns: z.ZodOptional<z.ZodNumber>;
|
|
9957
|
-
}, z.core.$strict>>;
|
|
9958
|
-
}, z.core.$strict>>;
|
|
9959
|
-
anon: z.ZodObject<{
|
|
9960
|
-
scopes: z.ZodArray<z.ZodLiteral<"agents:read">>;
|
|
9961
|
-
agents: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>;
|
|
9962
|
-
}, z.core.$strict>;
|
|
9963
|
-
tokens: z.ZodObject<{
|
|
9964
|
-
maxTtlSeconds: z.ZodNumber;
|
|
9965
|
-
}, z.core.$strict>;
|
|
9966
|
-
}, z.core.$strict>;
|
|
9967
|
-
}, z.core.$strict>;
|
|
9968
|
-
export declare const PutAccessPolicyRequest: z.ZodObject<{
|
|
9969
|
-
requestId: z.ZodString;
|
|
9970
|
-
policy: z.ZodObject<{
|
|
9971
|
-
version: z.ZodLiteral<1>;
|
|
9972
|
-
roles: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
9973
|
-
scopes: z.ZodArray<z.ZodEnum<{
|
|
9974
|
-
"agents:read": "agents:read";
|
|
9975
|
-
"sandboxes:write": "sandboxes:write";
|
|
9976
|
-
"sessions:own": "sessions:own";
|
|
9977
|
-
"vaults:own": "vaults:own";
|
|
9978
|
-
}>>;
|
|
9979
|
-
agents: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>;
|
|
9980
|
-
limits: z.ZodOptional<z.ZodObject<{
|
|
9981
|
-
turnsPerHour: z.ZodOptional<z.ZodNumber>;
|
|
9982
|
-
concurrentTurns: z.ZodOptional<z.ZodNumber>;
|
|
9983
|
-
}, z.core.$strict>>;
|
|
9984
|
-
}, z.core.$strict>>;
|
|
9985
|
-
anon: z.ZodObject<{
|
|
9986
|
-
scopes: z.ZodArray<z.ZodLiteral<"agents:read">>;
|
|
9987
|
-
agents: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>;
|
|
9988
|
-
}, z.core.$strict>;
|
|
9989
|
-
tokens: z.ZodObject<{
|
|
9990
|
-
maxTtlSeconds: z.ZodNumber;
|
|
9991
|
-
}, z.core.$strict>;
|
|
9992
|
-
}, z.core.$strict>;
|
|
9993
|
-
}, z.core.$strict>;
|
|
9994
9953
|
export declare const SigningKeyList: z.ZodObject<{
|
|
9995
9954
|
keys: z.ZodArray<z.ZodObject<{
|
|
9996
9955
|
id: z.ZodString;
|
|
@@ -10046,38 +10005,17 @@ export declare const RotateSigningKeysRequest: z.ZodObject<{
|
|
|
10046
10005
|
export declare const RevokeSigningKeyRequest: z.ZodObject<{
|
|
10047
10006
|
requestId: z.ZodString;
|
|
10048
10007
|
}, z.core.$strict>;
|
|
10049
|
-
export declare const
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
}
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
key: z.ZodString;
|
|
10063
|
-
origins: z.ZodArray<z.ZodString>;
|
|
10064
|
-
createdAt: z.ZodString;
|
|
10065
|
-
revokedAt: z.ZodNullable<z.ZodString>;
|
|
10066
|
-
}, z.core.$strict>;
|
|
10067
|
-
export declare const CreatePublishableKeyRequest: z.ZodObject<{
|
|
10068
|
-
requestId: z.ZodString;
|
|
10069
|
-
name: z.ZodString;
|
|
10070
|
-
origins: z.ZodArray<z.ZodString>;
|
|
10071
|
-
}, z.core.$strict>;
|
|
10072
|
-
export declare const UpdatePublishableKeyRequest: z.ZodObject<{
|
|
10073
|
-
requestId: z.ZodString;
|
|
10074
|
-
origins: z.ZodArray<z.ZodString>;
|
|
10075
|
-
}, z.core.$strict>;
|
|
10076
|
-
export declare const RevokeSubjectRequest: z.ZodObject<{
|
|
10077
|
-
requestId: z.ZodString;
|
|
10078
|
-
subject: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
10079
|
-
}, z.core.$strict>;
|
|
10080
|
-
export declare const RevokeSubjectResponse: z.ZodObject<{
|
|
10081
|
-
subject: z.ZodString;
|
|
10082
|
-
epoch: z.ZodNumber;
|
|
10008
|
+
export declare const MeResponse: z.ZodObject<{
|
|
10009
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
10010
|
+
scopes: z.ZodArray<z.ZodEnum<{
|
|
10011
|
+
"agents:read": "agents:read";
|
|
10012
|
+
"agents:write": "agents:write";
|
|
10013
|
+
"sandboxes:write": "sandboxes:write";
|
|
10014
|
+
"sessions:own": "sessions:own";
|
|
10015
|
+
studio: "studio";
|
|
10016
|
+
"tenant:settings": "tenant:settings";
|
|
10017
|
+
}>>;
|
|
10018
|
+
agents: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>;
|
|
10019
|
+
sandboxes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10020
|
+
via: z.ZodString;
|
|
10083
10021
|
}, z.core.$strict>;
|
package/dist/api/components.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* global registry.
|
|
6
6
|
*/
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import { JwksSchema,
|
|
8
|
+
import { JwksSchema, SigningKeyListSchema, SigningKeyViewSchema, RotateSigningKeysRequestSchema, RevokeSigningKeyRequestSchema, MeResponseSchema, TenantStatusSchema, ResetTenantRequestSchema, ResetTenantResponseSchema, SeedTenantConfigRequestSchema, SeedTenantConfigResponseSchema, HostModelCatalogSchema, TenantSandboxViewSchema, ModelUsageTotalsSchema, ModelBudgetsSchema, PutModelBudgetsRequestSchema, PutTenantSandboxRequestSchema, ListProvidersResponseSchema, HostModelViewSchema, PutHostModelRequestSchema, SelectHostModelRequestSchema, CreateVaultRequestSchema, VaultInfoSchema, ListVaultsResponseSchema, CreateCredentialRequestSchema, CredentialInfoSchema, ListCredentialsResponseSchema, RotateCredentialRequestSchema, StartOAuthRequestSchema, StartOAuthResponseSchema, DeletedResponseSchema, ListAgentsResponseSchema, ListPublicAgentsResponseSchema, ListSessionsResponseSchema, LiveEventSchema, PutAgentRequestSchema, PutAgentResponseSchema, PutSessionRequestSchema, SessionItemsResponseSchema, SessionViewSchema, StreamClosedFrameSchema, AcceptedResponseSchema, ActionResultReceiptSchema, DeleteEndpointResponseSchema, DeliveryHeartbeatResponseSchema, ActionOutcomeSchema, EndpointPingResponseSchema, ListEndpointsResponseSchema, PutEndpointsRequestSchema, SandboxToolOutcomeSchema, PutSandboxRequestSchema, SandboxViewSchema, ListSandboxesResponseSchema, DeleteSandboxResponseSchema, ListSandboxEventsResponseSchema, ArtifactViewSchema, ArtifactVersionViewSchema, ListArtifactsResponseSchema, UploadArtifactResponseSchema, DeleteArtifactResponseSchema, CreateArtifactLinkRequestSchema, ArtifactLinkSchema, PutTenantArtifactsRequestSchema, TenantArtifactsViewSchema, ArtifactTreeSchema, ArtifactDiffSchema, SessionCommandSchema, AdminStatusSchema, HostShutdownResponseSchema, ListOperatorKeysResponseSchema, PutOperatorKeyResponseSchema, DeleteOperatorKeyResponseSchema, OperatorKeySchema, ProtocolRejectedResponseSchema, RejectedResponseSchema, EVENT_SCHEMAS, EVENT_TYPES, } from "@nylorun/core/contracts";
|
|
9
9
|
function named(id, schema) {
|
|
10
10
|
return schema.meta({ id });
|
|
11
11
|
}
|
|
@@ -13,6 +13,10 @@ export const Rejected = named("Rejected", RejectedResponseSchema);
|
|
|
13
13
|
export const ProtocolRejected = named("ProtocolRejected", ProtocolRejectedResponseSchema);
|
|
14
14
|
export const AdminStatus = named("AdminStatus", AdminStatusSchema);
|
|
15
15
|
export const HostShutdownResponse = named("HostShutdownResponse", HostShutdownResponseSchema);
|
|
16
|
+
export const OperatorKey = named("OperatorKey", OperatorKeySchema);
|
|
17
|
+
export const ListOperatorKeysResponse = named("ListOperatorKeysResponse", ListOperatorKeysResponseSchema);
|
|
18
|
+
export const PutOperatorKeyResponse = named("PutOperatorKeyResponse", PutOperatorKeyResponseSchema);
|
|
19
|
+
export const DeleteOperatorKeyResponse = named("DeleteOperatorKeyResponse", DeleteOperatorKeyResponseSchema);
|
|
16
20
|
export const SandboxToolOutcome = named("SandboxToolOutcome", SandboxToolOutcomeSchema);
|
|
17
21
|
export const PutSandboxRequest = named("PutSandboxRequest", PutSandboxRequestSchema);
|
|
18
22
|
export const SandboxView = named("SandboxView", SandboxViewSchema);
|
|
@@ -80,19 +84,12 @@ export const CreateCredentialRequest = named("CreateCredentialRequest", CreateCr
|
|
|
80
84
|
export const CredentialInfo = named("CredentialInfo", CredentialInfoSchema);
|
|
81
85
|
export const ListCredentialsResponse = named("ListCredentialsResponse", ListCredentialsResponseSchema);
|
|
82
86
|
export const RotateCredentialRequest = named("RotateCredentialRequest", RotateCredentialRequestSchema);
|
|
87
|
+
export const StartOAuthRequest = named("StartOAuthRequest", StartOAuthRequestSchema);
|
|
88
|
+
export const StartOAuthResponse = named("StartOAuthResponse", StartOAuthResponseSchema);
|
|
83
89
|
export const DeletedResponse = named("DeletedResponse", DeletedResponseSchema);
|
|
84
90
|
export const Jwks = named("Jwks", JwksSchema);
|
|
85
|
-
export const CreateTokenRequest = named("CreateTokenRequest", CreateTokenRequestSchema);
|
|
86
|
-
export const CreateTokenResponse = named("CreateTokenResponse", CreateTokenResponseSchema);
|
|
87
|
-
export const AccessPolicyResponse = named("AccessPolicyResponse", AccessPolicyResponseSchema);
|
|
88
|
-
export const PutAccessPolicyRequest = named("PutAccessPolicyRequest", PutAccessPolicyRequestSchema);
|
|
89
91
|
export const SigningKeyList = named("SigningKeyList", SigningKeyListSchema);
|
|
90
92
|
export const SigningKeyView = named("SigningKeyView", SigningKeyViewSchema);
|
|
91
93
|
export const RotateSigningKeysRequest = named("RotateSigningKeysRequest", RotateSigningKeysRequestSchema);
|
|
92
94
|
export const RevokeSigningKeyRequest = named("RevokeSigningKeyRequest", RevokeSigningKeyRequestSchema);
|
|
93
|
-
export const
|
|
94
|
-
export const PublishableKey = named("PublishableKey", PublishableKeySchema);
|
|
95
|
-
export const CreatePublishableKeyRequest = named("CreatePublishableKeyRequest", CreatePublishableKeyRequestSchema);
|
|
96
|
-
export const UpdatePublishableKeyRequest = named("UpdatePublishableKeyRequest", UpdatePublishableKeyRequestSchema);
|
|
97
|
-
export const RevokeSubjectRequest = named("RevokeSubjectRequest", RevokeSubjectRequestSchema);
|
|
98
|
-
export const RevokeSubjectResponse = named("RevokeSubjectResponse", RevokeSubjectResponseSchema);
|
|
95
|
+
export const MeResponse = named("MeResponse", MeResponseSchema);
|
package/dist/api/http/app.js
CHANGED
|
@@ -7,6 +7,7 @@ import { authenticateCaller, declaredRoute, pathSegments } from "./define.js";
|
|
|
7
7
|
import { jsonResponse, rejectionOf } from "./respond.js";
|
|
8
8
|
import { accessRoutes } from "./routes/access.js";
|
|
9
9
|
import { endpointRoutes } from "./routes/endpoints.js";
|
|
10
|
+
import { meRoutes } from "./routes/me.js";
|
|
10
11
|
import { actionRoutes } from "./routes/actions.js";
|
|
11
12
|
import { sandboxRoutes } from "./routes/sandboxes.js";
|
|
12
13
|
import { artifactRoutes } from "./routes/artifacts.js";
|
|
@@ -45,6 +46,7 @@ function build() {
|
|
|
45
46
|
tenantRoutes(api);
|
|
46
47
|
vaultRoutes(api);
|
|
47
48
|
accessRoutes(api);
|
|
49
|
+
meRoutes(api);
|
|
48
50
|
agUiRoutes(api);
|
|
49
51
|
a2aRoutes(api);
|
|
50
52
|
api.notFound(notFound);
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* How a Tenant API route is declared: once, with who may call it, for serving and for the
|
|
3
3
|
* OpenAPI document.
|
|
4
4
|
*
|
|
5
|
-
* `RouteAccess` says which credentials a route takes
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* `RouteAccess` says which credentials a route takes and which subject scopes reach it: the one
|
|
6
|
+
* statement of who may call a route. The document shows it as the operation's `security`, its
|
|
7
|
+
* `Nylorun-*` headers and `x-nylorun-*` fields. Serving runs the Tenant's checks in order: the
|
|
8
|
+
* bearer, the subject's scopes, then the handler, which parses its body. The Runtime sends no
|
|
9
|
+
* CORS headers: a browser reaches it through the operator's proxy, with a trusted issuer's
|
|
10
|
+
* token.
|
|
11
11
|
*/
|
|
12
12
|
import type { IncomingMessage } from "node:http";
|
|
13
13
|
import type { OpenAPIHono, RouteConfig } from "@hono/zod-openapi";
|
|
@@ -15,16 +15,13 @@ import type { Context, Handler } from "hono";
|
|
|
15
15
|
import type { SubjectScope } from "@nylorun/core/contracts";
|
|
16
16
|
import type { AuthScope } from "../../tenant/context.js";
|
|
17
17
|
import type { TenantEnv } from "./app.js";
|
|
18
|
-
export type Credential = "application" | "subject" | "token" | "
|
|
18
|
+
export type Credential = "application" | "subject" | "token" | "delivery";
|
|
19
19
|
export interface RouteAccess {
|
|
20
20
|
readonly credentials: readonly Credential[];
|
|
21
21
|
/** The subject scopes that reach the route: any one of them, none (`never`), or all (`any`). */
|
|
22
22
|
readonly scopes: readonly SubjectScope[] | "never" | "any";
|
|
23
|
-
/** A browser page may call it: its preflight is allowed. */
|
|
24
|
-
readonly browser?: boolean;
|
|
25
23
|
/**
|
|
26
|
-
* Public data: a request with no credential at all (no `Authorization
|
|
27
|
-
* served too. A credential that is sent is still checked, so a wrong one stays the opaque 404.
|
|
24
|
+
* Public data: a request with no credential at all (no `Authorization`) is served too. A credential that is sent is still checked, so a wrong one stays the opaque 404.
|
|
28
25
|
*/
|
|
29
26
|
readonly anonymous?: boolean;
|
|
30
27
|
/**
|
|
@@ -40,7 +37,7 @@ export interface RouteAccess {
|
|
|
40
37
|
}
|
|
41
38
|
/** The route's path segments, decoded, as the Tenant's checks read them. */
|
|
42
39
|
export declare function pathSegments(incoming: IncomingMessage): string[];
|
|
43
|
-
/** Who is calling: the
|
|
40
|
+
/** Who is calling: the bearer, as every Tenant request checks it. */
|
|
44
41
|
export declare function authenticateCaller(c: Context<TenantEnv>,
|
|
45
42
|
/** The route serves public data (`RouteAccess.anonymous`): no credential is needed. */
|
|
46
43
|
anonymous?: boolean): Promise<AuthScope>;
|
package/dist/api/http/define.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { PROTOCOL_VERSION } from "@nylorun/core/compatibility";
|
|
3
3
|
import { authenticate, requireScopes } from "../../tenant/auth.js";
|
|
4
|
-
import { identifyClient } from "../../tenant/browser.js";
|
|
5
4
|
import { fail } from "../../tenant/http.js";
|
|
6
5
|
import { ProtocolRejected, Rejected } from "../components.js";
|
|
7
6
|
const SCHEMES = {
|
|
8
7
|
application: "applicationKey",
|
|
9
8
|
subject: "applicationKey",
|
|
10
|
-
token: "
|
|
11
|
-
publishable: "publishableKey",
|
|
9
|
+
token: "issuerToken",
|
|
12
10
|
delivery: "deliveryToken",
|
|
13
11
|
};
|
|
14
12
|
const rejected = (description) => ({
|
|
@@ -29,17 +27,14 @@ export function pathSegments(incoming) {
|
|
|
29
27
|
}
|
|
30
28
|
});
|
|
31
29
|
}
|
|
32
|
-
/** Who is calling: the
|
|
30
|
+
/** Who is calling: the bearer, as every Tenant request checks it. */
|
|
33
31
|
export async function authenticateCaller(c,
|
|
34
32
|
/** The route serves public data (`RouteAccess.anonymous`): no credential is needed. */
|
|
35
33
|
anonymous = false) {
|
|
36
|
-
const { tenant, incoming
|
|
37
|
-
|
|
38
|
-
// bearer is looked at, so every answer from here on is readable by an allowed page.
|
|
39
|
-
const client = await identifyClient(tenant, incoming, outgoing);
|
|
40
|
-
if (anonymous && !client && incoming.headers.authorization === undefined)
|
|
34
|
+
const { tenant, incoming } = c.env;
|
|
35
|
+
if (anonymous && incoming.headers.authorization === undefined)
|
|
41
36
|
return { kind: "anonymous" };
|
|
42
|
-
return await authenticate(tenant, incoming
|
|
37
|
+
return await authenticate(tenant, incoming);
|
|
43
38
|
}
|
|
44
39
|
const declared = [];
|
|
45
40
|
/** The declared route `method path` is, if any. `{param}` segments match any one segment. */
|
|
@@ -53,10 +48,6 @@ function authenticated(access) {
|
|
|
53
48
|
return async (c, next) => {
|
|
54
49
|
const scope = await authenticateCaller(c, access.anonymous === true);
|
|
55
50
|
requireScopes(scope, access.scopes);
|
|
56
|
-
if (scope.kind === "publishable" && !access.credentials.includes("publishable"))
|
|
57
|
-
fail(403, "A publishable key alone reaches only the agent list", {
|
|
58
|
-
code: "scope_required",
|
|
59
|
-
});
|
|
60
51
|
// Handlers tell callers apart by kind, and a delivery token is none of theirs: only the
|
|
61
52
|
// routes that list it may see one.
|
|
62
53
|
if (scope.kind === "delivery" && !access.credentials.includes("delivery"))
|
|
@@ -83,14 +74,6 @@ export function tenantRoute(api, access, route, handler) {
|
|
|
83
74
|
.meta({ description: "The subject's space-separated scopes; required with a subject" }),
|
|
84
75
|
}
|
|
85
76
|
: {}),
|
|
86
|
-
...(takes("publishable")
|
|
87
|
-
? {
|
|
88
|
-
"Nylorun-Key": z
|
|
89
|
-
.string()
|
|
90
|
-
.optional()
|
|
91
|
-
.meta({ description: "A publishable key, from a browser page on an allowed origin" }),
|
|
92
|
-
}
|
|
93
|
-
: {}),
|
|
94
77
|
});
|
|
95
78
|
api.openAPIRegistry.registerPath({
|
|
96
79
|
...route,
|
|
@@ -102,17 +85,19 @@ export function tenantRoute(api, access, route, handler) {
|
|
|
102
85
|
request: { ...route.request, headers },
|
|
103
86
|
responses: {
|
|
104
87
|
400: rejected("Invalid headers, path, body or cursor"),
|
|
105
|
-
...(takes("token")
|
|
106
|
-
|
|
88
|
+
...(takes("token")
|
|
89
|
+
? {
|
|
90
|
+
401: rejected("The token expired (`token_expired`), or its issuer's keys cannot be fetched now (`issuer_unavailable`)"),
|
|
91
|
+
}
|
|
92
|
+
: {}),
|
|
93
|
+
403: rejected("Not allowed for this credential or subject scope, or an application key from a browser (`origin_rejected`)"),
|
|
107
94
|
404: rejected("Not found, or a credential the Tenant does not know (`not_found`)"),
|
|
108
95
|
426: { description: "`Nylorun-Protocol` missing or unsupported", content: { "application/json": { schema: ProtocolRejected } } },
|
|
109
|
-
...(takes("token") ? { 429: rejected("The subject's turn limits are reached (`limit_exceeded`)") } : {}),
|
|
110
96
|
503: rejected("The Tenant's storage or streams are unavailable"),
|
|
111
97
|
...route.responses,
|
|
112
98
|
},
|
|
113
99
|
"x-nylorun-credentials": access.credentials,
|
|
114
100
|
"x-nylorun-scopes": access.scopes,
|
|
115
|
-
"x-nylorun-browser": access.browser === true,
|
|
116
101
|
});
|
|
117
102
|
declared.push({
|
|
118
103
|
method: route.method.toUpperCase(),
|
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Subjects travel in bodies, not paths, because they may be email addresses and request paths
|
|
7
|
-
* are logged.
|
|
2
|
+
* Signing keys, for the application key only, and the public keys, for any caller that reached
|
|
3
|
+
* the Tenant: the Runtime signs delivery tokens and capability links with them (protocol 7 has
|
|
4
|
+
* no subject tokens, access policy, browser keys or revocations).
|
|
8
5
|
*/
|
|
9
6
|
import type { OpenAPIHono } from "@hono/zod-openapi";
|
|
10
|
-
import type { PublishableKey as PublishableKeyBody } from "@nylorun/core/contracts";
|
|
11
|
-
import type { PublishableKeyRow } from "../../../store/types.js";
|
|
12
|
-
import type { TenantContext } from "../../../tenant/context.js";
|
|
13
7
|
import type { TenantEnv } from "../app.js";
|
|
14
8
|
export declare function accessRoutes(api: OpenAPIHono<TenantEnv>): void;
|
|
15
|
-
/** A publishable key as the API shows it. */
|
|
16
|
-
export declare function publishableKeyView(row: PublishableKeyRow): PublishableKeyBody;
|
|
17
|
-
/**
|
|
18
|
-
* Ends every token of `subject` minted so far: bumps its epoch, then ends its open streams
|
|
19
|
-
* here and, through `tenant/control`, on every other process. Running turns continue.
|
|
20
|
-
*/
|
|
21
|
-
export declare function revokeSubject(ctx: TenantContext, subject: string): Promise<{
|
|
22
|
-
subject: string;
|
|
23
|
-
epoch: number;
|
|
24
|
-
}>;
|