@nylorun/core 0.49.0-beta → 0.50.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 +9 -0
- package/dist/compatibility.d.ts +6 -0
- package/dist/compatibility.js +6 -0
- package/dist/contracts.d.ts +234 -0
- package/dist/contracts.js +167 -36
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @nylorun/core
|
|
2
2
|
|
|
3
|
+
## 0.50.0-beta
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9f17705: The event log is for developers, telemetry for operators (ADR-159). Each event type in the catalog names its layer: `agent`, what the agent saw and did, or `runtime`, what the Runtime did to the session. `eventLayer(type)` and `EVENT_LAYERS` are exported from `@nylorun/core/contracts` and `@nylorun/agents`, with the `TurnTrace` and `OtlpSpan` types; the envelope does not change. Studio's Events tab opens on the agent's events, with Runtime and All beside them and each row's writer, and gains a Trace view: a turn's spans as a waterfall, from the per-turn trace route, with Open trace on an event and Open event on a span. Studio's proxy allows a session's tool calls and a turn's trace. `guides/OBSERVABILITY.md` is the guide for both readers.
|
|
8
|
+
- 2b80f71: A Tenant stream with an audit read (ADR-159, Host feature `tenant-audit`). Keys put and deleted (`key.created`, `key.revoked`), signing keys rotated and revoked (`signing_key.rotated`, `signing_key.revoked`), the tool policy and every other setting changed (`policy.changed` with the rule count, `settings.changed` with the setting's key), vault credentials written, replaced, deleted and used (`credential.created`, `.rotated`, `.deleted`, `.used`, beside the `vault_audit` rows, which are still written) and Studio sign-ins (`studio.signed_in`) are recorded in `nylorun_streams.tenant_events` (migration `0050_tenant_events`), each in the transaction of the change it records, with who acted (`principal`, from the request's credential) and what wrote it (`source`), and never a secret value: every payload is strict. The stream is not relayed to S2 and a reset keeps it. `TENANT_EVENT_TYPES`, `TENANT_EVENT_PAYLOADS`, `TenantEventSchema` and `TenantAuditPageSchema` are in `@nylorun/core/contracts`.
|
|
9
|
+
|
|
10
|
+
The Management API reads it newest first with `GET /v1/tenant/audit?since&until&types&cursor&limit`, a management key only; `POST /v1/tenant/audit/studio-sign-in` takes only Studio's key. `@nylorun/admin` adds `tenant.audit({ since, until, types, cursor, limit })` and exports the Tenant event types. Studio records each sign-in (`token`, `forwarded`, and `loopback` at most hourly) in the background, so a failure never blocks one, and adds a Tenant › Audit tab: time, type, who and a one-line summary, with a type filter and Load more. Its proxy allows the read and nothing else under the audit. `guides/OBSERVABILITY.md` has an Audit part for operators.
|
|
11
|
+
|
|
3
12
|
## 0.49.0-beta
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -259,6 +259,12 @@ export declare const OPTIONAL_HOST_FEATURES: readonly ["tenant-fixture-model", "
|
|
|
259
259
|
* `turn.start`.
|
|
260
260
|
*/
|
|
261
261
|
"message-context",
|
|
262
|
+
/**
|
|
263
|
+
* The Tenant's stream (ADR-159): `GET /v1/tenant/audit` (the Management API) pages, newest first,
|
|
264
|
+
* the keys put and deleted, signing keys rotated and revoked, tool policy and settings changes,
|
|
265
|
+
* vault credentials written and used, and Studio sign-ins, each with who did it and no secret.
|
|
266
|
+
*/
|
|
267
|
+
"tenant-audit",
|
|
262
268
|
/**
|
|
263
269
|
* The triggers capability (D83): an agent whose version declares `harness.engine.triggers` sets
|
|
264
270
|
* up its own triggers with the `triggers` tool, kept by the Agent (`origin: agent` in
|
package/dist/compatibility.js
CHANGED
|
@@ -281,6 +281,12 @@ export const OPTIONAL_HOST_FEATURES = [
|
|
|
281
281
|
* `turn.start`.
|
|
282
282
|
*/
|
|
283
283
|
"message-context",
|
|
284
|
+
/**
|
|
285
|
+
* The Tenant's stream (ADR-159): `GET /v1/tenant/audit` (the Management API) pages, newest first,
|
|
286
|
+
* the keys put and deleted, signing keys rotated and revoked, tool policy and settings changes,
|
|
287
|
+
* vault credentials written and used, and Studio sign-ins, each with who did it and no secret.
|
|
288
|
+
*/
|
|
289
|
+
"tenant-audit",
|
|
284
290
|
/**
|
|
285
291
|
* The triggers capability (D83): an agent whose version declares `harness.engine.triggers` sets
|
|
286
292
|
* up its own triggers with the `triggers` tool, kept by the Agent (`origin: agent` in
|
package/dist/contracts.d.ts
CHANGED
|
@@ -1076,6 +1076,192 @@ export declare const ListAgentEventsResponseSchema: z.ZodObject<{
|
|
|
1076
1076
|
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1077
1077
|
}, z.core.$strict>>;
|
|
1078
1078
|
}, z.core.$strict>;
|
|
1079
|
+
/** The schema id of the Tenant's events (its stream in the record, ADR-159). */
|
|
1080
|
+
export declare const TENANT_EVENT_SCHEMA = "nylorun.tenant-event/1";
|
|
1081
|
+
/**
|
|
1082
|
+
* The Tenant's stream (ADR-159, Host feature `tenant-audit`): who changed who may reach the Tenant
|
|
1083
|
+
* and what its sessions may do, and each use of a vault credential, read with
|
|
1084
|
+
* `GET /v1/tenant/audit`. Every type is the Runtime's record (layer `runtime`): the Runtime saw it
|
|
1085
|
+
* happen, in the change's own transaction where it could; no harness writes one. No payload carries
|
|
1086
|
+
* a secret value: keys, signing keys, rules and credentials are named, never shown.
|
|
1087
|
+
*/
|
|
1088
|
+
export declare const TENANT_EVENT_TYPES: readonly ["key.created", "key.revoked", "signing_key.rotated", "signing_key.revoked", "policy.changed", "settings.changed", "credential.created", "credential.rotated", "credential.deleted", "credential.used", "studio.signed_in"];
|
|
1089
|
+
export type TenantEventType = (typeof TENANT_EVENT_TYPES)[number];
|
|
1090
|
+
/**
|
|
1091
|
+
* What wrote a Tenant event: `api`, a request to the Runtime or Management API; `operate`,
|
|
1092
|
+
* `nylorun-operate` on the Tenant's machine; `runtime`, the Runtime on its own (a gate using a
|
|
1093
|
+
* credential, a sweep deleting an Agent); `studio`, Studio's server, for a sign-in.
|
|
1094
|
+
*/
|
|
1095
|
+
export declare const TENANT_EVENT_SOURCES: readonly ["api", "operate", "runtime", "studio"];
|
|
1096
|
+
export type TenantEventSource = (typeof TENANT_EVENT_SOURCES)[number];
|
|
1097
|
+
/** How a person signed in to Studio: on its loopback address, with a login token, or through a sign-in proxy. */
|
|
1098
|
+
export declare const STUDIO_SIGN_IN_METHODS: readonly ["loopback", "token", "forwarded"];
|
|
1099
|
+
export type StudioSignInMethod = (typeof STUDIO_SIGN_IN_METHODS)[number];
|
|
1100
|
+
/**
|
|
1101
|
+
* The payload of each Tenant event. Each is strict, so a write that carries anything else, a
|
|
1102
|
+
* secret above all, is refused.
|
|
1103
|
+
*/
|
|
1104
|
+
export declare const TENANT_EVENT_PAYLOADS: {
|
|
1105
|
+
/** Key `keyId` was issued; `rotated` when it replaced a key of that name. */
|
|
1106
|
+
readonly "key.created": z.ZodObject<{
|
|
1107
|
+
keyId: z.ZodString;
|
|
1108
|
+
role: z.ZodEnum<{
|
|
1109
|
+
application: "application";
|
|
1110
|
+
management: "management";
|
|
1111
|
+
}>;
|
|
1112
|
+
rotated: z.ZodBoolean;
|
|
1113
|
+
}, z.core.$strict>;
|
|
1114
|
+
readonly "key.revoked": z.ZodObject<{
|
|
1115
|
+
keyId: z.ZodString;
|
|
1116
|
+
role: z.ZodEnum<{
|
|
1117
|
+
application: "application";
|
|
1118
|
+
management: "management";
|
|
1119
|
+
}>;
|
|
1120
|
+
}, z.core.$strict>;
|
|
1121
|
+
/** The standby key became `current`; the old current one `previous`, the old previous one `revoked`. */
|
|
1122
|
+
readonly "signing_key.rotated": z.ZodObject<{
|
|
1123
|
+
current: z.ZodString;
|
|
1124
|
+
standby: z.ZodString;
|
|
1125
|
+
previous: z.ZodOptional<z.ZodString>;
|
|
1126
|
+
revoked: z.ZodOptional<z.ZodString>;
|
|
1127
|
+
force: z.ZodBoolean;
|
|
1128
|
+
}, z.core.$strict>;
|
|
1129
|
+
/** Key `keyId` was revoked from `state`. */
|
|
1130
|
+
readonly "signing_key.revoked": z.ZodObject<{
|
|
1131
|
+
keyId: z.ZodString;
|
|
1132
|
+
state: z.ZodEnum<{
|
|
1133
|
+
previous: "previous";
|
|
1134
|
+
standby: "standby";
|
|
1135
|
+
}>;
|
|
1136
|
+
}, z.core.$strict>;
|
|
1137
|
+
/** The tool policy now holds `rules` rules, as of `updatedAt`; the rules are read from `GET /v1/tenant/tool-policy`. */
|
|
1138
|
+
readonly "policy.changed": z.ZodObject<{
|
|
1139
|
+
rules: z.ZodNumber;
|
|
1140
|
+
updatedAt: z.ZodString;
|
|
1141
|
+
}, z.core.$strict>;
|
|
1142
|
+
/**
|
|
1143
|
+
* Setting `key` was replaced: `limits.config`, `environments.config`, `artifacts.config`,
|
|
1144
|
+
* `skills.config`, `model.budgets`, `model.inputs` or `model` (the provider and model in force,
|
|
1145
|
+
* `provider` and `model`; `model.inputs` names the catalog model in `model`). Never its value.
|
|
1146
|
+
*/
|
|
1147
|
+
readonly "settings.changed": z.ZodObject<{
|
|
1148
|
+
key: z.ZodString;
|
|
1149
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
1150
|
+
model: z.ZodOptional<z.ZodString>;
|
|
1151
|
+
}, z.core.$strict>;
|
|
1152
|
+
readonly "credential.created": z.ZodObject<{
|
|
1153
|
+
vaultId: z.ZodOptional<z.ZodString>;
|
|
1154
|
+
credentialId: z.ZodOptional<z.ZodString>;
|
|
1155
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
1156
|
+
target: z.ZodOptional<z.ZodString>;
|
|
1157
|
+
outcome: z.ZodString;
|
|
1158
|
+
}, z.core.$strict>;
|
|
1159
|
+
readonly "credential.rotated": z.ZodObject<{
|
|
1160
|
+
vaultId: z.ZodOptional<z.ZodString>;
|
|
1161
|
+
credentialId: z.ZodOptional<z.ZodString>;
|
|
1162
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
1163
|
+
target: z.ZodOptional<z.ZodString>;
|
|
1164
|
+
outcome: z.ZodString;
|
|
1165
|
+
}, z.core.$strict>;
|
|
1166
|
+
readonly "credential.deleted": z.ZodObject<{
|
|
1167
|
+
vaultId: z.ZodOptional<z.ZodString>;
|
|
1168
|
+
credentialId: z.ZodOptional<z.ZodString>;
|
|
1169
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
1170
|
+
target: z.ZodOptional<z.ZodString>;
|
|
1171
|
+
outcome: z.ZodString;
|
|
1172
|
+
}, z.core.$strict>;
|
|
1173
|
+
readonly "credential.used": z.ZodObject<{
|
|
1174
|
+
vaultId: z.ZodOptional<z.ZodString>;
|
|
1175
|
+
credentialId: z.ZodOptional<z.ZodString>;
|
|
1176
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
1177
|
+
target: z.ZodOptional<z.ZodString>;
|
|
1178
|
+
outcome: z.ZodString;
|
|
1179
|
+
}, z.core.$strict>;
|
|
1180
|
+
/** A browser signed in to Studio, by `method`, as `subject` when it names a person. */
|
|
1181
|
+
readonly "studio.signed_in": z.ZodObject<{
|
|
1182
|
+
method: z.ZodEnum<{
|
|
1183
|
+
forwarded: "forwarded";
|
|
1184
|
+
loopback: "loopback";
|
|
1185
|
+
token: "token";
|
|
1186
|
+
}>;
|
|
1187
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
1188
|
+
}, z.core.$strict>;
|
|
1189
|
+
};
|
|
1190
|
+
export type TenantEventPayload<T extends TenantEventType> = z.infer<(typeof TENANT_EVENT_PAYLOADS)[T]>;
|
|
1191
|
+
/**
|
|
1192
|
+
* One event on the Tenant's stream, numbered from 0. `principal` is who acted, from the request's
|
|
1193
|
+
* credential: a key's name (`bootstrap`, `studio`, an application key's), `<key>:<subject>` for a
|
|
1194
|
+
* key acting for a person, `<issuer>:<subject>` for a token, `operate` for `nylorun-operate`,
|
|
1195
|
+
* and `host` for the Runtime itself.
|
|
1196
|
+
*/
|
|
1197
|
+
export declare const TenantEventSchema: z.ZodObject<{
|
|
1198
|
+
schema: z.ZodLiteral<"nylorun.tenant-event/1">;
|
|
1199
|
+
seq: z.ZodNumber;
|
|
1200
|
+
time: z.ZodString;
|
|
1201
|
+
type: z.ZodEnum<{
|
|
1202
|
+
"credential.created": "credential.created";
|
|
1203
|
+
"credential.deleted": "credential.deleted";
|
|
1204
|
+
"credential.rotated": "credential.rotated";
|
|
1205
|
+
"credential.used": "credential.used";
|
|
1206
|
+
"key.created": "key.created";
|
|
1207
|
+
"key.revoked": "key.revoked";
|
|
1208
|
+
"policy.changed": "policy.changed";
|
|
1209
|
+
"settings.changed": "settings.changed";
|
|
1210
|
+
"signing_key.revoked": "signing_key.revoked";
|
|
1211
|
+
"signing_key.rotated": "signing_key.rotated";
|
|
1212
|
+
"studio.signed_in": "studio.signed_in";
|
|
1213
|
+
}>;
|
|
1214
|
+
source: z.ZodEnum<{
|
|
1215
|
+
api: "api";
|
|
1216
|
+
operate: "operate";
|
|
1217
|
+
runtime: "runtime";
|
|
1218
|
+
studio: "studio";
|
|
1219
|
+
}>;
|
|
1220
|
+
principal: z.ZodString;
|
|
1221
|
+
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1222
|
+
}, z.core.$strict>;
|
|
1223
|
+
export type TenantEvent = z.infer<typeof TenantEventSchema>;
|
|
1224
|
+
/** A page of the Tenant's events, newest first; `nextCursor` reads older ones. */
|
|
1225
|
+
export declare const TenantAuditPageSchema: z.ZodObject<{
|
|
1226
|
+
events: z.ZodArray<z.ZodObject<{
|
|
1227
|
+
schema: z.ZodLiteral<"nylorun.tenant-event/1">;
|
|
1228
|
+
seq: z.ZodNumber;
|
|
1229
|
+
time: z.ZodString;
|
|
1230
|
+
type: z.ZodEnum<{
|
|
1231
|
+
"credential.created": "credential.created";
|
|
1232
|
+
"credential.deleted": "credential.deleted";
|
|
1233
|
+
"credential.rotated": "credential.rotated";
|
|
1234
|
+
"credential.used": "credential.used";
|
|
1235
|
+
"key.created": "key.created";
|
|
1236
|
+
"key.revoked": "key.revoked";
|
|
1237
|
+
"policy.changed": "policy.changed";
|
|
1238
|
+
"settings.changed": "settings.changed";
|
|
1239
|
+
"signing_key.revoked": "signing_key.revoked";
|
|
1240
|
+
"signing_key.rotated": "signing_key.rotated";
|
|
1241
|
+
"studio.signed_in": "studio.signed_in";
|
|
1242
|
+
}>;
|
|
1243
|
+
source: z.ZodEnum<{
|
|
1244
|
+
api: "api";
|
|
1245
|
+
operate: "operate";
|
|
1246
|
+
runtime: "runtime";
|
|
1247
|
+
studio: "studio";
|
|
1248
|
+
}>;
|
|
1249
|
+
principal: z.ZodString;
|
|
1250
|
+
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1251
|
+
}, z.core.$strict>>;
|
|
1252
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
1253
|
+
}, z.core.$strict>;
|
|
1254
|
+
export type TenantAuditPage = z.infer<typeof TenantAuditPageSchema>;
|
|
1255
|
+
/** `POST /v1/tenant/audit/studio-sign-in`: how a person signed in to Studio, and who when known. */
|
|
1256
|
+
export declare const StudioSignInRequestSchema: z.ZodObject<{
|
|
1257
|
+
method: z.ZodEnum<{
|
|
1258
|
+
forwarded: "forwarded";
|
|
1259
|
+
loopback: "loopback";
|
|
1260
|
+
token: "token";
|
|
1261
|
+
}>;
|
|
1262
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
1263
|
+
}, z.core.$strict>;
|
|
1264
|
+
export type StudioSignInRequest = z.infer<typeof StudioSignInRequestSchema>;
|
|
1079
1265
|
/**
|
|
1080
1266
|
* A model role's name (Host feature `model-roles`, ADR-154): a lowercase letter, then up to 31
|
|
1081
1267
|
* lowercase letters, digits and `-`, such as `builder`.
|
|
@@ -4594,6 +4780,12 @@ export declare const EventSourceKindSchema: z.ZodEnum<{
|
|
|
4594
4780
|
"tool-gate": "tool-gate";
|
|
4595
4781
|
}>;
|
|
4596
4782
|
export type EventSourceKind = z.infer<typeof EventSourceKindSchema>;
|
|
4783
|
+
/**
|
|
4784
|
+
* Whose account an event is: the agent's or the Runtime's (ADR-159). A session's events have one each
|
|
4785
|
+
* (`EVENT_CATALOG`); every event on an Agent's stream (`AGENT_EVENT_TYPES`) is the Runtime's.
|
|
4786
|
+
*/
|
|
4787
|
+
export declare const EVENT_LAYERS: readonly ["agent", "runtime"];
|
|
4788
|
+
export type EventLayer = (typeof EVENT_LAYERS)[number];
|
|
4597
4789
|
/**
|
|
4598
4790
|
* How far an event can be trusted, by who could forge it. `observed`: the Runtime saw it itself
|
|
4599
4791
|
* (commands, the tools core serves, gate records, core's settle). `claimed`: a harness reported
|
|
@@ -6026,6 +6218,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6026
6218
|
}, z.core.$loose>;
|
|
6027
6219
|
readonly source: "api";
|
|
6028
6220
|
readonly version: 1;
|
|
6221
|
+
readonly layer: "agent";
|
|
6029
6222
|
};
|
|
6030
6223
|
readonly "command.approve": {
|
|
6031
6224
|
readonly payload: z.ZodObject<{
|
|
@@ -6037,6 +6230,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6037
6230
|
}, z.core.$loose>;
|
|
6038
6231
|
readonly source: "api";
|
|
6039
6232
|
readonly version: 1;
|
|
6233
|
+
readonly layer: "agent";
|
|
6040
6234
|
};
|
|
6041
6235
|
readonly "command.respond": {
|
|
6042
6236
|
readonly payload: z.ZodObject<{
|
|
@@ -6048,6 +6242,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6048
6242
|
}, z.core.$loose>;
|
|
6049
6243
|
readonly source: "api";
|
|
6050
6244
|
readonly version: 1;
|
|
6245
|
+
readonly layer: "agent";
|
|
6051
6246
|
};
|
|
6052
6247
|
readonly "turn.completed": {
|
|
6053
6248
|
readonly payload: z.ZodObject<{
|
|
@@ -6067,6 +6262,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6067
6262
|
}, z.core.$loose>;
|
|
6068
6263
|
readonly source: "loop";
|
|
6069
6264
|
readonly version: 1;
|
|
6265
|
+
readonly layer: "agent";
|
|
6070
6266
|
};
|
|
6071
6267
|
readonly "turn.paused": {
|
|
6072
6268
|
readonly payload: z.ZodObject<{
|
|
@@ -6082,6 +6278,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6082
6278
|
}, z.core.$loose>;
|
|
6083
6279
|
readonly source: "loop";
|
|
6084
6280
|
readonly version: 1;
|
|
6281
|
+
readonly layer: "agent";
|
|
6085
6282
|
};
|
|
6086
6283
|
readonly "turn.failed": {
|
|
6087
6284
|
readonly payload: z.ZodObject<{
|
|
@@ -6105,6 +6302,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6105
6302
|
}, z.core.$loose>;
|
|
6106
6303
|
readonly source: "loop";
|
|
6107
6304
|
readonly version: 1;
|
|
6305
|
+
readonly layer: "agent";
|
|
6108
6306
|
};
|
|
6109
6307
|
readonly "turn.cancelled": {
|
|
6110
6308
|
readonly payload: z.ZodObject<{
|
|
@@ -6124,6 +6322,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6124
6322
|
}, z.core.$loose>;
|
|
6125
6323
|
readonly source: "api";
|
|
6126
6324
|
readonly version: 1;
|
|
6325
|
+
readonly layer: "agent";
|
|
6127
6326
|
};
|
|
6128
6327
|
readonly "turn.version_kept": {
|
|
6129
6328
|
readonly payload: z.ZodObject<{
|
|
@@ -6142,6 +6341,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6142
6341
|
}, z.core.$loose>;
|
|
6143
6342
|
readonly source: "api";
|
|
6144
6343
|
readonly version: 1;
|
|
6344
|
+
readonly layer: "runtime";
|
|
6145
6345
|
};
|
|
6146
6346
|
readonly "session.model": {
|
|
6147
6347
|
readonly payload: z.ZodObject<{
|
|
@@ -6196,6 +6396,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6196
6396
|
}, z.core.$loose>;
|
|
6197
6397
|
readonly source: "api";
|
|
6198
6398
|
readonly version: 1;
|
|
6399
|
+
readonly layer: "runtime";
|
|
6199
6400
|
};
|
|
6200
6401
|
readonly "message.queued": {
|
|
6201
6402
|
readonly payload: z.ZodObject<{
|
|
@@ -6209,6 +6410,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6209
6410
|
}, z.core.$loose>;
|
|
6210
6411
|
readonly source: "api";
|
|
6211
6412
|
readonly version: 1;
|
|
6413
|
+
readonly layer: "runtime";
|
|
6212
6414
|
};
|
|
6213
6415
|
readonly "queue.taken": {
|
|
6214
6416
|
readonly payload: z.ZodObject<{
|
|
@@ -6218,6 +6420,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6218
6420
|
}, z.core.$loose>;
|
|
6219
6421
|
readonly source: "api";
|
|
6220
6422
|
readonly version: 1;
|
|
6423
|
+
readonly layer: "runtime";
|
|
6221
6424
|
};
|
|
6222
6425
|
readonly "queue.failed": {
|
|
6223
6426
|
readonly payload: z.ZodObject<{
|
|
@@ -6230,6 +6433,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6230
6433
|
}, z.core.$loose>;
|
|
6231
6434
|
readonly source: "api";
|
|
6232
6435
|
readonly version: 1;
|
|
6436
|
+
readonly layer: "runtime";
|
|
6233
6437
|
};
|
|
6234
6438
|
readonly "queue.cancelled": {
|
|
6235
6439
|
readonly payload: z.ZodObject<{
|
|
@@ -6238,6 +6442,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6238
6442
|
}, z.core.$loose>;
|
|
6239
6443
|
readonly source: "api";
|
|
6240
6444
|
readonly version: 1;
|
|
6445
|
+
readonly layer: "runtime";
|
|
6241
6446
|
};
|
|
6242
6447
|
readonly "wake.booked": {
|
|
6243
6448
|
readonly payload: z.ZodObject<{
|
|
@@ -6248,6 +6453,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6248
6453
|
}, z.core.$loose>;
|
|
6249
6454
|
readonly source: "api";
|
|
6250
6455
|
readonly version: 1;
|
|
6456
|
+
readonly layer: "runtime";
|
|
6251
6457
|
};
|
|
6252
6458
|
readonly "wake.cancelled": {
|
|
6253
6459
|
readonly payload: z.ZodObject<{
|
|
@@ -6255,6 +6461,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6255
6461
|
}, z.core.$loose>;
|
|
6256
6462
|
readonly source: "api";
|
|
6257
6463
|
readonly version: 1;
|
|
6464
|
+
readonly layer: "runtime";
|
|
6258
6465
|
};
|
|
6259
6466
|
readonly "memory.updated": {
|
|
6260
6467
|
readonly payload: z.ZodObject<{
|
|
@@ -6273,6 +6480,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6273
6480
|
}, z.core.$loose>;
|
|
6274
6481
|
readonly source: "api";
|
|
6275
6482
|
readonly version: 1;
|
|
6483
|
+
readonly layer: "agent";
|
|
6276
6484
|
};
|
|
6277
6485
|
readonly "message.assistant": {
|
|
6278
6486
|
readonly payload: z.ZodObject<{
|
|
@@ -6317,6 +6525,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6317
6525
|
}, z.core.$loose>;
|
|
6318
6526
|
readonly source: "loop";
|
|
6319
6527
|
readonly version: 1;
|
|
6528
|
+
readonly layer: "agent";
|
|
6320
6529
|
};
|
|
6321
6530
|
readonly "model.failed": {
|
|
6322
6531
|
readonly payload: z.ZodObject<{
|
|
@@ -6352,6 +6561,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6352
6561
|
}, z.core.$loose>;
|
|
6353
6562
|
readonly source: "loop";
|
|
6354
6563
|
readonly version: 1;
|
|
6564
|
+
readonly layer: "agent";
|
|
6355
6565
|
};
|
|
6356
6566
|
readonly "context.compacted": {
|
|
6357
6567
|
readonly payload: z.ZodObject<{
|
|
@@ -6390,6 +6600,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6390
6600
|
}, z.core.$loose>;
|
|
6391
6601
|
readonly source: "loop";
|
|
6392
6602
|
readonly version: 1;
|
|
6603
|
+
readonly layer: "agent";
|
|
6393
6604
|
};
|
|
6394
6605
|
readonly "tool.completed": {
|
|
6395
6606
|
readonly payload: z.ZodObject<{
|
|
@@ -6447,6 +6658,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6447
6658
|
}, z.core.$loose>;
|
|
6448
6659
|
readonly source: "loop";
|
|
6449
6660
|
readonly version: 1;
|
|
6661
|
+
readonly layer: "agent";
|
|
6450
6662
|
};
|
|
6451
6663
|
readonly "effect.uncertain": {
|
|
6452
6664
|
readonly payload: z.ZodObject<{
|
|
@@ -6455,6 +6667,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6455
6667
|
}, z.core.$loose>;
|
|
6456
6668
|
readonly source: "loop";
|
|
6457
6669
|
readonly version: 1;
|
|
6670
|
+
readonly layer: "agent";
|
|
6458
6671
|
};
|
|
6459
6672
|
readonly "delegation.started": {
|
|
6460
6673
|
readonly payload: z.ZodObject<{
|
|
@@ -6467,6 +6680,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6467
6680
|
}, z.core.$loose>;
|
|
6468
6681
|
readonly source: "loop";
|
|
6469
6682
|
readonly version: 1;
|
|
6683
|
+
readonly layer: "agent";
|
|
6470
6684
|
};
|
|
6471
6685
|
readonly "delegation.completed": {
|
|
6472
6686
|
readonly payload: z.ZodObject<{
|
|
@@ -6479,6 +6693,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6479
6693
|
}, z.core.$loose>;
|
|
6480
6694
|
readonly source: "loop";
|
|
6481
6695
|
readonly version: 1;
|
|
6696
|
+
readonly layer: "agent";
|
|
6482
6697
|
};
|
|
6483
6698
|
readonly "mcp.discovered": {
|
|
6484
6699
|
readonly payload: z.ZodObject<{
|
|
@@ -6504,6 +6719,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6504
6719
|
}, z.core.$loose>;
|
|
6505
6720
|
readonly source: "loop";
|
|
6506
6721
|
readonly version: 1;
|
|
6722
|
+
readonly layer: "runtime";
|
|
6507
6723
|
};
|
|
6508
6724
|
readonly "plan.updated": {
|
|
6509
6725
|
readonly payload: z.ZodObject<{
|
|
@@ -6521,6 +6737,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6521
6737
|
}, z.core.$loose>;
|
|
6522
6738
|
readonly source: "loop";
|
|
6523
6739
|
readonly version: 1;
|
|
6740
|
+
readonly layer: "agent";
|
|
6524
6741
|
};
|
|
6525
6742
|
readonly "engine.diagnostic": {
|
|
6526
6743
|
readonly payload: z.ZodObject<{
|
|
@@ -6530,6 +6747,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6530
6747
|
}, z.core.$loose>;
|
|
6531
6748
|
readonly source: "loop";
|
|
6532
6749
|
readonly version: 1;
|
|
6750
|
+
readonly layer: "runtime";
|
|
6533
6751
|
};
|
|
6534
6752
|
readonly "environment.state": {
|
|
6535
6753
|
readonly payload: z.ZodObject<{
|
|
@@ -6549,6 +6767,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6549
6767
|
}, z.core.$loose>;
|
|
6550
6768
|
readonly source: "loop";
|
|
6551
6769
|
readonly version: 1;
|
|
6770
|
+
readonly layer: "runtime";
|
|
6552
6771
|
};
|
|
6553
6772
|
readonly "environment.exec": {
|
|
6554
6773
|
readonly payload: z.ZodObject<{
|
|
@@ -6560,6 +6779,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6560
6779
|
}, z.core.$loose>;
|
|
6561
6780
|
readonly source: "loop";
|
|
6562
6781
|
readonly version: 1;
|
|
6782
|
+
readonly layer: "runtime";
|
|
6563
6783
|
};
|
|
6564
6784
|
readonly "agent.attached": {
|
|
6565
6785
|
readonly payload: z.ZodObject<{
|
|
@@ -6567,6 +6787,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6567
6787
|
}, z.core.$loose>;
|
|
6568
6788
|
readonly source: "api";
|
|
6569
6789
|
readonly version: 1;
|
|
6790
|
+
readonly layer: "runtime";
|
|
6570
6791
|
};
|
|
6571
6792
|
readonly "node.started": {
|
|
6572
6793
|
readonly payload: z.ZodObject<{
|
|
@@ -6577,6 +6798,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6577
6798
|
}, z.core.$loose>;
|
|
6578
6799
|
readonly source: "loop";
|
|
6579
6800
|
readonly version: 1;
|
|
6801
|
+
readonly layer: "agent";
|
|
6580
6802
|
};
|
|
6581
6803
|
readonly "node.completed": {
|
|
6582
6804
|
readonly payload: z.ZodObject<{
|
|
@@ -6598,6 +6820,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6598
6820
|
}, z.core.$loose>;
|
|
6599
6821
|
readonly source: "loop";
|
|
6600
6822
|
readonly version: 1;
|
|
6823
|
+
readonly layer: "agent";
|
|
6601
6824
|
};
|
|
6602
6825
|
readonly "node.agent": {
|
|
6603
6826
|
readonly payload: z.ZodObject<{
|
|
@@ -6608,6 +6831,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6608
6831
|
}, z.core.$loose>;
|
|
6609
6832
|
readonly source: "loop";
|
|
6610
6833
|
readonly version: 1;
|
|
6834
|
+
readonly layer: "agent";
|
|
6611
6835
|
};
|
|
6612
6836
|
readonly "loop.iteration": {
|
|
6613
6837
|
readonly payload: z.ZodObject<{
|
|
@@ -6619,6 +6843,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6619
6843
|
}, z.core.$loose>;
|
|
6620
6844
|
readonly source: "loop";
|
|
6621
6845
|
readonly version: 1;
|
|
6846
|
+
readonly layer: "agent";
|
|
6622
6847
|
};
|
|
6623
6848
|
readonly "loop.verified": {
|
|
6624
6849
|
readonly payload: z.ZodObject<{
|
|
@@ -6630,6 +6855,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6630
6855
|
}, z.core.$loose>;
|
|
6631
6856
|
readonly source: "api";
|
|
6632
6857
|
readonly version: 1;
|
|
6858
|
+
readonly layer: "agent";
|
|
6633
6859
|
};
|
|
6634
6860
|
readonly "artifact.created": {
|
|
6635
6861
|
readonly payload: z.ZodObject<{
|
|
@@ -6656,6 +6882,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6656
6882
|
}, z.core.$loose>;
|
|
6657
6883
|
readonly source: "api";
|
|
6658
6884
|
readonly version: 1;
|
|
6885
|
+
readonly layer: "runtime";
|
|
6659
6886
|
};
|
|
6660
6887
|
readonly "artifact.version.created": {
|
|
6661
6888
|
readonly payload: z.ZodObject<{
|
|
@@ -6682,6 +6909,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6682
6909
|
}, z.core.$loose>;
|
|
6683
6910
|
readonly source: "api";
|
|
6684
6911
|
readonly version: 1;
|
|
6912
|
+
readonly layer: "runtime";
|
|
6685
6913
|
};
|
|
6686
6914
|
readonly "artifact.deleted": {
|
|
6687
6915
|
readonly payload: z.ZodObject<{
|
|
@@ -6690,6 +6918,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6690
6918
|
}, z.core.$loose>;
|
|
6691
6919
|
readonly source: "api";
|
|
6692
6920
|
readonly version: 1;
|
|
6921
|
+
readonly layer: "runtime";
|
|
6693
6922
|
};
|
|
6694
6923
|
readonly "artifact.export.skipped": {
|
|
6695
6924
|
readonly payload: z.ZodObject<{
|
|
@@ -6707,6 +6936,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6707
6936
|
}, z.core.$loose>;
|
|
6708
6937
|
readonly source: "api";
|
|
6709
6938
|
readonly version: 1;
|
|
6939
|
+
readonly layer: "runtime";
|
|
6710
6940
|
};
|
|
6711
6941
|
readonly "artifact.export.failed": {
|
|
6712
6942
|
readonly payload: z.ZodObject<{
|
|
@@ -6715,6 +6945,7 @@ export declare const EVENT_CATALOG: {
|
|
|
6715
6945
|
}, z.core.$loose>;
|
|
6716
6946
|
readonly source: "api";
|
|
6717
6947
|
readonly version: 1;
|
|
6948
|
+
readonly layer: "runtime";
|
|
6718
6949
|
};
|
|
6719
6950
|
readonly "transcript.updated": {
|
|
6720
6951
|
readonly payload: z.ZodObject<{
|
|
@@ -6724,11 +6955,14 @@ export declare const EVENT_CATALOG: {
|
|
|
6724
6955
|
}, z.core.$loose>;
|
|
6725
6956
|
readonly source: "loop";
|
|
6726
6957
|
readonly version: 1;
|
|
6958
|
+
readonly layer: "agent";
|
|
6727
6959
|
readonly visibility: "internal";
|
|
6728
6960
|
};
|
|
6729
6961
|
};
|
|
6730
6962
|
export type EventType = keyof typeof EVENT_CATALOG;
|
|
6731
6963
|
export declare const EVENT_TYPES: readonly EventType[];
|
|
6964
|
+
/** An event type's layer (ADR-159); `undefined` for a type this version does not know. */
|
|
6965
|
+
export declare function eventLayer(type: string): EventLayer | undefined;
|
|
6732
6966
|
/** Drops the index signatures `passthrough` adds, so plain interfaces are assignable. */
|
|
6733
6967
|
type Closed<T> = T extends readonly (infer U)[] ? Closed<U>[] : T extends object ? {
|
|
6734
6968
|
[K in keyof T as string extends K ? never : K]: Closed<T[K]>;
|
package/dist/contracts.js
CHANGED
|
@@ -1343,6 +1343,124 @@ export const AgentEventSchema = z
|
|
|
1343
1343
|
export const ListAgentEventsResponseSchema = z
|
|
1344
1344
|
.object({ events: z.array(AgentEventSchema) })
|
|
1345
1345
|
.strict();
|
|
1346
|
+
/** The schema id of the Tenant's events (its stream in the record, ADR-159). */
|
|
1347
|
+
export const TENANT_EVENT_SCHEMA = "nylorun.tenant-event/1";
|
|
1348
|
+
/**
|
|
1349
|
+
* The Tenant's stream (ADR-159, Host feature `tenant-audit`): who changed who may reach the Tenant
|
|
1350
|
+
* and what its sessions may do, and each use of a vault credential, read with
|
|
1351
|
+
* `GET /v1/tenant/audit`. Every type is the Runtime's record (layer `runtime`): the Runtime saw it
|
|
1352
|
+
* happen, in the change's own transaction where it could; no harness writes one. No payload carries
|
|
1353
|
+
* a secret value: keys, signing keys, rules and credentials are named, never shown.
|
|
1354
|
+
*/
|
|
1355
|
+
export const TENANT_EVENT_TYPES = [
|
|
1356
|
+
// An application or management key was put (created, or rotated: `rotated`) or deleted.
|
|
1357
|
+
"key.created",
|
|
1358
|
+
"key.revoked",
|
|
1359
|
+
// The signing keys rotated, or one was revoked.
|
|
1360
|
+
"signing_key.rotated",
|
|
1361
|
+
"signing_key.revoked",
|
|
1362
|
+
// The tool policy was replaced.
|
|
1363
|
+
"policy.changed",
|
|
1364
|
+
// Another Tenant setting was replaced: limits, compute, artifacts, skills, budgets, the model.
|
|
1365
|
+
"settings.changed",
|
|
1366
|
+
// A vault credential was written, replaced, deleted or used (each `vault_audit` row of one).
|
|
1367
|
+
"credential.created",
|
|
1368
|
+
"credential.rotated",
|
|
1369
|
+
"credential.deleted",
|
|
1370
|
+
"credential.used",
|
|
1371
|
+
// A person signed in to Studio (Studio records it with its own key).
|
|
1372
|
+
"studio.signed_in",
|
|
1373
|
+
];
|
|
1374
|
+
/**
|
|
1375
|
+
* What wrote a Tenant event: `api`, a request to the Runtime or Management API; `operate`,
|
|
1376
|
+
* `nylorun-operate` on the Tenant's machine; `runtime`, the Runtime on its own (a gate using a
|
|
1377
|
+
* credential, a sweep deleting an Agent); `studio`, Studio's server, for a sign-in.
|
|
1378
|
+
*/
|
|
1379
|
+
export const TENANT_EVENT_SOURCES = ["api", "operate", "runtime", "studio"];
|
|
1380
|
+
/** How a person signed in to Studio: on its loopback address, with a login token, or through a sign-in proxy. */
|
|
1381
|
+
export const STUDIO_SIGN_IN_METHODS = ["loopback", "token", "forwarded"];
|
|
1382
|
+
/**
|
|
1383
|
+
* A credential event's payload: the `vault_audit` row's fields, never the credential's value.
|
|
1384
|
+
* `outcome` is the row's (`created`, `copied`, `rotated`, `deleted`, `approved`, `refused`); a use
|
|
1385
|
+
* names the session it was for and the URL it was sent to (`target`).
|
|
1386
|
+
*/
|
|
1387
|
+
const CredentialEventPayloadSchema = z
|
|
1388
|
+
.object({
|
|
1389
|
+
vaultId: z.string().optional(),
|
|
1390
|
+
credentialId: z.string().optional(),
|
|
1391
|
+
sessionId: z.string().optional(),
|
|
1392
|
+
target: z.string().optional(),
|
|
1393
|
+
outcome: z.string(),
|
|
1394
|
+
})
|
|
1395
|
+
.strict();
|
|
1396
|
+
const KeyRoleNameSchema = z.enum(["application", "management"]);
|
|
1397
|
+
/**
|
|
1398
|
+
* The payload of each Tenant event. Each is strict, so a write that carries anything else, a
|
|
1399
|
+
* secret above all, is refused.
|
|
1400
|
+
*/
|
|
1401
|
+
export const TENANT_EVENT_PAYLOADS = {
|
|
1402
|
+
/** Key `keyId` was issued; `rotated` when it replaced a key of that name. */
|
|
1403
|
+
"key.created": z.object({ keyId: z.string(), role: KeyRoleNameSchema, rotated: z.boolean() }).strict(),
|
|
1404
|
+
"key.revoked": z.object({ keyId: z.string(), role: KeyRoleNameSchema }).strict(),
|
|
1405
|
+
/** The standby key became `current`; the old current one `previous`, the old previous one `revoked`. */
|
|
1406
|
+
"signing_key.rotated": z
|
|
1407
|
+
.object({
|
|
1408
|
+
current: z.string(),
|
|
1409
|
+
standby: z.string(),
|
|
1410
|
+
previous: z.string().optional(),
|
|
1411
|
+
revoked: z.string().optional(),
|
|
1412
|
+
force: z.boolean(),
|
|
1413
|
+
})
|
|
1414
|
+
.strict(),
|
|
1415
|
+
/** Key `keyId` was revoked from `state`. */
|
|
1416
|
+
"signing_key.revoked": z.object({ keyId: z.string(), state: z.enum(["previous", "standby"]) }).strict(),
|
|
1417
|
+
/** The tool policy now holds `rules` rules, as of `updatedAt`; the rules are read from `GET /v1/tenant/tool-policy`. */
|
|
1418
|
+
"policy.changed": z.object({ rules: z.number().int().nonnegative(), updatedAt: z.string() }).strict(),
|
|
1419
|
+
/**
|
|
1420
|
+
* Setting `key` was replaced: `limits.config`, `environments.config`, `artifacts.config`,
|
|
1421
|
+
* `skills.config`, `model.budgets`, `model.inputs` or `model` (the provider and model in force,
|
|
1422
|
+
* `provider` and `model`; `model.inputs` names the catalog model in `model`). Never its value.
|
|
1423
|
+
*/
|
|
1424
|
+
"settings.changed": z
|
|
1425
|
+
.object({ key: z.string(), provider: z.string().optional(), model: z.string().optional() })
|
|
1426
|
+
.strict(),
|
|
1427
|
+
"credential.created": CredentialEventPayloadSchema,
|
|
1428
|
+
"credential.rotated": CredentialEventPayloadSchema,
|
|
1429
|
+
"credential.deleted": CredentialEventPayloadSchema,
|
|
1430
|
+
"credential.used": CredentialEventPayloadSchema,
|
|
1431
|
+
/** A browser signed in to Studio, by `method`, as `subject` when it names a person. */
|
|
1432
|
+
"studio.signed_in": z
|
|
1433
|
+
.object({ method: z.enum(STUDIO_SIGN_IN_METHODS), subject: z.string().optional() })
|
|
1434
|
+
.strict(),
|
|
1435
|
+
};
|
|
1436
|
+
/**
|
|
1437
|
+
* One event on the Tenant's stream, numbered from 0. `principal` is who acted, from the request's
|
|
1438
|
+
* credential: a key's name (`bootstrap`, `studio`, an application key's), `<key>:<subject>` for a
|
|
1439
|
+
* key acting for a person, `<issuer>:<subject>` for a token, `operate` for `nylorun-operate`,
|
|
1440
|
+
* and `host` for the Runtime itself.
|
|
1441
|
+
*/
|
|
1442
|
+
export const TenantEventSchema = z
|
|
1443
|
+
.object({
|
|
1444
|
+
schema: z.literal(TENANT_EVENT_SCHEMA),
|
|
1445
|
+
seq: z.number().int().nonnegative(),
|
|
1446
|
+
time: z.string(),
|
|
1447
|
+
type: z.enum(TENANT_EVENT_TYPES),
|
|
1448
|
+
source: z.enum(TENANT_EVENT_SOURCES),
|
|
1449
|
+
principal: z.string(),
|
|
1450
|
+
payload: z.record(z.string(), z.unknown()),
|
|
1451
|
+
})
|
|
1452
|
+
.strict();
|
|
1453
|
+
/** A page of the Tenant's events, newest first; `nextCursor` reads older ones. */
|
|
1454
|
+
export const TenantAuditPageSchema = z
|
|
1455
|
+
.object({ events: z.array(TenantEventSchema), nextCursor: z.string().nullable() })
|
|
1456
|
+
.strict();
|
|
1457
|
+
/** `POST /v1/tenant/audit/studio-sign-in`: how a person signed in to Studio, and who when known. */
|
|
1458
|
+
export const StudioSignInRequestSchema = z
|
|
1459
|
+
.object({
|
|
1460
|
+
method: z.enum(STUDIO_SIGN_IN_METHODS),
|
|
1461
|
+
subject: z.string().min(1).max(200).optional(),
|
|
1462
|
+
})
|
|
1463
|
+
.strict();
|
|
1346
1464
|
/**
|
|
1347
1465
|
* A model role's name (Host feature `model-roles`, ADR-154): a lowercase letter, then up to 31
|
|
1348
1466
|
* lowercase letters, digits and `-`, such as `builder`.
|
|
@@ -3110,6 +3228,11 @@ export const EventSourceKindSchema = z.enum([
|
|
|
3110
3228
|
"human",
|
|
3111
3229
|
"api",
|
|
3112
3230
|
]);
|
|
3231
|
+
/**
|
|
3232
|
+
* Whose account an event is: the agent's or the Runtime's (ADR-159). A session's events have one each
|
|
3233
|
+
* (`EVENT_CATALOG`); every event on an Agent's stream (`AGENT_EVENT_TYPES`) is the Runtime's.
|
|
3234
|
+
*/
|
|
3235
|
+
export const EVENT_LAYERS = ["agent", "runtime"];
|
|
3113
3236
|
/**
|
|
3114
3237
|
* How far an event can be trusted, by who could forge it. `observed`: the Runtime saw it itself
|
|
3115
3238
|
* (commands, the tools core serves, gate records, core's settle). `claimed`: a harness reported
|
|
@@ -3948,65 +4071,73 @@ export const McpDiscoveredPayloadSchema = z
|
|
|
3948
4071
|
* new type or a protocol version, never an edit in place.
|
|
3949
4072
|
*/
|
|
3950
4073
|
export const EVENT_CATALOG = {
|
|
3951
|
-
"command.message": { payload: CommandMessagePayloadSchema, source: "api", version: 1 },
|
|
3952
|
-
"command.approve": { payload: CommandApprovePayloadSchema, source: "api", version: 1 },
|
|
3953
|
-
"command.respond": { payload: CommandRespondPayloadSchema, source: "api", version: 1 },
|
|
3954
|
-
"turn.completed": { payload: TurnCompletedPayloadSchema, source: "loop", version: 1 },
|
|
3955
|
-
"turn.paused": { payload: TurnPausedPayloadSchema, source: "loop", version: 1 },
|
|
3956
|
-
"turn.failed": { payload: TurnFailedPayloadSchema, source: "loop", version: 1 },
|
|
3957
|
-
"turn.cancelled": { payload: TurnCancelledPayloadSchema, source: "api", version: 1 },
|
|
3958
|
-
"turn.version_kept": { payload: TurnVersionKeptPayloadSchema, source: "api", version: 1 },
|
|
3959
|
-
"session.model": { payload: SessionModelPayloadSchema, source: "api", version: 1 },
|
|
3960
|
-
"message.queued": { payload: MessageQueuedPayloadSchema, source: "api", version: 1 },
|
|
3961
|
-
"queue.taken": { payload: QueueTakenPayloadSchema, source: "api", version: 1 },
|
|
3962
|
-
"queue.failed": { payload: QueueFailedPayloadSchema, source: "api", version: 1 },
|
|
3963
|
-
"queue.cancelled": { payload: QueueCancelledPayloadSchema, source: "api", version: 1 },
|
|
3964
|
-
"wake.booked": { payload: WakeBookedPayloadSchema, source: "api", version: 1 },
|
|
3965
|
-
"wake.cancelled": { payload: WakeCancelledPayloadSchema, source: "api", version: 1 },
|
|
3966
|
-
"memory.updated": { payload: MemoryUpdatedPayloadSchema, source: "api", version: 1 },
|
|
3967
|
-
"message.assistant": { payload: AssistantMessagePayloadSchema, source: "loop", version: 1 },
|
|
3968
|
-
"model.failed": { payload: ModelFailedPayloadSchema, source: "loop", version: 1 },
|
|
3969
|
-
"context.compacted": { payload: ContextCompactedPayloadSchema, source: "loop", version: 1 },
|
|
3970
|
-
"tool.completed": { payload: ToolCompletedPayloadSchema, source: "loop", version: 1 },
|
|
3971
|
-
"effect.uncertain": { payload: EffectUncertainPayloadSchema, source: "loop", version: 1 },
|
|
3972
|
-
"delegation.started": { payload: DelegationPayloadSchema, source: "loop", version: 1 },
|
|
3973
|
-
"delegation.completed": { payload: DelegationPayloadSchema, source: "loop", version: 1 },
|
|
3974
|
-
"mcp.discovered": { payload: McpDiscoveredPayloadSchema, source: "loop", version: 1 },
|
|
3975
|
-
"plan.updated": { payload: PlanUpdatedPayloadSchema, source: "loop", version: 1 },
|
|
3976
|
-
"engine.diagnostic": { payload: EngineDiagnosticPayloadSchema, source: "loop", version: 1 },
|
|
3977
|
-
"environment.state": { payload: EnvironmentStatePayloadSchema, source: "loop", version: 1 },
|
|
3978
|
-
"environment.exec": { payload: EnvironmentExecPayloadSchema, source: "loop", version: 1 },
|
|
3979
|
-
"agent.attached": { payload: AgentAttachedPayloadSchema, source: "api", version: 1 },
|
|
3980
|
-
"node.started": { payload: NodeStartedPayloadSchema, source: "loop", version: 1 },
|
|
3981
|
-
"node.completed": { payload: NodeCompletedPayloadSchema, source: "loop", version: 1 },
|
|
3982
|
-
"node.agent": { payload: NodeAgentPayloadSchema, source: "loop", version: 1 },
|
|
3983
|
-
"loop.iteration": { payload: LoopIterationPayloadSchema, source: "loop", version: 1 },
|
|
3984
|
-
"loop.verified": { payload: LoopVerifiedPayloadSchema, source: "api", version: 1 },
|
|
3985
|
-
"artifact.created": { payload: ArtifactVersionPayloadSchema, source: "api", version: 1 },
|
|
4074
|
+
"command.message": { payload: CommandMessagePayloadSchema, source: "api", version: 1, layer: "agent" },
|
|
4075
|
+
"command.approve": { payload: CommandApprovePayloadSchema, source: "api", version: 1, layer: "agent" },
|
|
4076
|
+
"command.respond": { payload: CommandRespondPayloadSchema, source: "api", version: 1, layer: "agent" },
|
|
4077
|
+
"turn.completed": { payload: TurnCompletedPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4078
|
+
"turn.paused": { payload: TurnPausedPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4079
|
+
"turn.failed": { payload: TurnFailedPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4080
|
+
"turn.cancelled": { payload: TurnCancelledPayloadSchema, source: "api", version: 1, layer: "agent" },
|
|
4081
|
+
"turn.version_kept": { payload: TurnVersionKeptPayloadSchema, source: "api", version: 1, layer: "runtime" },
|
|
4082
|
+
"session.model": { payload: SessionModelPayloadSchema, source: "api", version: 1, layer: "runtime" },
|
|
4083
|
+
"message.queued": { payload: MessageQueuedPayloadSchema, source: "api", version: 1, layer: "runtime" },
|
|
4084
|
+
"queue.taken": { payload: QueueTakenPayloadSchema, source: "api", version: 1, layer: "runtime" },
|
|
4085
|
+
"queue.failed": { payload: QueueFailedPayloadSchema, source: "api", version: 1, layer: "runtime" },
|
|
4086
|
+
"queue.cancelled": { payload: QueueCancelledPayloadSchema, source: "api", version: 1, layer: "runtime" },
|
|
4087
|
+
"wake.booked": { payload: WakeBookedPayloadSchema, source: "api", version: 1, layer: "runtime" },
|
|
4088
|
+
"wake.cancelled": { payload: WakeCancelledPayloadSchema, source: "api", version: 1, layer: "runtime" },
|
|
4089
|
+
"memory.updated": { payload: MemoryUpdatedPayloadSchema, source: "api", version: 1, layer: "agent" },
|
|
4090
|
+
"message.assistant": { payload: AssistantMessagePayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4091
|
+
"model.failed": { payload: ModelFailedPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4092
|
+
"context.compacted": { payload: ContextCompactedPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4093
|
+
"tool.completed": { payload: ToolCompletedPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4094
|
+
"effect.uncertain": { payload: EffectUncertainPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4095
|
+
"delegation.started": { payload: DelegationPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4096
|
+
"delegation.completed": { payload: DelegationPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4097
|
+
"mcp.discovered": { payload: McpDiscoveredPayloadSchema, source: "loop", version: 1, layer: "runtime" },
|
|
4098
|
+
"plan.updated": { payload: PlanUpdatedPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4099
|
+
"engine.diagnostic": { payload: EngineDiagnosticPayloadSchema, source: "loop", version: 1, layer: "runtime" },
|
|
4100
|
+
"environment.state": { payload: EnvironmentStatePayloadSchema, source: "loop", version: 1, layer: "runtime" },
|
|
4101
|
+
"environment.exec": { payload: EnvironmentExecPayloadSchema, source: "loop", version: 1, layer: "runtime" },
|
|
4102
|
+
"agent.attached": { payload: AgentAttachedPayloadSchema, source: "api", version: 1, layer: "runtime" },
|
|
4103
|
+
"node.started": { payload: NodeStartedPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4104
|
+
"node.completed": { payload: NodeCompletedPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4105
|
+
"node.agent": { payload: NodeAgentPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4106
|
+
"loop.iteration": { payload: LoopIterationPayloadSchema, source: "loop", version: 1, layer: "agent" },
|
|
4107
|
+
"loop.verified": { payload: LoopVerifiedPayloadSchema, source: "api", version: 1, layer: "agent" },
|
|
4108
|
+
"artifact.created": { payload: ArtifactVersionPayloadSchema, source: "api", version: 1, layer: "runtime" },
|
|
3986
4109
|
"artifact.version.created": {
|
|
3987
4110
|
payload: ArtifactVersionPayloadSchema,
|
|
3988
4111
|
source: "api",
|
|
3989
4112
|
version: 1,
|
|
4113
|
+
layer: "runtime",
|
|
3990
4114
|
},
|
|
3991
|
-
"artifact.deleted": { payload: ArtifactDeletedPayloadSchema, source: "api", version: 1 },
|
|
4115
|
+
"artifact.deleted": { payload: ArtifactDeletedPayloadSchema, source: "api", version: 1, layer: "runtime" },
|
|
3992
4116
|
"artifact.export.skipped": {
|
|
3993
4117
|
payload: ArtifactExportSkippedPayloadSchema,
|
|
3994
4118
|
source: "api",
|
|
3995
4119
|
version: 1,
|
|
4120
|
+
layer: "runtime",
|
|
3996
4121
|
},
|
|
3997
4122
|
"artifact.export.failed": {
|
|
3998
4123
|
payload: ArtifactExportFailedPayloadSchema,
|
|
3999
4124
|
source: "api",
|
|
4000
4125
|
version: 1,
|
|
4126
|
+
layer: "runtime",
|
|
4001
4127
|
},
|
|
4002
4128
|
"transcript.updated": {
|
|
4003
4129
|
payload: TranscriptUpdatedPayloadSchema,
|
|
4004
4130
|
source: "loop",
|
|
4005
4131
|
version: 1,
|
|
4132
|
+
layer: "agent",
|
|
4006
4133
|
visibility: "internal",
|
|
4007
4134
|
},
|
|
4008
4135
|
};
|
|
4009
4136
|
export const EVENT_TYPES = Object.keys(EVENT_CATALOG);
|
|
4137
|
+
/** An event type's layer (ADR-159); `undefined` for a type this version does not know. */
|
|
4138
|
+
export function eventLayer(type) {
|
|
4139
|
+
return Object.hasOwn(EVENT_CATALOG, type) ? EVENT_CATALOG[type].layer : undefined;
|
|
4140
|
+
}
|
|
4010
4141
|
export function isEventType(type) {
|
|
4011
4142
|
return Object.hasOwn(EVENT_CATALOG, type);
|
|
4012
4143
|
}
|