@nylorun/runtime 0.32.0-beta → 0.33.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 +20 -0
- package/dist/api/components.d.ts +35 -0
- package/dist/api/components.js +3 -1
- package/dist/api/http/routes/sessions.js +63 -2
- package/dist/api/openapi.js +3 -0
- package/dist/gates/handler.js +2 -2
- package/dist/gates/in-process.d.ts +4 -3
- package/dist/gates/in-process.js +11 -5
- package/dist/gates/tenant-vaults.d.ts +4 -3
- package/dist/gates/tenant-vaults.js +2 -2
- package/dist/harness-api/start.js +1 -1
- package/dist/host/main.js +2 -0
- package/dist/host/stack-config.d.ts +5 -0
- package/dist/host/stack-config.js +15 -0
- package/dist/management-openapi.json +60 -5
- package/dist/model/descriptor.d.ts +5 -4
- package/dist/model/descriptor.js +4 -3
- package/dist/model/pi-model.js +17 -1
- package/dist/openapi.json +515 -2
- package/dist/tenant/context.d.ts +6 -1
- package/dist/tenant/session-model.d.ts +16 -0
- package/dist/tenant/session-model.js +46 -0
- package/dist/vault/host-identity.d.ts +24 -0
- package/dist/vault/host-identity.js +35 -0
- package/dist/vault/host-model.d.ts +9 -5
- package/dist/vault/host-model.js +30 -19
- package/dist/vault/service.d.ts +18 -2
- package/dist/vault/service.js +52 -9
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
package/dist/openapi.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"openapi": "3.2.0",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "Nylorun Runtime API",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.33.0-beta",
|
|
6
6
|
"x-nylorun-protocol": {
|
|
7
7
|
"min": 16,
|
|
8
8
|
"max": 18,
|
|
@@ -34,7 +34,9 @@
|
|
|
34
34
|
"traces",
|
|
35
35
|
"artifact-reads",
|
|
36
36
|
"gateway-credentials",
|
|
37
|
-
"agent-folders"
|
|
37
|
+
"agent-folders",
|
|
38
|
+
"session-model",
|
|
39
|
+
"model-host-identity"
|
|
38
40
|
]
|
|
39
41
|
},
|
|
40
42
|
"description": "For developers: agent manifests, Agents, sessions (with AG-UI and A2A) and artifacts, through `@nylorun/agents`. Every Tenant serves it on its one URL, beside the Management API (`/openapi/management.json`). Every request sends `Nylorun-Protocol`. Who may call each operation is its `security` and its `x-nylorun-credentials` and `x-nylorun-scopes` (the subject scopes that reach it) fields: an application key (servers) or a trusted issuer's token (browsers and apps)."
|
|
@@ -8867,6 +8869,113 @@
|
|
|
8867
8869
|
],
|
|
8868
8870
|
"additionalProperties": false
|
|
8869
8871
|
},
|
|
8872
|
+
"SessionModelView": {
|
|
8873
|
+
"anyOf": [
|
|
8874
|
+
{
|
|
8875
|
+
"type": "object",
|
|
8876
|
+
"properties": {
|
|
8877
|
+
"configured": {
|
|
8878
|
+
"type": "boolean",
|
|
8879
|
+
"enum": [
|
|
8880
|
+
false
|
|
8881
|
+
]
|
|
8882
|
+
},
|
|
8883
|
+
"choice": {
|
|
8884
|
+
"type": "object",
|
|
8885
|
+
"properties": {
|
|
8886
|
+
"provider": {
|
|
8887
|
+
"type": "string",
|
|
8888
|
+
"minLength": 1
|
|
8889
|
+
},
|
|
8890
|
+
"model": {
|
|
8891
|
+
"type": "string",
|
|
8892
|
+
"minLength": 1
|
|
8893
|
+
}
|
|
8894
|
+
},
|
|
8895
|
+
"required": [
|
|
8896
|
+
"provider",
|
|
8897
|
+
"model"
|
|
8898
|
+
],
|
|
8899
|
+
"additionalProperties": false
|
|
8900
|
+
}
|
|
8901
|
+
},
|
|
8902
|
+
"required": [
|
|
8903
|
+
"configured"
|
|
8904
|
+
],
|
|
8905
|
+
"additionalProperties": false
|
|
8906
|
+
},
|
|
8907
|
+
{
|
|
8908
|
+
"type": "object",
|
|
8909
|
+
"properties": {
|
|
8910
|
+
"configured": {
|
|
8911
|
+
"type": "boolean",
|
|
8912
|
+
"enum": [
|
|
8913
|
+
true
|
|
8914
|
+
]
|
|
8915
|
+
},
|
|
8916
|
+
"source": {
|
|
8917
|
+
"type": "string",
|
|
8918
|
+
"enum": [
|
|
8919
|
+
"session",
|
|
8920
|
+
"tenant"
|
|
8921
|
+
]
|
|
8922
|
+
},
|
|
8923
|
+
"provider": {
|
|
8924
|
+
"type": "string"
|
|
8925
|
+
},
|
|
8926
|
+
"model": {
|
|
8927
|
+
"type": "string"
|
|
8928
|
+
},
|
|
8929
|
+
"baseUrl": {
|
|
8930
|
+
"type": "string"
|
|
8931
|
+
},
|
|
8932
|
+
"choice": {
|
|
8933
|
+
"type": "object",
|
|
8934
|
+
"properties": {
|
|
8935
|
+
"provider": {
|
|
8936
|
+
"type": "string",
|
|
8937
|
+
"minLength": 1
|
|
8938
|
+
},
|
|
8939
|
+
"model": {
|
|
8940
|
+
"type": "string",
|
|
8941
|
+
"minLength": 1
|
|
8942
|
+
}
|
|
8943
|
+
},
|
|
8944
|
+
"required": [
|
|
8945
|
+
"provider",
|
|
8946
|
+
"model"
|
|
8947
|
+
],
|
|
8948
|
+
"additionalProperties": false
|
|
8949
|
+
}
|
|
8950
|
+
},
|
|
8951
|
+
"required": [
|
|
8952
|
+
"configured",
|
|
8953
|
+
"source",
|
|
8954
|
+
"provider",
|
|
8955
|
+
"model"
|
|
8956
|
+
],
|
|
8957
|
+
"additionalProperties": false
|
|
8958
|
+
}
|
|
8959
|
+
]
|
|
8960
|
+
},
|
|
8961
|
+
"PutSessionModelRequest": {
|
|
8962
|
+
"type": "object",
|
|
8963
|
+
"properties": {
|
|
8964
|
+
"provider": {
|
|
8965
|
+
"type": "string",
|
|
8966
|
+
"minLength": 1
|
|
8967
|
+
},
|
|
8968
|
+
"model": {
|
|
8969
|
+
"type": "string",
|
|
8970
|
+
"minLength": 1
|
|
8971
|
+
}
|
|
8972
|
+
},
|
|
8973
|
+
"required": [
|
|
8974
|
+
"provider",
|
|
8975
|
+
"model"
|
|
8976
|
+
],
|
|
8977
|
+
"additionalProperties": false
|
|
8978
|
+
},
|
|
8870
8979
|
"SessionItemsResponse": {
|
|
8871
8980
|
"type": "object",
|
|
8872
8981
|
"properties": {
|
|
@@ -32816,6 +32925,410 @@
|
|
|
32816
32925
|
}
|
|
32817
32926
|
}
|
|
32818
32927
|
},
|
|
32928
|
+
"/v1/sessions/{sessionId}/model": {
|
|
32929
|
+
"get": {
|
|
32930
|
+
"tags": [
|
|
32931
|
+
"Sessions API"
|
|
32932
|
+
],
|
|
32933
|
+
"summary": "Get a session's model",
|
|
32934
|
+
"description": "The model the session's next turn uses (feature `session-model`): its own (`source: \"session\"`) while its provider is connected, else the Tenant's (`source: \"tenant\"`). `choice` is the session's own model, kept while its provider is disconnected.",
|
|
32935
|
+
"security": [
|
|
32936
|
+
{
|
|
32937
|
+
"applicationKey": []
|
|
32938
|
+
},
|
|
32939
|
+
{
|
|
32940
|
+
"issuerToken": []
|
|
32941
|
+
}
|
|
32942
|
+
],
|
|
32943
|
+
"x-nylorun-credentials": [
|
|
32944
|
+
"application",
|
|
32945
|
+
"subject",
|
|
32946
|
+
"token"
|
|
32947
|
+
],
|
|
32948
|
+
"x-nylorun-scopes": [
|
|
32949
|
+
"sessions:own"
|
|
32950
|
+
],
|
|
32951
|
+
"parameters": [
|
|
32952
|
+
{
|
|
32953
|
+
"schema": {
|
|
32954
|
+
"type": "string"
|
|
32955
|
+
},
|
|
32956
|
+
"required": true,
|
|
32957
|
+
"name": "sessionId",
|
|
32958
|
+
"in": "path"
|
|
32959
|
+
},
|
|
32960
|
+
{
|
|
32961
|
+
"schema": {
|
|
32962
|
+
"type": "string",
|
|
32963
|
+
"description": "The protocol version, `18`"
|
|
32964
|
+
},
|
|
32965
|
+
"required": true,
|
|
32966
|
+
"description": "The protocol version, `18`",
|
|
32967
|
+
"name": "Nylorun-Protocol",
|
|
32968
|
+
"in": "header"
|
|
32969
|
+
},
|
|
32970
|
+
{
|
|
32971
|
+
"schema": {
|
|
32972
|
+
"type": "string",
|
|
32973
|
+
"description": "The person an application key acts for"
|
|
32974
|
+
},
|
|
32975
|
+
"required": false,
|
|
32976
|
+
"description": "The person an application key acts for",
|
|
32977
|
+
"name": "Nylorun-Subject",
|
|
32978
|
+
"in": "header"
|
|
32979
|
+
},
|
|
32980
|
+
{
|
|
32981
|
+
"schema": {
|
|
32982
|
+
"type": "string",
|
|
32983
|
+
"description": "The subject's space-separated scopes; required with a subject"
|
|
32984
|
+
},
|
|
32985
|
+
"required": false,
|
|
32986
|
+
"description": "The subject's space-separated scopes; required with a subject",
|
|
32987
|
+
"name": "Nylorun-Scopes",
|
|
32988
|
+
"in": "header"
|
|
32989
|
+
}
|
|
32990
|
+
],
|
|
32991
|
+
"responses": {
|
|
32992
|
+
"200": {
|
|
32993
|
+
"description": "The session's model",
|
|
32994
|
+
"content": {
|
|
32995
|
+
"application/json": {
|
|
32996
|
+
"schema": {
|
|
32997
|
+
"$ref": "#/components/schemas/SessionModelView"
|
|
32998
|
+
}
|
|
32999
|
+
}
|
|
33000
|
+
}
|
|
33001
|
+
},
|
|
33002
|
+
"400": {
|
|
33003
|
+
"description": "Invalid headers, path, body or cursor",
|
|
33004
|
+
"content": {
|
|
33005
|
+
"application/json": {
|
|
33006
|
+
"schema": {
|
|
33007
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33008
|
+
}
|
|
33009
|
+
}
|
|
33010
|
+
}
|
|
33011
|
+
},
|
|
33012
|
+
"401": {
|
|
33013
|
+
"description": "No credential (`credential_required`), one the Tenant does not accept (`credential_invalid`), a token that expired (`token_expired`), or a token whose issuer's keys cannot be fetched now (`issuer_unavailable`). `WWW-Authenticate: Bearer` names the protected resource metadata (`resource_metadata`)",
|
|
33014
|
+
"content": {
|
|
33015
|
+
"application/json": {
|
|
33016
|
+
"schema": {
|
|
33017
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33018
|
+
}
|
|
33019
|
+
}
|
|
33020
|
+
}
|
|
33021
|
+
},
|
|
33022
|
+
"403": {
|
|
33023
|
+
"description": "Not allowed for this credential or subject scope (`scope_required`; a token also gets `WWW-Authenticate: Bearer error=\"insufficient_scope\"` and the scope), a key of the other API (`key_role_mismatch`), or an application key from a browser (`origin_rejected`)",
|
|
33024
|
+
"content": {
|
|
33025
|
+
"application/json": {
|
|
33026
|
+
"schema": {
|
|
33027
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33028
|
+
}
|
|
33029
|
+
}
|
|
33030
|
+
}
|
|
33031
|
+
},
|
|
33032
|
+
"404": {
|
|
33033
|
+
"description": "Not found (`not_found`)",
|
|
33034
|
+
"content": {
|
|
33035
|
+
"application/json": {
|
|
33036
|
+
"schema": {
|
|
33037
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33038
|
+
}
|
|
33039
|
+
}
|
|
33040
|
+
}
|
|
33041
|
+
},
|
|
33042
|
+
"426": {
|
|
33043
|
+
"description": "`Nylorun-Protocol` missing or unsupported",
|
|
33044
|
+
"content": {
|
|
33045
|
+
"application/json": {
|
|
33046
|
+
"schema": {
|
|
33047
|
+
"$ref": "#/components/schemas/ProtocolRejected"
|
|
33048
|
+
}
|
|
33049
|
+
}
|
|
33050
|
+
}
|
|
33051
|
+
},
|
|
33052
|
+
"503": {
|
|
33053
|
+
"description": "The Tenant's storage or streams are unavailable",
|
|
33054
|
+
"content": {
|
|
33055
|
+
"application/json": {
|
|
33056
|
+
"schema": {
|
|
33057
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33058
|
+
}
|
|
33059
|
+
}
|
|
33060
|
+
}
|
|
33061
|
+
}
|
|
33062
|
+
}
|
|
33063
|
+
},
|
|
33064
|
+
"put": {
|
|
33065
|
+
"tags": [
|
|
33066
|
+
"Sessions API"
|
|
33067
|
+
],
|
|
33068
|
+
"summary": "Choose a session's model",
|
|
33069
|
+
"description": "Chooses one of a connected provider's models for the session's turns (feature `session-model`), in place of the Tenant's model. The Tenant's model and every other session's stay as they are. Only the application sets it, for itself or for a subject: a trusted issuer's token is refused. A turn calls one model, so the choice changes only while no turn runs or waits (`409 session_busy`). A provider that is not connected, or a model its catalog does not list, is `422 request_rejected`.",
|
|
33070
|
+
"security": [
|
|
33071
|
+
{
|
|
33072
|
+
"applicationKey": []
|
|
33073
|
+
}
|
|
33074
|
+
],
|
|
33075
|
+
"x-nylorun-credentials": [
|
|
33076
|
+
"application",
|
|
33077
|
+
"subject"
|
|
33078
|
+
],
|
|
33079
|
+
"x-nylorun-scopes": [
|
|
33080
|
+
"sessions:own"
|
|
33081
|
+
],
|
|
33082
|
+
"parameters": [
|
|
33083
|
+
{
|
|
33084
|
+
"schema": {
|
|
33085
|
+
"type": "string"
|
|
33086
|
+
},
|
|
33087
|
+
"required": true,
|
|
33088
|
+
"name": "sessionId",
|
|
33089
|
+
"in": "path"
|
|
33090
|
+
},
|
|
33091
|
+
{
|
|
33092
|
+
"schema": {
|
|
33093
|
+
"type": "string",
|
|
33094
|
+
"description": "The protocol version, `18`"
|
|
33095
|
+
},
|
|
33096
|
+
"required": true,
|
|
33097
|
+
"description": "The protocol version, `18`",
|
|
33098
|
+
"name": "Nylorun-Protocol",
|
|
33099
|
+
"in": "header"
|
|
33100
|
+
},
|
|
33101
|
+
{
|
|
33102
|
+
"schema": {
|
|
33103
|
+
"type": "string",
|
|
33104
|
+
"description": "The person an application key acts for"
|
|
33105
|
+
},
|
|
33106
|
+
"required": false,
|
|
33107
|
+
"description": "The person an application key acts for",
|
|
33108
|
+
"name": "Nylorun-Subject",
|
|
33109
|
+
"in": "header"
|
|
33110
|
+
},
|
|
33111
|
+
{
|
|
33112
|
+
"schema": {
|
|
33113
|
+
"type": "string",
|
|
33114
|
+
"description": "The subject's space-separated scopes; required with a subject"
|
|
33115
|
+
},
|
|
33116
|
+
"required": false,
|
|
33117
|
+
"description": "The subject's space-separated scopes; required with a subject",
|
|
33118
|
+
"name": "Nylorun-Scopes",
|
|
33119
|
+
"in": "header"
|
|
33120
|
+
}
|
|
33121
|
+
],
|
|
33122
|
+
"requestBody": {
|
|
33123
|
+
"required": true,
|
|
33124
|
+
"content": {
|
|
33125
|
+
"application/json": {
|
|
33126
|
+
"schema": {
|
|
33127
|
+
"$ref": "#/components/schemas/PutSessionModelRequest"
|
|
33128
|
+
}
|
|
33129
|
+
}
|
|
33130
|
+
}
|
|
33131
|
+
},
|
|
33132
|
+
"responses": {
|
|
33133
|
+
"200": {
|
|
33134
|
+
"description": "The session's model",
|
|
33135
|
+
"content": {
|
|
33136
|
+
"application/json": {
|
|
33137
|
+
"schema": {
|
|
33138
|
+
"$ref": "#/components/schemas/SessionModelView"
|
|
33139
|
+
}
|
|
33140
|
+
}
|
|
33141
|
+
}
|
|
33142
|
+
},
|
|
33143
|
+
"400": {
|
|
33144
|
+
"description": "Invalid headers, path, body or cursor",
|
|
33145
|
+
"content": {
|
|
33146
|
+
"application/json": {
|
|
33147
|
+
"schema": {
|
|
33148
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33149
|
+
}
|
|
33150
|
+
}
|
|
33151
|
+
}
|
|
33152
|
+
},
|
|
33153
|
+
"401": {
|
|
33154
|
+
"description": "No credential (`credential_required`), or one the Tenant does not accept (`credential_invalid`), with a `WWW-Authenticate: Bearer` challenge",
|
|
33155
|
+
"content": {
|
|
33156
|
+
"application/json": {
|
|
33157
|
+
"schema": {
|
|
33158
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33159
|
+
}
|
|
33160
|
+
}
|
|
33161
|
+
}
|
|
33162
|
+
},
|
|
33163
|
+
"403": {
|
|
33164
|
+
"description": "A trusted issuer's token (`scope_required`)"
|
|
33165
|
+
},
|
|
33166
|
+
"404": {
|
|
33167
|
+
"description": "Not found (`not_found`)",
|
|
33168
|
+
"content": {
|
|
33169
|
+
"application/json": {
|
|
33170
|
+
"schema": {
|
|
33171
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33172
|
+
}
|
|
33173
|
+
}
|
|
33174
|
+
}
|
|
33175
|
+
},
|
|
33176
|
+
"409": {
|
|
33177
|
+
"description": "A turn is running or waits (`session_busy`)"
|
|
33178
|
+
},
|
|
33179
|
+
"422": {
|
|
33180
|
+
"description": "The provider is not connected, or the model is not one of its models"
|
|
33181
|
+
},
|
|
33182
|
+
"426": {
|
|
33183
|
+
"description": "`Nylorun-Protocol` missing or unsupported",
|
|
33184
|
+
"content": {
|
|
33185
|
+
"application/json": {
|
|
33186
|
+
"schema": {
|
|
33187
|
+
"$ref": "#/components/schemas/ProtocolRejected"
|
|
33188
|
+
}
|
|
33189
|
+
}
|
|
33190
|
+
}
|
|
33191
|
+
},
|
|
33192
|
+
"503": {
|
|
33193
|
+
"description": "The Tenant's storage or streams are unavailable",
|
|
33194
|
+
"content": {
|
|
33195
|
+
"application/json": {
|
|
33196
|
+
"schema": {
|
|
33197
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33198
|
+
}
|
|
33199
|
+
}
|
|
33200
|
+
}
|
|
33201
|
+
}
|
|
33202
|
+
}
|
|
33203
|
+
},
|
|
33204
|
+
"delete": {
|
|
33205
|
+
"tags": [
|
|
33206
|
+
"Sessions API"
|
|
33207
|
+
],
|
|
33208
|
+
"summary": "Clear a session's model",
|
|
33209
|
+
"description": "Clears the session's own model (feature `session-model`): its next turns use the Tenant's model. Refused while a turn runs or waits (`409 session_busy`).",
|
|
33210
|
+
"security": [
|
|
33211
|
+
{
|
|
33212
|
+
"applicationKey": []
|
|
33213
|
+
}
|
|
33214
|
+
],
|
|
33215
|
+
"x-nylorun-credentials": [
|
|
33216
|
+
"application",
|
|
33217
|
+
"subject"
|
|
33218
|
+
],
|
|
33219
|
+
"x-nylorun-scopes": [
|
|
33220
|
+
"sessions:own"
|
|
33221
|
+
],
|
|
33222
|
+
"parameters": [
|
|
33223
|
+
{
|
|
33224
|
+
"schema": {
|
|
33225
|
+
"type": "string"
|
|
33226
|
+
},
|
|
33227
|
+
"required": true,
|
|
33228
|
+
"name": "sessionId",
|
|
33229
|
+
"in": "path"
|
|
33230
|
+
},
|
|
33231
|
+
{
|
|
33232
|
+
"schema": {
|
|
33233
|
+
"type": "string",
|
|
33234
|
+
"description": "The protocol version, `18`"
|
|
33235
|
+
},
|
|
33236
|
+
"required": true,
|
|
33237
|
+
"description": "The protocol version, `18`",
|
|
33238
|
+
"name": "Nylorun-Protocol",
|
|
33239
|
+
"in": "header"
|
|
33240
|
+
},
|
|
33241
|
+
{
|
|
33242
|
+
"schema": {
|
|
33243
|
+
"type": "string",
|
|
33244
|
+
"description": "The person an application key acts for"
|
|
33245
|
+
},
|
|
33246
|
+
"required": false,
|
|
33247
|
+
"description": "The person an application key acts for",
|
|
33248
|
+
"name": "Nylorun-Subject",
|
|
33249
|
+
"in": "header"
|
|
33250
|
+
},
|
|
33251
|
+
{
|
|
33252
|
+
"schema": {
|
|
33253
|
+
"type": "string",
|
|
33254
|
+
"description": "The subject's space-separated scopes; required with a subject"
|
|
33255
|
+
},
|
|
33256
|
+
"required": false,
|
|
33257
|
+
"description": "The subject's space-separated scopes; required with a subject",
|
|
33258
|
+
"name": "Nylorun-Scopes",
|
|
33259
|
+
"in": "header"
|
|
33260
|
+
}
|
|
33261
|
+
],
|
|
33262
|
+
"responses": {
|
|
33263
|
+
"200": {
|
|
33264
|
+
"description": "The session's model",
|
|
33265
|
+
"content": {
|
|
33266
|
+
"application/json": {
|
|
33267
|
+
"schema": {
|
|
33268
|
+
"$ref": "#/components/schemas/SessionModelView"
|
|
33269
|
+
}
|
|
33270
|
+
}
|
|
33271
|
+
}
|
|
33272
|
+
},
|
|
33273
|
+
"400": {
|
|
33274
|
+
"description": "Invalid headers, path, body or cursor",
|
|
33275
|
+
"content": {
|
|
33276
|
+
"application/json": {
|
|
33277
|
+
"schema": {
|
|
33278
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33279
|
+
}
|
|
33280
|
+
}
|
|
33281
|
+
}
|
|
33282
|
+
},
|
|
33283
|
+
"401": {
|
|
33284
|
+
"description": "No credential (`credential_required`), or one the Tenant does not accept (`credential_invalid`), with a `WWW-Authenticate: Bearer` challenge",
|
|
33285
|
+
"content": {
|
|
33286
|
+
"application/json": {
|
|
33287
|
+
"schema": {
|
|
33288
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33289
|
+
}
|
|
33290
|
+
}
|
|
33291
|
+
}
|
|
33292
|
+
},
|
|
33293
|
+
"403": {
|
|
33294
|
+
"description": "A trusted issuer's token (`scope_required`)"
|
|
33295
|
+
},
|
|
33296
|
+
"404": {
|
|
33297
|
+
"description": "Not found (`not_found`)",
|
|
33298
|
+
"content": {
|
|
33299
|
+
"application/json": {
|
|
33300
|
+
"schema": {
|
|
33301
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33302
|
+
}
|
|
33303
|
+
}
|
|
33304
|
+
}
|
|
33305
|
+
},
|
|
33306
|
+
"409": {
|
|
33307
|
+
"description": "A turn is running or waits (`session_busy`)"
|
|
33308
|
+
},
|
|
33309
|
+
"426": {
|
|
33310
|
+
"description": "`Nylorun-Protocol` missing or unsupported",
|
|
33311
|
+
"content": {
|
|
33312
|
+
"application/json": {
|
|
33313
|
+
"schema": {
|
|
33314
|
+
"$ref": "#/components/schemas/ProtocolRejected"
|
|
33315
|
+
}
|
|
33316
|
+
}
|
|
33317
|
+
}
|
|
33318
|
+
},
|
|
33319
|
+
"503": {
|
|
33320
|
+
"description": "The Tenant's storage or streams are unavailable",
|
|
33321
|
+
"content": {
|
|
33322
|
+
"application/json": {
|
|
33323
|
+
"schema": {
|
|
33324
|
+
"$ref": "#/components/schemas/Rejected"
|
|
33325
|
+
}
|
|
33326
|
+
}
|
|
33327
|
+
}
|
|
33328
|
+
}
|
|
33329
|
+
}
|
|
33330
|
+
}
|
|
33331
|
+
},
|
|
32819
33332
|
"/v1/sessions/{sessionId}/usage": {
|
|
32820
33333
|
"get": {
|
|
32821
33334
|
"tags": [
|
package/dist/tenant/context.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* under ownership (§10.6); `abortLocal` aborts an advance running on this process.
|
|
16
16
|
*/
|
|
17
17
|
import type { SessionHistory } from "./history.js";
|
|
18
|
-
import type { IssuerScope, SubjectScope, TenantEnvelope } from "@nylorun/core/contracts";
|
|
18
|
+
import type { IssuerScope, SessionModelChoice, SubjectScope, TenantEnvelope } from "@nylorun/core/contracts";
|
|
19
19
|
import type { DurableCheckpoint, FlowCheckpoint } from "@nylorun/harness/run";
|
|
20
20
|
import type { AgentManifest, JsonValue, SandboxManifest } from "@nylorun/core/define";
|
|
21
21
|
import type { OutboxRequest, SessionStore, Tx } from "../store/types.js";
|
|
@@ -141,6 +141,11 @@ export interface Session {
|
|
|
141
141
|
* Tenant-wide ones beside the session's own. Absent until a message names a file.
|
|
142
142
|
*/
|
|
143
143
|
fileArtifacts?: string[];
|
|
144
|
+
/**
|
|
145
|
+
* The session's own model (Host feature `session-model`): its turns' model calls use it in
|
|
146
|
+
* place of the Tenant's while its provider is connected. Absent: the Tenant's model.
|
|
147
|
+
*/
|
|
148
|
+
model?: SessionModelChoice;
|
|
144
149
|
}
|
|
145
150
|
export type AuthScope = {
|
|
146
151
|
kind: "application";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A session's own model (Host feature `session-model`): one of a connected provider's models,
|
|
3
|
+
* which the session's turns use in place of the Tenant's. It is kept on the session
|
|
4
|
+
* (`Session.model`): the Model Gate reads it at each call (`HostModelVault.readHostModel`) and a
|
|
5
|
+
* turn's start describes it (`turn.start.model`). The Tenant's model, and every other session's,
|
|
6
|
+
* stay as they are. While its provider is disconnected the session uses the Tenant's model again.
|
|
7
|
+
*/
|
|
8
|
+
import type { SessionModelChoice, SessionModelView } from "@nylorun/core/contracts";
|
|
9
|
+
import { type SessionAccess, type TenantContext } from "./context.js";
|
|
10
|
+
/** The model the session's next turn uses, and where it comes from. */
|
|
11
|
+
export declare function readSessionModel(ctx: TenantContext, id: string, access: SessionAccess | undefined): Promise<SessionModelView>;
|
|
12
|
+
/**
|
|
13
|
+
* Chooses the session's own model, or clears it (`choice` undefined) so its turns use the
|
|
14
|
+
* Tenant's. A turn calls one model: the choice changes only while no turn runs or waits.
|
|
15
|
+
*/
|
|
16
|
+
export declare function chooseSessionModel(ctx: TenantContext, id: string, choice: SessionModelChoice | undefined, access: SessionAccess | undefined): Promise<SessionModelView>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { catalogModel, hostModelCatalog } from "../model/catalog.js";
|
|
2
|
+
import { hostCredentialRowFor, modelBinding } from "../vault/service.js";
|
|
3
|
+
import { takesMessages } from "./commands.js";
|
|
4
|
+
import { lockedSession, sessionOf } from "./context.js";
|
|
5
|
+
import { fail } from "./http.js";
|
|
6
|
+
/** The model the session's next turn uses, and where it comes from. */
|
|
7
|
+
export async function readSessionModel(ctx, id, access) {
|
|
8
|
+
const session = await ctx.store.tx((t) => sessionOf(t, id, access));
|
|
9
|
+
return ctx.vault.getSessionModel(session.model);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Chooses the session's own model, or clears it (`choice` undefined) so its turns use the
|
|
13
|
+
* Tenant's. A turn calls one model: the choice changes only while no turn runs or waits.
|
|
14
|
+
*/
|
|
15
|
+
export async function chooseSessionModel(ctx, id, choice, access) {
|
|
16
|
+
const session = await ctx.store.tx(async (t) => {
|
|
17
|
+
const s = await lockedSession(t, id, access);
|
|
18
|
+
if (!takesMessages(s))
|
|
19
|
+
fail(409, "The session's turn is running or waits: choose its model when the turn ends", {
|
|
20
|
+
code: "session_busy",
|
|
21
|
+
});
|
|
22
|
+
if (choice)
|
|
23
|
+
await checkChoice(t, choice);
|
|
24
|
+
const { model: _model, ...rest } = s;
|
|
25
|
+
const next = choice ? { ...rest, model: { provider: choice.provider, model: choice.model } } : rest;
|
|
26
|
+
await t.put("sessions", id, next);
|
|
27
|
+
return next;
|
|
28
|
+
});
|
|
29
|
+
return ctx.vault.getSessionModel(session.model);
|
|
30
|
+
}
|
|
31
|
+
/** A choice names a connected provider and, when its catalog lists models, one of them. */
|
|
32
|
+
async function checkChoice(t, choice) {
|
|
33
|
+
if (!/^[a-zA-Z0-9._-]+$/.test(choice.provider))
|
|
34
|
+
fail(400, "Invalid provider id", { code: "invalid_request" });
|
|
35
|
+
const row = await hostCredentialRowFor(t, choice.provider);
|
|
36
|
+
if (!row)
|
|
37
|
+
fail(422, `Model provider ${choice.provider} is not connected: connect it in Model Settings first`, {
|
|
38
|
+
code: "request_rejected",
|
|
39
|
+
});
|
|
40
|
+
// A custom endpoint serves the models it names; the provider's own model is always one.
|
|
41
|
+
if (choice.provider === "custom" || modelBinding(row).model === choice.model)
|
|
42
|
+
return;
|
|
43
|
+
const listed = hostModelCatalog().providers.find((provider) => provider.id === choice.provider);
|
|
44
|
+
if (listed && listed.models.length > 0 && !catalogModel(choice.provider, choice.model))
|
|
45
|
+
fail(422, `Unknown model ${choice.model} for provider ${choice.provider}`, { code: "request_rejected" });
|
|
46
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Host's identity for model calls (ADR-71): a model credential of type `host_identity` holds
|
|
3
|
+
* no secret, only the Google Cloud project and location. The model gate calls Agent Platform with
|
|
4
|
+
* the Host's Google Application Default Credentials, which Google's client library finds at each
|
|
5
|
+
* call (`GOOGLE_APPLICATION_CREDENTIALS`, gcloud's file, or the metadata server on Google Cloud).
|
|
6
|
+
* Nothing of them is stored, logged or passed to a sandbox.
|
|
7
|
+
*
|
|
8
|
+
* Off unless the Host's operator lends it, per provider, with `NYLORUN_MODEL_HOST_IDENTITY` on the
|
|
9
|
+
* process that runs the gates. Every Tenant on the Host may then use it, so a Host that serves
|
|
10
|
+
* several organizations must not set it.
|
|
11
|
+
*/
|
|
12
|
+
/** The providers that can use the Host's identity. */
|
|
13
|
+
export declare const HOST_IDENTITY_PROVIDERS: readonly ["google-vertex"];
|
|
14
|
+
/**
|
|
15
|
+
* What pi-ai's Vertex AI client takes in place of an API key to use Application Default
|
|
16
|
+
* Credentials, with the project and location in the call's `env`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const VERTEX_ADC_MARKER = "gcp-vertex-credentials";
|
|
19
|
+
/** Sets the providers this process lends the Host's identity to (at startup). */
|
|
20
|
+
export declare function useHostIdentity(providers: readonly string[]): void;
|
|
21
|
+
/** Why a model of `provider` may not use the Host's identity here, or undefined when it may. */
|
|
22
|
+
export declare function hostIdentityRefused(provider: string): string | undefined;
|
|
23
|
+
/** The call's `env` for a `host_identity` credential: where Agent Platform runs it. */
|
|
24
|
+
export declare function hostIdentityEnv(project: string, location: string): Record<string, string>;
|