@sealkeeper/schema 0.4.4 → 0.4.6
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/dist/agent-name.d.ts +1 -1
- package/dist/agent-name.js +4 -4
- package/dist/api.d.ts +625 -33
- package/dist/api.js +262 -57
- package/dist/badge.d.ts +1 -0
- package/dist/badge.js +7 -0
- package/dist/client-address.d.ts +6 -0
- package/dist/client-address.js +81 -0
- package/dist/db/agents.d.ts +155 -0
- package/dist/db/agents.js +38 -0
- package/dist/db/client.d.ts +431 -0
- package/dist/db/client.js +24 -1
- package/dist/db/events.js +7 -0
- package/dist/db/index.d.ts +16 -0
- package/dist/db/index.js +4 -0
- package/dist/db/migrate.js +5 -1
- package/dist/db/migrator.d.ts +5 -1
- package/dist/db/migrator.js +18 -2
- package/dist/db/operator-identities.d.ts +211 -0
- package/dist/db/operator-identities.js +49 -0
- package/dist/db/operator-level-grants.d.ts +109 -0
- package/dist/db/operator-level-grants.js +30 -0
- package/dist/db/operator-slugs.d.ts +92 -0
- package/dist/db/operator-slugs.js +25 -0
- package/dist/db/operators.d.ts +119 -0
- package/dist/db/operators.js +30 -2
- package/dist/db/standing.d.ts +1 -0
- package/dist/db/standing.js +2 -0
- package/dist/db/task-claim-failures.d.ts +143 -0
- package/dist/db/task-claim-failures.js +37 -0
- package/dist/db/tasks.d.ts +60 -0
- package/dist/db/tasks.js +19 -1
- package/dist/envelope.d.ts +3 -0
- package/dist/envelope.js +16 -11
- package/dist/goal.d.ts +62 -1
- package/dist/goal.js +70 -11
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/json-shape.d.ts +9 -0
- package/dist/json-shape.js +70 -0
- package/dist/moderation.d.ts +29 -0
- package/dist/moderation.js +547 -0
- package/dist/operator-domains.d.ts +104 -0
- package/dist/operator-domains.js +85 -0
- package/dist/policy.d.ts +4 -0
- package/dist/policy.js +10 -0
- package/dist/runtime.d.ts +17 -0
- package/dist/runtime.js +61 -0
- package/dist/seal-conformance.js +2 -0
- package/dist/standing.d.ts +27 -8
- package/dist/standing.js +59 -22
- package/dist/tasks.d.ts +25 -1
- package/dist/tasks.js +43 -9
- package/package.json +1 -1
package/dist/db/agents.d.ts
CHANGED
|
@@ -138,6 +138,42 @@ export declare const agents: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
138
138
|
identity: undefined;
|
|
139
139
|
generated: undefined;
|
|
140
140
|
}, {}, {}>;
|
|
141
|
+
runtime: import("drizzle-orm/pg-core").PgColumn<{
|
|
142
|
+
name: "runtime";
|
|
143
|
+
tableName: "agents";
|
|
144
|
+
dataType: "string";
|
|
145
|
+
columnType: "PgText";
|
|
146
|
+
data: "claude-code" | "codex" | "cursor" | "gemini-cli" | "mastra" | "openclaw" | "other" | "unknown";
|
|
147
|
+
driverParam: string;
|
|
148
|
+
notNull: true;
|
|
149
|
+
hasDefault: true;
|
|
150
|
+
isPrimaryKey: false;
|
|
151
|
+
isAutoincrement: false;
|
|
152
|
+
hasRuntimeDefault: false;
|
|
153
|
+
enumValues: [string, ...string[]];
|
|
154
|
+
baseColumn: never;
|
|
155
|
+
identity: undefined;
|
|
156
|
+
generated: undefined;
|
|
157
|
+
}, {}, {
|
|
158
|
+
$type: "claude-code" | "codex" | "cursor" | "gemini-cli" | "mastra" | "openclaw" | "other" | "unknown";
|
|
159
|
+
}>;
|
|
160
|
+
runtimeIssuedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
161
|
+
name: "runtime_issued_at";
|
|
162
|
+
tableName: "agents";
|
|
163
|
+
dataType: "date";
|
|
164
|
+
columnType: "PgTimestamp";
|
|
165
|
+
data: Date;
|
|
166
|
+
driverParam: string;
|
|
167
|
+
notNull: false;
|
|
168
|
+
hasDefault: false;
|
|
169
|
+
isPrimaryKey: false;
|
|
170
|
+
isAutoincrement: false;
|
|
171
|
+
hasRuntimeDefault: false;
|
|
172
|
+
enumValues: undefined;
|
|
173
|
+
baseColumn: never;
|
|
174
|
+
identity: undefined;
|
|
175
|
+
generated: undefined;
|
|
176
|
+
}, {}, {}>;
|
|
141
177
|
dirtySince: import("drizzle-orm/pg-core").PgColumn<{
|
|
142
178
|
name: "dirty_since";
|
|
143
179
|
tableName: "agents";
|
|
@@ -189,6 +225,125 @@ export declare const agents: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
189
225
|
identity: undefined;
|
|
190
226
|
generated: undefined;
|
|
191
227
|
}, {}, {}>;
|
|
228
|
+
termsVersion: import("drizzle-orm/pg-core").PgColumn<{
|
|
229
|
+
name: "terms_version";
|
|
230
|
+
tableName: "agents";
|
|
231
|
+
dataType: "string";
|
|
232
|
+
columnType: "PgText";
|
|
233
|
+
data: string;
|
|
234
|
+
driverParam: string;
|
|
235
|
+
notNull: false;
|
|
236
|
+
hasDefault: false;
|
|
237
|
+
isPrimaryKey: false;
|
|
238
|
+
isAutoincrement: false;
|
|
239
|
+
hasRuntimeDefault: false;
|
|
240
|
+
enumValues: [string, ...string[]];
|
|
241
|
+
baseColumn: never;
|
|
242
|
+
identity: undefined;
|
|
243
|
+
generated: undefined;
|
|
244
|
+
}, {}, {}>;
|
|
245
|
+
privacyVersion: import("drizzle-orm/pg-core").PgColumn<{
|
|
246
|
+
name: "privacy_version";
|
|
247
|
+
tableName: "agents";
|
|
248
|
+
dataType: "string";
|
|
249
|
+
columnType: "PgText";
|
|
250
|
+
data: string;
|
|
251
|
+
driverParam: string;
|
|
252
|
+
notNull: false;
|
|
253
|
+
hasDefault: false;
|
|
254
|
+
isPrimaryKey: false;
|
|
255
|
+
isAutoincrement: false;
|
|
256
|
+
hasRuntimeDefault: false;
|
|
257
|
+
enumValues: [string, ...string[]];
|
|
258
|
+
baseColumn: never;
|
|
259
|
+
identity: undefined;
|
|
260
|
+
generated: undefined;
|
|
261
|
+
}, {}, {}>;
|
|
262
|
+
eventCount: import("drizzle-orm/pg-core").PgColumn<{
|
|
263
|
+
name: "event_count";
|
|
264
|
+
tableName: "agents";
|
|
265
|
+
dataType: "number";
|
|
266
|
+
columnType: "PgBigInt53";
|
|
267
|
+
data: number;
|
|
268
|
+
driverParam: string | number;
|
|
269
|
+
notNull: true;
|
|
270
|
+
hasDefault: true;
|
|
271
|
+
isPrimaryKey: false;
|
|
272
|
+
isAutoincrement: false;
|
|
273
|
+
hasRuntimeDefault: false;
|
|
274
|
+
enumValues: undefined;
|
|
275
|
+
baseColumn: never;
|
|
276
|
+
identity: undefined;
|
|
277
|
+
generated: undefined;
|
|
278
|
+
}, {}, {}>;
|
|
279
|
+
sessionCount: import("drizzle-orm/pg-core").PgColumn<{
|
|
280
|
+
name: "session_count";
|
|
281
|
+
tableName: "agents";
|
|
282
|
+
dataType: "number";
|
|
283
|
+
columnType: "PgBigInt53";
|
|
284
|
+
data: number;
|
|
285
|
+
driverParam: string | number;
|
|
286
|
+
notNull: true;
|
|
287
|
+
hasDefault: true;
|
|
288
|
+
isPrimaryKey: false;
|
|
289
|
+
isAutoincrement: false;
|
|
290
|
+
hasRuntimeDefault: false;
|
|
291
|
+
enumValues: undefined;
|
|
292
|
+
baseColumn: never;
|
|
293
|
+
identity: undefined;
|
|
294
|
+
generated: undefined;
|
|
295
|
+
}, {}, {}>;
|
|
296
|
+
toolCallCount: import("drizzle-orm/pg-core").PgColumn<{
|
|
297
|
+
name: "tool_call_count";
|
|
298
|
+
tableName: "agents";
|
|
299
|
+
dataType: "number";
|
|
300
|
+
columnType: "PgBigInt53";
|
|
301
|
+
data: number;
|
|
302
|
+
driverParam: string | number;
|
|
303
|
+
notNull: true;
|
|
304
|
+
hasDefault: true;
|
|
305
|
+
isPrimaryKey: false;
|
|
306
|
+
isAutoincrement: false;
|
|
307
|
+
hasRuntimeDefault: false;
|
|
308
|
+
enumValues: undefined;
|
|
309
|
+
baseColumn: never;
|
|
310
|
+
identity: undefined;
|
|
311
|
+
generated: undefined;
|
|
312
|
+
}, {}, {}>;
|
|
313
|
+
incidentCount: import("drizzle-orm/pg-core").PgColumn<{
|
|
314
|
+
name: "incident_count";
|
|
315
|
+
tableName: "agents";
|
|
316
|
+
dataType: "number";
|
|
317
|
+
columnType: "PgBigInt53";
|
|
318
|
+
data: number;
|
|
319
|
+
driverParam: string | number;
|
|
320
|
+
notNull: true;
|
|
321
|
+
hasDefault: true;
|
|
322
|
+
isPrimaryKey: false;
|
|
323
|
+
isAutoincrement: false;
|
|
324
|
+
hasRuntimeDefault: false;
|
|
325
|
+
enumValues: undefined;
|
|
326
|
+
baseColumn: never;
|
|
327
|
+
identity: undefined;
|
|
328
|
+
generated: undefined;
|
|
329
|
+
}, {}, {}>;
|
|
330
|
+
lastSeenAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
331
|
+
name: "last_seen_at";
|
|
332
|
+
tableName: "agents";
|
|
333
|
+
dataType: "date";
|
|
334
|
+
columnType: "PgTimestamp";
|
|
335
|
+
data: Date;
|
|
336
|
+
driverParam: string;
|
|
337
|
+
notNull: false;
|
|
338
|
+
hasDefault: false;
|
|
339
|
+
isPrimaryKey: false;
|
|
340
|
+
isAutoincrement: false;
|
|
341
|
+
hasRuntimeDefault: false;
|
|
342
|
+
enumValues: undefined;
|
|
343
|
+
baseColumn: never;
|
|
344
|
+
identity: undefined;
|
|
345
|
+
generated: undefined;
|
|
346
|
+
}, {}, {}>;
|
|
192
347
|
};
|
|
193
348
|
dialect: 'pg';
|
|
194
349
|
}>;
|
package/dist/db/agents.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sql } from 'drizzle-orm';
|
|
2
2
|
import { bigint, check, index, jsonb, pgTable, text, timestamp, uniqueIndex, uuid, } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { RUNTIMES } from '../runtime.js';
|
|
3
4
|
import { operators } from './operators.js';
|
|
4
5
|
import { timestamps } from './timestamps.js';
|
|
5
6
|
// How a Drizzle table is declared.
|
|
@@ -31,6 +32,15 @@ export const agents = pgTable('agents', {
|
|
|
31
32
|
// sent again cannot move the version back.
|
|
32
33
|
versionIssuedAt: timestamp('version_issued_at', { withTimezone: true }),
|
|
33
34
|
card: jsonb('card'),
|
|
35
|
+
// What the agent runs in, one of RUNTIMES. Set by the signed
|
|
36
|
+
// registration payload and changed by the signed PATCH, unknown until
|
|
37
|
+
// then. Migration 0024 backfilled unknown for every agent, since events
|
|
38
|
+
// do not say which adapter sent them.
|
|
39
|
+
runtime: text('runtime').$type().notNull().default('unknown'),
|
|
40
|
+
// The signed issuedAt of the last runtime change, null until the first.
|
|
41
|
+
// Same rule as versionIssuedAt, so an old envelope sent again cannot
|
|
42
|
+
// move the runtime back.
|
|
43
|
+
runtimeIssuedAt: timestamp('runtime_issued_at', { withTimezone: true }),
|
|
34
44
|
// When the agent was first marked dirty since the scoring run last
|
|
35
45
|
// cleared it. Every write that can move the agent's standing marks it,
|
|
36
46
|
// in the same transaction as that write, but a mark sets this only when
|
|
@@ -47,9 +57,37 @@ export const agents = pgTable('agents', {
|
|
|
47
57
|
// standing, a dormancy rung or evidence leaving the window. Written by
|
|
48
58
|
// the scoring run only, null when nothing is due.
|
|
49
59
|
recomputeAt: timestamp('recompute_at', { withTimezone: true }),
|
|
60
|
+
// The POLICY_VERSIONS the operator accepted by registering this agent,
|
|
61
|
+
// stamped by the API at registration, never sent by the client
|
|
62
|
+
// (VOU-121). Null for agents registered before.
|
|
63
|
+
termsVersion: text('terms_version'),
|
|
64
|
+
privacyVersion: text('privacy_version'),
|
|
65
|
+
// Live counts of the agent's events, all time, and the newest
|
|
66
|
+
// received_at, for the agent answers (VOU-207). The database keeps them.
|
|
67
|
+
// The events_count_agent_events trigger (migration 0038) adds each
|
|
68
|
+
// insert statement's accepted rows, so a replay skipped by ON CONFLICT
|
|
69
|
+
// adds nothing, and the application never writes them. Reading them is
|
|
70
|
+
// one primary key read however many events the agent has sent. Events
|
|
71
|
+
// are append only and deleted only with their agent, so nothing ever
|
|
72
|
+
// takes one away. bigint, since an agent at the ingest cap sends
|
|
73
|
+
// millions a day.
|
|
74
|
+
eventCount: bigint('event_count', { mode: 'number' }).notNull().default(0),
|
|
75
|
+
sessionCount: bigint('session_count', { mode: 'number' })
|
|
76
|
+
.notNull()
|
|
77
|
+
.default(0),
|
|
78
|
+
toolCallCount: bigint('tool_call_count', { mode: 'number' })
|
|
79
|
+
.notNull()
|
|
80
|
+
.default(0),
|
|
81
|
+
incidentCount: bigint('incident_count', { mode: 'number' })
|
|
82
|
+
.notNull()
|
|
83
|
+
.default(0),
|
|
84
|
+
lastSeenAt: timestamp('last_seen_at', { withTimezone: true }),
|
|
50
85
|
...timestamps,
|
|
51
86
|
}, (t) => [
|
|
52
87
|
check('agents_id_length', sql `length(${t.id}) = 43`),
|
|
88
|
+
// Built from RUNTIMES, so a runtime added there shows up as a changed
|
|
89
|
+
// check in the next drizzle-kit generate.
|
|
90
|
+
check('agents_runtime', sql `${t.runtime} in (${sql.raw(RUNTIMES.map((r) => `'${r}'`).join(', '))})`),
|
|
53
91
|
// The handle login/name points at one agent. Names are lowercase, so a
|
|
54
92
|
// plain unique index is enough.
|
|
55
93
|
uniqueIndex('agents_operator_name_unique').on(t.operatorId, t.name),
|