@heynixie/contract 0.71.0 → 0.72.0
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/{approval-contract.d.ts → contract/approval-contract.d.ts} +158 -0
- package/dist/{build-query-utils.d.ts → contract/build-query-utils.d.ts} +252 -238
- package/dist/{contract.d.ts → contract/contract.d.ts} +340 -285
- package/dist/contract/forgettable-kinds.d.ts +1 -0
- package/dist/{host-contract.d.ts → contract/host-contract.d.ts} +47 -0
- package/dist/{memory-view-contract.d.ts → contract/memory-view-contract.d.ts} +1 -217
- package/dist/contract/pause-state-schema.d.ts +9 -0
- package/dist/contract/recovery-schema.d.ts +21 -0
- package/dist/contract/rule-contract.d.ts +106 -0
- package/dist/index.d.ts +17 -18
- package/dist/index.js +751 -722
- package/dist/{build-pending-input.d.ts → span/build-pending-input.d.ts} +1 -1
- package/dist/{build-span-state.d.ts → span/build-span-state.d.ts} +1 -1
- package/dist/{pick-span-source.d.ts → span/pick-span-source.d.ts} +1 -1
- package/dist/types.d.ts +3 -3
- package/package.json +1 -1
- package/dist/forgettable-kinds.d.ts +0 -1
- package/dist/proposal-outcome-schema.d.ts +0 -37
- package/dist/rule-contract.d.ts +0 -124
- /package/dist/{action-proposal-schema.d.ts → contract/action-proposal-schema.d.ts} +0 -0
- /package/dist/{client-header-name.d.ts → contract/client-header-name.d.ts} +0 -0
- /package/dist/{forget-backup-schema.d.ts → contract/forget-backup-schema.d.ts} +0 -0
- /package/dist/{image-limits.d.ts → contract/image-limits.d.ts} +0 -0
- /package/dist/{image-not-found-error.d.ts → contract/image-not-found-error.d.ts} +0 -0
- /package/dist/{image-refused-error.d.ts → contract/image-refused-error.d.ts} +0 -0
- /package/dist/{input-miss-schema.d.ts → contract/input-miss-schema.d.ts} +0 -0
- /package/dist/{is-time-zone.d.ts → contract/is-time-zone.d.ts} +0 -0
- /package/dist/{known-contact-schema.d.ts → contract/known-contact-schema.d.ts} +0 -0
- /package/dist/{logged-input-schema.d.ts → contract/logged-input-schema.d.ts} +0 -0
- /package/dist/{memory-export-contract.d.ts → contract/memory-export-contract.d.ts} +0 -0
- /package/dist/{moment-contract.d.ts → contract/moment-contract.d.ts} +0 -0
- /package/dist/{render-session-cookie.d.ts → contract/render-session-cookie.d.ts} +0 -0
- /package/dist/{reused-id-errors.d.ts → contract/reused-id-errors.d.ts} +0 -0
- /package/dist/{session-cookie-name.d.ts → contract/session-cookie-name.d.ts} +0 -0
- /package/dist/{signed-in.d.ts → contract/signed-in.d.ts} +0 -0
- /package/dist/{task-schema.d.ts → contract/task-schema.d.ts} +0 -0
- /package/dist/{tool-call-schema.d.ts → contract/tool-call-schema.d.ts} +0 -0
- /package/dist/{turn-inputs-contract.d.ts → contract/turn-inputs-contract.d.ts} +0 -0
- /package/dist/{task-message-input-schema.d.ts → message/task-message-input-schema.d.ts} +0 -0
- /package/dist/{task-message-kind-schema.d.ts → message/task-message-kind-schema.d.ts} +0 -0
- /package/dist/{task-message-result-schema.d.ts → message/task-message-result-schema.d.ts} +0 -0
- /package/dist/{has-several-words.d.ts → span/has-several-words.d.ts} +0 -0
- /package/dist/{span-schema.d.ts → span/span-schema.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// src/has-several-words.ts
|
|
1
|
+
// src/span/has-several-words.ts
|
|
2
2
|
function hasSeveralWords(text) {
|
|
3
3
|
return /\S\s+\S/u.test(text);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
// src/pick-span-source.ts
|
|
6
|
+
// src/span/pick-span-source.ts
|
|
7
7
|
var pastedInputTypes = new Set(["insertFromPaste", "insertFromPasteAsQuotation"]);
|
|
8
8
|
var typedInputTypes = new Set([
|
|
9
9
|
"insertCompositionText",
|
|
@@ -29,7 +29,7 @@ function pickSpanSource(inputType, data) {
|
|
|
29
29
|
return "unknown";
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// src/build-pending-input.ts
|
|
32
|
+
// src/span/build-pending-input.ts
|
|
33
33
|
function buildPendingInput(fields) {
|
|
34
34
|
const pending = {
|
|
35
35
|
selection: {
|
|
@@ -41,12 +41,12 @@ function buildPendingInput(fields) {
|
|
|
41
41
|
};
|
|
42
42
|
return fields.inputType === "insertText" && fields.data !== null && hasSeveralWords(fields.data) ? { ...pending, respacing: fields.data } : pending;
|
|
43
43
|
}
|
|
44
|
-
// src/build-query-utils.ts
|
|
44
|
+
// src/contract/build-query-utils.ts
|
|
45
45
|
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
|
46
46
|
function buildQueryUtils(client) {
|
|
47
47
|
return createTanstackQueryUtils(client, { path: ["nixie"] });
|
|
48
48
|
}
|
|
49
|
-
// src/build-span-state.ts
|
|
49
|
+
// src/span/build-span-state.ts
|
|
50
50
|
function buildSpanState(state, pending, text) {
|
|
51
51
|
const pinned = planEdit(state.text, text, pending?.selection);
|
|
52
52
|
const fallback = pending === undefined || !isEditAtSelection(pinned, pending.selection);
|
|
@@ -146,35 +146,68 @@ function mergeSpans(spans) {
|
|
|
146
146
|
}
|
|
147
147
|
return merged;
|
|
148
148
|
}
|
|
149
|
-
// src/client-header-name.ts
|
|
149
|
+
// src/contract/client-header-name.ts
|
|
150
150
|
var clientHeaderName = "x-nixie-client";
|
|
151
|
-
// src/forgettable-kinds.ts
|
|
152
|
-
var forgettableKinds = [
|
|
153
|
-
|
|
151
|
+
// src/contract/forgettable-kinds.ts
|
|
152
|
+
var forgettableKinds = [
|
|
153
|
+
"action.outcome",
|
|
154
|
+
"action.queued",
|
|
155
|
+
"action.retry_scheduled",
|
|
156
|
+
"memory.writer_failed",
|
|
157
|
+
"model.compaction_failed",
|
|
158
|
+
"model.reply",
|
|
159
|
+
"model.session_summarized",
|
|
160
|
+
"owner_message",
|
|
161
|
+
"policy.action_answered",
|
|
162
|
+
"policy.action_proposed",
|
|
163
|
+
"policy.contact_marked_known",
|
|
164
|
+
"prompts.override_rejected",
|
|
165
|
+
"proposals.deferred",
|
|
166
|
+
"session.enrolled",
|
|
167
|
+
"session.labelled",
|
|
168
|
+
"session_kept",
|
|
169
|
+
"skills.write_rejected",
|
|
170
|
+
"task.created",
|
|
171
|
+
"task.run_ended",
|
|
172
|
+
"task.run_report_requested",
|
|
173
|
+
"task.step_errored",
|
|
174
|
+
"task_message",
|
|
175
|
+
"tool_called",
|
|
176
|
+
"tool_result"
|
|
177
|
+
];
|
|
178
|
+
// src/contract/contract.ts
|
|
154
179
|
import { eventIterator as eventIterator2, oc as oc2 } from "@orpc/contract";
|
|
155
|
-
import { z as
|
|
180
|
+
import { z as z13 } from "zod";
|
|
156
181
|
|
|
157
|
-
// src/
|
|
182
|
+
// src/span/span-schema.ts
|
|
183
|
+
import { z } from "zod";
|
|
184
|
+
var spanSchema = z.object({
|
|
185
|
+
end: z.int().nonnegative(),
|
|
186
|
+
source: z.enum(["typed", "pasted", "dropped", "unknown"]),
|
|
187
|
+
start: z.int().nonnegative()
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// src/contract/approval-contract.ts
|
|
158
191
|
import { z as z6 } from "zod";
|
|
159
192
|
|
|
160
|
-
// src/memory-view-contract.ts
|
|
193
|
+
// src/contract/memory-view-contract.ts
|
|
161
194
|
import { z as z5 } from "zod";
|
|
162
195
|
|
|
163
|
-
// src/forget-backup-schema.ts
|
|
164
|
-
import { z } from "zod";
|
|
165
|
-
var forgetBackupSchema =
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
196
|
+
// src/contract/forget-backup-schema.ts
|
|
197
|
+
import { z as z2 } from "zod";
|
|
198
|
+
var forgetBackupSchema = z2.discriminatedUnion("state", [
|
|
199
|
+
z2.object({ state: z2.literal("off") }),
|
|
200
|
+
z2.object({ state: z2.literal("pending") }),
|
|
201
|
+
z2.object({ state: z2.literal("failed"), failure: z2.string() }),
|
|
202
|
+
z2.object({ state: z2.literal("complete") }),
|
|
203
|
+
z2.object({ state: z2.literal("unknown") })
|
|
171
204
|
]);
|
|
172
205
|
|
|
173
|
-
// src/memory-export-contract.ts
|
|
206
|
+
// src/contract/memory-export-contract.ts
|
|
174
207
|
import { eventIterator } from "@orpc/contract";
|
|
175
|
-
import { z as
|
|
208
|
+
import { z as z3 } from "zod";
|
|
176
209
|
|
|
177
|
-
// src/reused-id-errors.ts
|
|
210
|
+
// src/contract/reused-id-errors.ts
|
|
178
211
|
var reusedIDErrors = {
|
|
179
212
|
CLIENT_ACTION_ID_REUSED: {
|
|
180
213
|
message: "The client action ID belongs to a different action",
|
|
@@ -182,52 +215,52 @@ var reusedIDErrors = {
|
|
|
182
215
|
}
|
|
183
216
|
};
|
|
184
217
|
|
|
185
|
-
// src/signed-in.ts
|
|
218
|
+
// src/contract/signed-in.ts
|
|
186
219
|
import { oc } from "@orpc/contract";
|
|
187
220
|
var signedIn = oc.errors({
|
|
188
221
|
UNAUTHORIZED: { message: "The device session is missing, lapsed or revoked", status: 401 }
|
|
189
222
|
});
|
|
190
223
|
|
|
191
|
-
// src/memory-export-contract.ts
|
|
224
|
+
// src/contract/memory-export-contract.ts
|
|
192
225
|
var checkedExport = signedIn.errors(reusedIDErrors).errors({
|
|
193
226
|
MEMORY_NOT_STARTED: { message: "The memory store has not started yet", status: 503 }
|
|
194
227
|
});
|
|
195
|
-
var exportEvent =
|
|
196
|
-
|
|
197
|
-
|
|
228
|
+
var exportEvent = z3.union([
|
|
229
|
+
z3.object({ chunk: z3.string() }),
|
|
230
|
+
z3.object({ isComplete: z3.literal(true) })
|
|
198
231
|
]);
|
|
199
232
|
var exportEvents = eventIterator(exportEvent);
|
|
200
233
|
var memoryExportContract = {
|
|
201
|
-
export: checkedExport.input(
|
|
234
|
+
export: checkedExport.input(z3.object({ clientActionID: z3.uuid() })).output(exportEvents)
|
|
202
235
|
};
|
|
203
236
|
|
|
204
|
-
// src/moment-contract.ts
|
|
205
|
-
import { z as
|
|
237
|
+
// src/contract/moment-contract.ts
|
|
238
|
+
import { z as z4 } from "zod";
|
|
206
239
|
var momentView = signedIn.errors({
|
|
207
240
|
MEMORY_NOT_STARTED: { message: "The memory store has not started yet", status: 503 },
|
|
208
241
|
MOMENT_NOT_FOUND: { message: "No moment has this ID", status: 404 },
|
|
209
242
|
STALE_VERSION: { message: "The moment has moved past that version", status: 409 }
|
|
210
243
|
});
|
|
211
|
-
var momentIDSchema =
|
|
212
|
-
var momentTargetSchema =
|
|
213
|
-
var reflectionSchema =
|
|
214
|
-
model:
|
|
215
|
-
text:
|
|
216
|
-
writtenAt:
|
|
217
|
-
});
|
|
218
|
-
var destroyPreviewSchema =
|
|
219
|
-
keptAt:
|
|
220
|
-
keptBy:
|
|
221
|
-
kept:
|
|
222
|
-
lost:
|
|
223
|
-
momentID:
|
|
224
|
-
note:
|
|
225
|
-
reflections:
|
|
226
|
-
shortID:
|
|
227
|
-
state:
|
|
228
|
-
thread:
|
|
229
|
-
title:
|
|
230
|
-
version:
|
|
244
|
+
var momentIDSchema = z4.string().min(1).max(200);
|
|
245
|
+
var momentTargetSchema = z4.object({ momentID: momentIDSchema, version: z4.int().positive() });
|
|
246
|
+
var reflectionSchema = z4.object({
|
|
247
|
+
model: z4.string(),
|
|
248
|
+
text: z4.string().nullable(),
|
|
249
|
+
writtenAt: z4.date()
|
|
250
|
+
});
|
|
251
|
+
var destroyPreviewSchema = z4.object({
|
|
252
|
+
keptAt: z4.date(),
|
|
253
|
+
keptBy: z4.enum(["owner", "model"]),
|
|
254
|
+
kept: z4.object({ records: z4.int().nonnegative() }),
|
|
255
|
+
lost: z4.object({ links: z4.int().nonnegative(), texts: z4.int().nonnegative() }),
|
|
256
|
+
momentID: z4.string(),
|
|
257
|
+
note: z4.string().nullable(),
|
|
258
|
+
reflections: z4.array(reflectionSchema),
|
|
259
|
+
shortID: z4.string(),
|
|
260
|
+
state: z4.enum(["active", "retired"]),
|
|
261
|
+
thread: z4.string(),
|
|
262
|
+
title: z4.string().nullable(),
|
|
263
|
+
version: z4.int().positive()
|
|
231
264
|
});
|
|
232
265
|
var momentKeep = signedIn.errors(reusedIDErrors).errors({
|
|
233
266
|
MEMORY_NOT_STARTED: { message: "The memory store has not started yet", status: 503 },
|
|
@@ -236,127 +269,93 @@ var momentKeep = signedIn.errors(reusedIDErrors).errors({
|
|
|
236
269
|
status: 422
|
|
237
270
|
}
|
|
238
271
|
});
|
|
239
|
-
var titleSchema =
|
|
240
|
-
var keepSchema =
|
|
241
|
-
clientActionID:
|
|
242
|
-
firstSequence:
|
|
243
|
-
lastSequence:
|
|
244
|
-
thread:
|
|
272
|
+
var titleSchema = z4.string().min(1).max(120).regex(/\S/u);
|
|
273
|
+
var keepSchema = z4.object({
|
|
274
|
+
clientActionID: z4.uuid(),
|
|
275
|
+
firstSequence: z4.int().nonnegative(),
|
|
276
|
+
lastSequence: z4.int().nonnegative(),
|
|
277
|
+
thread: z4.string().min(1).max(200),
|
|
245
278
|
title: titleSchema
|
|
246
279
|
});
|
|
247
|
-
var momentSummarySchema =
|
|
248
|
-
editedAt:
|
|
249
|
-
keptAt:
|
|
250
|
-
keptBy:
|
|
251
|
-
momentID:
|
|
252
|
-
shortID:
|
|
253
|
-
state:
|
|
254
|
-
title:
|
|
255
|
-
});
|
|
256
|
-
var momentListSchema =
|
|
257
|
-
before:
|
|
258
|
-
includeRetired:
|
|
259
|
-
query:
|
|
260
|
-
});
|
|
261
|
-
var linkSchema =
|
|
262
|
-
itemID:
|
|
263
|
-
shortID:
|
|
264
|
-
text:
|
|
265
|
-
});
|
|
266
|
-
var noteSchema =
|
|
267
|
-
var shownReflectionSchema = reflectionSchema.extend({ reflectionID:
|
|
280
|
+
var momentSummarySchema = z4.object({
|
|
281
|
+
editedAt: z4.date().nullable(),
|
|
282
|
+
keptAt: z4.date(),
|
|
283
|
+
keptBy: z4.enum(["owner", "model"]),
|
|
284
|
+
momentID: z4.string(),
|
|
285
|
+
shortID: z4.string(),
|
|
286
|
+
state: z4.enum(["active", "retired"]),
|
|
287
|
+
title: z4.string().nullable()
|
|
288
|
+
});
|
|
289
|
+
var momentListSchema = z4.object({
|
|
290
|
+
before: z4.int().nonnegative().optional(),
|
|
291
|
+
includeRetired: z4.boolean(),
|
|
292
|
+
query: z4.string().max(500).optional()
|
|
293
|
+
});
|
|
294
|
+
var linkSchema = z4.object({
|
|
295
|
+
itemID: z4.string(),
|
|
296
|
+
shortID: z4.string(),
|
|
297
|
+
text: z4.string().nullable()
|
|
298
|
+
});
|
|
299
|
+
var noteSchema = z4.object({ text: z4.string(), writtenAt: z4.date() });
|
|
300
|
+
var shownReflectionSchema = reflectionSchema.extend({ reflectionID: z4.string() });
|
|
268
301
|
var momentDetailSchema = momentSummarySchema.extend({
|
|
269
|
-
firstSequence:
|
|
270
|
-
lastSequence:
|
|
271
|
-
links:
|
|
302
|
+
firstSequence: z4.int().nonnegative(),
|
|
303
|
+
lastSequence: z4.int().nonnegative(),
|
|
304
|
+
links: z4.array(linkSchema),
|
|
272
305
|
note: noteSchema.nullable(),
|
|
273
|
-
reflections:
|
|
274
|
-
thread:
|
|
275
|
-
titleBy:
|
|
276
|
-
version:
|
|
277
|
-
});
|
|
278
|
-
var spanRecordSchema =
|
|
279
|
-
isGap:
|
|
280
|
-
isRemoved:
|
|
281
|
-
kind:
|
|
282
|
-
recordedAt:
|
|
283
|
-
sequence:
|
|
284
|
-
text:
|
|
285
|
-
tool:
|
|
286
|
-
});
|
|
287
|
-
var momentChangeSchema =
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
kind:
|
|
291
|
-
firstSequence:
|
|
292
|
-
lastSequence:
|
|
306
|
+
reflections: z4.array(shownReflectionSchema),
|
|
307
|
+
thread: z4.string(),
|
|
308
|
+
titleBy: z4.enum(["owner", "model"]),
|
|
309
|
+
version: z4.int().positive()
|
|
310
|
+
});
|
|
311
|
+
var spanRecordSchema = z4.object({
|
|
312
|
+
isGap: z4.boolean(),
|
|
313
|
+
isRemoved: z4.boolean(),
|
|
314
|
+
kind: z4.string(),
|
|
315
|
+
recordedAt: z4.date(),
|
|
316
|
+
sequence: z4.int().nonnegative(),
|
|
317
|
+
text: z4.string().nullable(),
|
|
318
|
+
tool: z4.string().nullable()
|
|
319
|
+
});
|
|
320
|
+
var momentChangeSchema = z4.discriminatedUnion("kind", [
|
|
321
|
+
z4.object({ kind: z4.literal("title"), title: titleSchema }),
|
|
322
|
+
z4.object({
|
|
323
|
+
kind: z4.literal("edges"),
|
|
324
|
+
firstSequence: z4.int().nonnegative(),
|
|
325
|
+
lastSequence: z4.int().nonnegative()
|
|
293
326
|
}),
|
|
294
|
-
|
|
295
|
-
|
|
327
|
+
z4.object({ kind: z4.literal("note"), note: z4.string().min(1).max(4000).regex(/\S/u) }),
|
|
328
|
+
z4.object({ kind: z4.literal("reflection_removed"), reflectionID: z4.string().min(1).max(200) })
|
|
296
329
|
]);
|
|
297
330
|
var momentChange = momentView.errors(reusedIDErrors);
|
|
298
331
|
var momentContract = {
|
|
299
|
-
keepMoment: momentKeep.input(keepSchema).output(
|
|
332
|
+
keepMoment: momentKeep.input(keepSchema).output(z4.object({ momentID: z4.string(), shortID: z4.string() })),
|
|
300
333
|
listMoments: signedIn.errors({
|
|
301
334
|
MEMORY_NOT_STARTED: { message: "The memory store has not started yet", status: 503 }
|
|
302
|
-
}).input(momentListSchema).output(
|
|
303
|
-
readMoment: momentView.input(
|
|
304
|
-
readMomentSpan: momentView.input(
|
|
335
|
+
}).input(momentListSchema).output(z4.object({ moments: z4.array(momentSummarySchema), next: z4.int().nonnegative().nullable() })),
|
|
336
|
+
readMoment: momentView.input(z4.object({ momentID: momentIDSchema })).output(momentDetailSchema),
|
|
337
|
+
readMomentSpan: momentView.input(z4.object({ momentID: momentIDSchema, after: z4.int().nonnegative().optional() })).output(z4.object({ records: z4.array(spanRecordSchema), next: z4.int().nonnegative().nullable() })),
|
|
305
338
|
editMoment: momentChange.errors({
|
|
306
339
|
BAD_SPAN: {
|
|
307
340
|
message: "The span needs a first and a last record on the thread, in order",
|
|
308
341
|
status: 422
|
|
309
342
|
},
|
|
310
343
|
REFLECTION_NOT_FOUND: { message: "The moment has no reflection with this ID", status: 404 }
|
|
311
|
-
}).input(momentTargetSchema.extend({ clientActionID:
|
|
344
|
+
}).input(momentTargetSchema.extend({ clientActionID: z4.uuid(), change: momentChangeSchema })).output(z4.object({ momentID: z4.string(), version: z4.int().positive() })),
|
|
312
345
|
linkMoment: momentChange.errors({
|
|
313
346
|
MEMORY_ITEM_NOT_FOUND: { message: "No memory item has this ID", status: 404 },
|
|
314
347
|
ALREADY_LINKED: { message: "The item is already linked to the moment", status: 409 },
|
|
315
348
|
NOT_LINKED: { message: "The item is not linked to the moment", status: 409 }
|
|
316
349
|
}).input(momentTargetSchema.extend({
|
|
317
|
-
clientActionID:
|
|
318
|
-
isLinked:
|
|
319
|
-
itemID:
|
|
320
|
-
})).output(
|
|
350
|
+
clientActionID: z4.uuid(),
|
|
351
|
+
isLinked: z4.boolean(),
|
|
352
|
+
itemID: z4.string().min(1).max(200)
|
|
353
|
+
})).output(z4.object({ momentID: z4.string(), version: z4.int().positive() })),
|
|
321
354
|
previewMomentDestroy: momentView.input(momentTargetSchema).output(destroyPreviewSchema),
|
|
322
|
-
destroyMoment: momentView.errors(reusedIDErrors).input(momentTargetSchema.extend({ clientActionID:
|
|
355
|
+
destroyMoment: momentView.errors(reusedIDErrors).input(momentTargetSchema.extend({ clientActionID: z4.uuid() })).output(z4.object({ momentID: z4.string() }))
|
|
323
356
|
};
|
|
324
357
|
|
|
325
|
-
// src/
|
|
326
|
-
import { z as z4 } from "zod";
|
|
327
|
-
var closeMatchSchema = z4.object({
|
|
328
|
-
itemID: z4.string(),
|
|
329
|
-
text: z4.string(),
|
|
330
|
-
version: z4.int().positive()
|
|
331
|
-
});
|
|
332
|
-
var proposalOutcomeSchema = z4.discriminatedUnion("status", [
|
|
333
|
-
z4.object({ proposalID: z4.string(), status: z4.literal("applied") }),
|
|
334
|
-
z4.object({ proposalID: z4.string(), status: z4.literal("rejected") }),
|
|
335
|
-
z4.object({
|
|
336
|
-
item: closeMatchSchema,
|
|
337
|
-
proposalID: z4.string(),
|
|
338
|
-
status: z4.literal("close_match")
|
|
339
|
-
}),
|
|
340
|
-
z4.object({
|
|
341
|
-
cause: z4.enum(["lapsed", "answered", "moved", "changed", "gone"]),
|
|
342
|
-
proposalID: z4.string(),
|
|
343
|
-
status: z4.literal("stale")
|
|
344
|
-
}),
|
|
345
|
-
z4.object({
|
|
346
|
-
code: z4.enum([
|
|
347
|
-
"CLIENT_ACTION_ID_REUSED",
|
|
348
|
-
"PIN_EDIT",
|
|
349
|
-
"PINNED_CORE_FULL",
|
|
350
|
-
"RETIREMENT_EDIT",
|
|
351
|
-
"REVISION_TARGET",
|
|
352
|
-
"WRONG_STATE"
|
|
353
|
-
]),
|
|
354
|
-
proposalID: z4.string(),
|
|
355
|
-
status: z4.literal("refused")
|
|
356
|
-
})
|
|
357
|
-
]);
|
|
358
|
-
|
|
359
|
-
// src/memory-view-contract.ts
|
|
358
|
+
// src/contract/memory-view-contract.ts
|
|
360
359
|
var memoryView = signedIn.errors({
|
|
361
360
|
MEMORY_NOT_STARTED: { message: "The memory store has not started yet", status: 503 }
|
|
362
361
|
});
|
|
@@ -366,7 +365,6 @@ var memoryChange = memoryView.errors(reusedIDErrors).errors({
|
|
|
366
365
|
WRONG_STATE: { message: "The memory item is not in a state that change takes", status: 409 }
|
|
367
366
|
});
|
|
368
367
|
var itemIDSchema = z5.string().min(1).max(200);
|
|
369
|
-
var itemTextSchema = z5.string().max(2000).regex(/\S/u);
|
|
370
368
|
var proposalOriginSchema = z5.enum(["owner", "conversation", "task", "memory_writer"]);
|
|
371
369
|
var originSchema = z5.enum([...proposalOriginSchema.options, "lapse"]);
|
|
372
370
|
var sourceSchema = z5.enum(["owner", "owner_data", "untrusted"]);
|
|
@@ -442,7 +440,8 @@ var reviewReasonSchema = z5.enum([
|
|
|
442
440
|
"self_note",
|
|
443
441
|
"from_photo",
|
|
444
442
|
"sensitive",
|
|
445
|
-
"subject_change"
|
|
443
|
+
"subject_change",
|
|
444
|
+
"ask_rule"
|
|
446
445
|
]);
|
|
447
446
|
var proposalSourceSchema = z5.object({
|
|
448
447
|
origin: proposalOriginSchema,
|
|
@@ -472,22 +471,7 @@ var memoryProposalSchema = z5.object({
|
|
|
472
471
|
text: z5.string(),
|
|
473
472
|
until: z5.date().nullable()
|
|
474
473
|
});
|
|
475
|
-
var proposalAnswerSchema = z5.object({
|
|
476
|
-
actionHash: z5.string().min(1).max(200),
|
|
477
|
-
clientActionID: z5.uuid(),
|
|
478
|
-
proposalID: z5.string().min(1).max(200)
|
|
479
|
-
});
|
|
480
474
|
var revisionTargetSchema = z5.object({ itemID: itemIDSchema, version: z5.int().positive() });
|
|
481
|
-
var approvalAnswerSchema = proposalAnswerSchema.extend({
|
|
482
|
-
editedText: itemTextSchema.optional(),
|
|
483
|
-
ignoreCloseMatch: z5.boolean().optional(),
|
|
484
|
-
revisionOf: revisionTargetSchema.optional()
|
|
485
|
-
});
|
|
486
|
-
var rejectionReasonSchema = z5.string().max(500).regex(/\S/u);
|
|
487
|
-
var rejectionAnswerSchema = proposalAnswerSchema.extend({
|
|
488
|
-
reason: rejectionReasonSchema.optional()
|
|
489
|
-
});
|
|
490
|
-
var proposalOutcomesSchema = z5.object({ outcomes: z5.array(proposalOutcomeSchema) });
|
|
491
475
|
var memoryItemDetailSchema = memoryItemSchema.extend({ versions: z5.array(memoryVersionSchema) });
|
|
492
476
|
var forgetLossSchema = z5.object({
|
|
493
477
|
evidenceMessages: z5.int().nonnegative(),
|
|
@@ -570,18 +554,11 @@ var memoryViewContract = {
|
|
|
570
554
|
PINNED_CORE_FULL: { message: "The pin takes the pinned core past its budget", status: 409 }
|
|
571
555
|
}).input(versionTargetSchema.extend({ isPinned: z5.boolean() })).output(z5.object({ isPinned: z5.boolean(), itemID: z5.string() })),
|
|
572
556
|
markSensitive: memoryChange.input(z5.object({ clientActionID: z5.uuid(), isSensitive: z5.boolean(), itemID: itemIDSchema })).output(z5.object({ isSensitive: z5.boolean(), itemID: z5.string() })),
|
|
573
|
-
listProposals: memoryView.output(z5.object({ proposals: z5.array(memoryProposalSchema) })),
|
|
574
|
-
approveProposals: memoryView.input(z5.object({
|
|
575
|
-
answers: z5.array(approvalAnswerSchema).min(1).max(50)
|
|
576
|
-
})).output(proposalOutcomesSchema),
|
|
577
|
-
rejectProposals: memoryView.input(z5.object({
|
|
578
|
-
answers: z5.array(rejectionAnswerSchema).min(1).max(50)
|
|
579
|
-
})).output(proposalOutcomesSchema),
|
|
580
557
|
...memoryExportContract,
|
|
581
558
|
...momentContract
|
|
582
559
|
};
|
|
583
560
|
|
|
584
|
-
// src/approval-contract.ts
|
|
561
|
+
// src/contract/approval-contract.ts
|
|
585
562
|
var choiceSchema = z6.enum(["approve", "always_allow", "defer", "decline"]);
|
|
586
563
|
var stateSchema = z6.enum(["pending", "deferred", "approved", "declined", "lapsed", "withdrawn"]);
|
|
587
564
|
var hashesSchema = z6.object({ actionHash: z6.string(), ruleHash: z6.string().nullable() });
|
|
@@ -600,12 +577,16 @@ var proposalSchema = z6.object({
|
|
|
600
577
|
lapsesAt: z6.date(),
|
|
601
578
|
deadlineAt: z6.date().nullable(),
|
|
602
579
|
deferGeneration: z6.int().nonnegative(),
|
|
603
|
-
deferUntil: z6.date().nullable()
|
|
580
|
+
deferUntil: z6.date().nullable(),
|
|
581
|
+
thread: z6.string().nullable(),
|
|
582
|
+
taskID: z6.string().nullable(),
|
|
583
|
+
sequence: z6.int().positive()
|
|
604
584
|
});
|
|
605
585
|
var bodySchema = z6.object({
|
|
606
586
|
sentence: z6.string(),
|
|
607
587
|
fields: z6.record(z6.string(), z6.string()),
|
|
608
588
|
ruleSentence: z6.string().nullable(),
|
|
589
|
+
approveLabel: z6.string(),
|
|
609
590
|
memory: memoryProposalSchema.optional()
|
|
610
591
|
});
|
|
611
592
|
var itemSchema = z6.object({
|
|
@@ -615,6 +596,14 @@ var itemSchema = z6.object({
|
|
|
615
596
|
task: taskSchema.nullable(),
|
|
616
597
|
choices: z6.array(choiceSchema)
|
|
617
598
|
});
|
|
599
|
+
var readItemSchema = z6.object({
|
|
600
|
+
proposal: proposalSchema,
|
|
601
|
+
body: bodySchema.nullable(),
|
|
602
|
+
task: taskSchema.nullable(),
|
|
603
|
+
choices: z6.array(choiceSchema),
|
|
604
|
+
answeredOn: z6.string().nullable(),
|
|
605
|
+
isAnsweredHere: z6.boolean()
|
|
606
|
+
});
|
|
618
607
|
var deferSettingsSchema = z6.object({
|
|
619
608
|
defaultMinutes: z6.int().positive(),
|
|
620
609
|
eveningAt: z6.string(),
|
|
@@ -637,7 +626,7 @@ var answerSchema = z6.object({
|
|
|
637
626
|
memory: memoryAnswerSchema.optional()
|
|
638
627
|
});
|
|
639
628
|
var ruleRefSchema = z6.object({ id: z6.string(), revision: versionSchema });
|
|
640
|
-
var
|
|
629
|
+
var closeMatchSchema = z6.object({ itemID: z6.string(), text: z6.string(), version: versionSchema });
|
|
641
630
|
var approvedSchema = z6.object({
|
|
642
631
|
proposalID: z6.string(),
|
|
643
632
|
state: z6.literal("approved"),
|
|
@@ -647,7 +636,7 @@ var closedSchema = z6.object({ proposalID: z6.string(), state: z6.enum(["decline
|
|
|
647
636
|
var closeMatchResultSchema = z6.object({
|
|
648
637
|
proposalID: z6.string(),
|
|
649
638
|
state: z6.literal("pending"),
|
|
650
|
-
closeMatch:
|
|
639
|
+
closeMatch: closeMatchSchema
|
|
651
640
|
});
|
|
652
641
|
var resultSchema = z6.discriminatedUnion("state", [
|
|
653
642
|
approvedSchema,
|
|
@@ -679,15 +668,19 @@ var answerErrors = signedIn.errors(reusedIDErrors).errors({
|
|
|
679
668
|
}
|
|
680
669
|
});
|
|
681
670
|
var listedSchema = z6.object({ defer: deferSettingsSchema, items: z6.array(itemSchema) });
|
|
671
|
+
var readInputSchema = z6.object({
|
|
672
|
+
proposalIDs: z6.array(z6.string().min(1).max(200)).min(1).max(100)
|
|
673
|
+
});
|
|
682
674
|
var batchInputSchema = z6.object({ answers: z6.array(answerSchema).min(1).max(100) });
|
|
683
675
|
var batchResultSchema = z6.object({ results: z6.array(z6.union([resultSchema, refusedSchema])) });
|
|
684
676
|
var approvalContract = {
|
|
685
677
|
listItems: signedIn.output(listedSchema),
|
|
678
|
+
readProposals: signedIn.input(readInputSchema).output(z6.object({ proposals: z6.array(readItemSchema) })),
|
|
686
679
|
answerProposal: answerErrors.input(answerSchema).output(resultSchema),
|
|
687
680
|
answerProposals: signedIn.errors(reusedIDErrors).input(batchInputSchema).output(batchResultSchema)
|
|
688
681
|
};
|
|
689
682
|
|
|
690
|
-
// src/image-limits.ts
|
|
683
|
+
// src/contract/image-limits.ts
|
|
691
684
|
var imageLimits = {
|
|
692
685
|
count: 4,
|
|
693
686
|
bytes: 5 * 1024 * 1024,
|
|
@@ -695,13 +688,13 @@ var imageLimits = {
|
|
|
695
688
|
mediaTypes: ["image/jpeg", "image/png", "image/webp", "image/gif"]
|
|
696
689
|
};
|
|
697
690
|
|
|
698
|
-
// src/image-not-found-error.ts
|
|
691
|
+
// src/contract/image-not-found-error.ts
|
|
699
692
|
var imageNotFoundError = {
|
|
700
693
|
message: "No readable image of a message has this position",
|
|
701
694
|
status: 404
|
|
702
695
|
};
|
|
703
696
|
|
|
704
|
-
// src/image-refused-error.ts
|
|
697
|
+
// src/contract/image-refused-error.ts
|
|
705
698
|
import { z as z7 } from "zod";
|
|
706
699
|
var imageRefusedDataSchema = z7.object({
|
|
707
700
|
position: z7.int().nonnegative().nullable(),
|
|
@@ -713,189 +706,204 @@ var imageRefusedError = {
|
|
|
713
706
|
data: imageRefusedDataSchema
|
|
714
707
|
};
|
|
715
708
|
|
|
716
|
-
// src/
|
|
709
|
+
// src/contract/pause-state-schema.ts
|
|
717
710
|
import { z as z8 } from "zod";
|
|
718
|
-
var
|
|
719
|
-
var
|
|
720
|
-
ruleID: z8.string(),
|
|
721
|
-
before: ruleVersionSchema,
|
|
722
|
-
after: ruleVersionSchema
|
|
723
|
-
});
|
|
724
|
-
var effectChangeSchema = z8.object({
|
|
725
|
-
tool: z8.string(),
|
|
726
|
-
remove: z8.array(z8.string()),
|
|
727
|
-
sentence: z8.string()
|
|
728
|
-
});
|
|
729
|
-
var ruleProposalSchema = z8.object({
|
|
730
|
-
proposalID: z8.string(),
|
|
731
|
-
changes: z8.array(ruleChangeSchema),
|
|
732
|
-
effectChanges: z8.array(effectChangeSchema),
|
|
733
|
-
createdAt: z8.date(),
|
|
734
|
-
lapseAt: z8.date()
|
|
735
|
-
});
|
|
736
|
-
var actionProposalSchema = z8.object({
|
|
737
|
-
proposalID: z8.string(),
|
|
738
|
-
tool: z8.string(),
|
|
739
|
-
sentence: z8.string(),
|
|
740
|
-
destinations: z8.array(z8.string()),
|
|
741
|
-
createdAt: z8.date(),
|
|
742
|
-
lapseAt: z8.date()
|
|
743
|
-
});
|
|
744
|
-
var ruleAnswer = signedIn.errors({
|
|
745
|
-
NOT_FOUND: { message: "No rule change proposal has this ID", status: 404 },
|
|
746
|
-
PROPOSAL_CLOSED: {
|
|
747
|
-
message: "The rule change proposal is answered, withdrawn or lapsed",
|
|
748
|
-
status: 409
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
|
-
var proposalIDSchema = z8.string().min(1).max(200);
|
|
752
|
-
var ruleContract = {
|
|
753
|
-
listProposals: signedIn.output(z8.object({ proposals: z8.array(ruleProposalSchema) })),
|
|
754
|
-
approveProposal: ruleAnswer.input(z8.object({ proposalID: proposalIDSchema })).output(z8.object({ proposalID: z8.string() })),
|
|
755
|
-
rejectProposal: ruleAnswer.input(z8.object({ proposalID: proposalIDSchema, reason: z8.string().max(500).regex(/\S/u) })).output(z8.object({ proposalID: z8.string() })),
|
|
756
|
-
listActionProposals: signedIn.output(z8.object({ proposals: z8.array(actionProposalSchema) })),
|
|
757
|
-
approveActionProposal: ruleAnswer.input(z8.object({ proposalID: proposalIDSchema })).output(z8.object({ proposalID: z8.string() })),
|
|
758
|
-
rejectActionProposal: ruleAnswer.input(z8.object({ proposalID: proposalIDSchema, reason: z8.string().max(500).regex(/\S/u) })).output(z8.object({ proposalID: z8.string() }))
|
|
759
|
-
};
|
|
711
|
+
var pauseCauseSchema = z8.enum(["restore", "owner", "spending"]);
|
|
712
|
+
var pauseStateSchema = z8.object({ cause: pauseCauseSchema, since: z8.date() }).nullable();
|
|
760
713
|
|
|
761
|
-
// src/
|
|
714
|
+
// src/contract/recovery-schema.ts
|
|
762
715
|
import { z as z9 } from "zod";
|
|
763
|
-
var
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
716
|
+
var taskStateSchema = z9.enum([
|
|
717
|
+
"ready",
|
|
718
|
+
"running",
|
|
719
|
+
"waiting",
|
|
720
|
+
"paused",
|
|
721
|
+
"stopped",
|
|
722
|
+
"done",
|
|
723
|
+
"failed",
|
|
724
|
+
"closed"
|
|
725
|
+
]);
|
|
726
|
+
var taskToCheckSchema = z9.object({
|
|
727
|
+
taskID: z9.string(),
|
|
728
|
+
name: z9.string(),
|
|
729
|
+
stateAtBackup: taskStateSchema,
|
|
730
|
+
wasRunning: z9.boolean(),
|
|
731
|
+
pendingActions: z9.int().nonnegative()
|
|
732
|
+
});
|
|
733
|
+
var recoverySchema = z9.object({
|
|
734
|
+
restoredAt: z9.date(),
|
|
735
|
+
backupTakenAt: z9.date(),
|
|
736
|
+
toCheck: z9.array(taskToCheckSchema)
|
|
737
|
+
}).nullable();
|
|
768
738
|
|
|
769
|
-
// src/
|
|
739
|
+
// src/contract/rule-contract.ts
|
|
770
740
|
import { z as z10 } from "zod";
|
|
771
|
-
var
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
741
|
+
var ruleIDSchema = z10.string().min(1).max(200);
|
|
742
|
+
var revisionSchema = z10.int().positive();
|
|
743
|
+
var ruleSchema = z10.object({
|
|
744
|
+
ruleID: z10.string(),
|
|
745
|
+
revision: revisionSchema,
|
|
746
|
+
sentence: z10.string(),
|
|
747
|
+
outcome: z10.enum(["allow", "ask", "deny"]),
|
|
748
|
+
destinations: z10.array(z10.string())
|
|
749
|
+
});
|
|
750
|
+
var notFound = { NOT_FOUND: { message: "No rule has this ID", status: 404 } };
|
|
751
|
+
var ruleChange = signedIn.errors(reusedIDErrors).errors({
|
|
752
|
+
...notFound,
|
|
753
|
+
CONFLICT: {
|
|
754
|
+
message: "The rule changed since the notice showed it",
|
|
755
|
+
status: 409,
|
|
756
|
+
data: z10.object({ revision: revisionSchema })
|
|
757
|
+
},
|
|
758
|
+
NOT_ALLOWED: {
|
|
759
|
+
message: "The rule takes no such change",
|
|
760
|
+
status: 403,
|
|
761
|
+
data: z10.object({ reason: z10.enum(["widens", "empty"]) })
|
|
762
|
+
}
|
|
781
763
|
});
|
|
764
|
+
var destinationsSchema = z10.array(z10.string().regex(/^\S+$/u)).max(100);
|
|
765
|
+
var ruleContract = {
|
|
766
|
+
readRule: signedIn.errors(notFound).input(z10.object({ ruleID: ruleIDSchema })).output(ruleSchema),
|
|
767
|
+
removeRule: ruleChange.input(z10.object({ ruleID: ruleIDSchema, revision: revisionSchema, clientActionID: z10.uuid() })).output(z10.object({ ruleID: z10.string() })),
|
|
768
|
+
editRule: ruleChange.input(z10.object({
|
|
769
|
+
ruleID: ruleIDSchema,
|
|
770
|
+
revision: revisionSchema,
|
|
771
|
+
destinations: destinationsSchema,
|
|
772
|
+
clientActionID: z10.uuid()
|
|
773
|
+
})).output(z10.object({ ruleID: z10.string(), revision: revisionSchema }))
|
|
774
|
+
};
|
|
782
775
|
|
|
783
|
-
// src/
|
|
776
|
+
// src/contract/task-schema.ts
|
|
784
777
|
import { z as z11 } from "zod";
|
|
785
|
-
var
|
|
786
|
-
|
|
787
|
-
|
|
778
|
+
var taskSchema2 = z11.object({
|
|
779
|
+
error: z11.string().optional(),
|
|
780
|
+
errorLimit: z11.int().positive().optional(),
|
|
781
|
+
errors: z11.int().positive().optional(),
|
|
782
|
+
isWaitingForRetry: z11.boolean().optional(),
|
|
783
|
+
readCursor: z11.int().nonnegative().optional(),
|
|
784
|
+
reason: z11.string().optional(),
|
|
785
|
+
retryAt: z11.date().optional(),
|
|
786
|
+
stepKey: z11.string().optional(),
|
|
787
|
+
taskID: z11.string()
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
// src/contract/tool-call-schema.ts
|
|
791
|
+
import { z as z12 } from "zod";
|
|
792
|
+
var jsonObjectSchema = z12.record(z12.string(), z12.unknown());
|
|
793
|
+
var toolCallSchema = z12.object({
|
|
794
|
+
callID: z12.string(),
|
|
788
795
|
content: jsonObjectSchema.optional(),
|
|
789
796
|
input: jsonObjectSchema.optional(),
|
|
790
|
-
outcome:
|
|
791
|
-
tool:
|
|
797
|
+
outcome: z12.string().optional(),
|
|
798
|
+
tool: z12.string().optional()
|
|
792
799
|
});
|
|
793
800
|
|
|
794
|
-
// src/contract.ts
|
|
795
|
-
var clientActionIDSchema =
|
|
796
|
-
var sequenceSchema =
|
|
797
|
-
var threadSchema =
|
|
798
|
-
var imageSchema =
|
|
799
|
-
var imageFilesSchema =
|
|
800
|
-
var imageRefSchema =
|
|
801
|
-
position:
|
|
801
|
+
// src/contract/contract.ts
|
|
802
|
+
var clientActionIDSchema = z13.uuid();
|
|
803
|
+
var sequenceSchema = z13.int().nonnegative();
|
|
804
|
+
var threadSchema = z13.string().min(1).max(200);
|
|
805
|
+
var imageSchema = z13.object({ mediaType: z13.enum(imageLimits.mediaTypes) });
|
|
806
|
+
var imageFilesSchema = z13.array(z13.file());
|
|
807
|
+
var imageRefSchema = z13.object({
|
|
808
|
+
position: z13.int().nonnegative(),
|
|
802
809
|
sequence: sequenceSchema,
|
|
803
810
|
thread: threadSchema
|
|
804
811
|
});
|
|
805
|
-
var versionRefSchema =
|
|
806
|
-
itemID:
|
|
807
|
-
version:
|
|
812
|
+
var versionRefSchema = z13.object({
|
|
813
|
+
itemID: z13.string().min(1).max(200),
|
|
814
|
+
version: z13.int().nonnegative()
|
|
808
815
|
});
|
|
809
|
-
var recallItemSchema = versionRefSchema.extend({ score:
|
|
810
|
-
var recallSchema =
|
|
816
|
+
var recallItemSchema = versionRefSchema.extend({ score: z13.number().optional() });
|
|
817
|
+
var recallSchema = z13.object({ items: z13.array(recallItemSchema) });
|
|
811
818
|
var ratingItemSchema = versionRefSchema.extend({
|
|
812
|
-
hasNote:
|
|
813
|
-
verdict:
|
|
819
|
+
hasNote: z13.boolean(),
|
|
820
|
+
verdict: z13.enum(["helpful", "noise", "misleading"])
|
|
814
821
|
});
|
|
815
|
-
var ratingSchema =
|
|
816
|
-
items:
|
|
817
|
-
ratedBy:
|
|
822
|
+
var ratingSchema = z13.object({
|
|
823
|
+
items: z13.array(ratingItemSchema),
|
|
824
|
+
ratedBy: z13.string().optional(),
|
|
818
825
|
recalledSequence: sequenceSchema
|
|
819
826
|
});
|
|
820
|
-
var tokenCountSchema =
|
|
821
|
-
var contextSchema =
|
|
822
|
-
var compactionSchema =
|
|
827
|
+
var tokenCountSchema = z13.int().nonnegative();
|
|
828
|
+
var contextSchema = z13.object({ size: tokenCountSchema, window: z13.int().positive() });
|
|
829
|
+
var compactionSchema = z13.object({
|
|
823
830
|
postTokens: tokenCountSchema.optional(),
|
|
824
831
|
preTokens: tokenCountSchema,
|
|
825
|
-
trigger:
|
|
832
|
+
trigger: z13.enum(["manual", "auto"])
|
|
826
833
|
});
|
|
827
|
-
var summarySchema =
|
|
834
|
+
var summarySchema = z13.object({
|
|
828
835
|
contextSize: tokenCountSchema.optional(),
|
|
829
836
|
summaryTokens: tokenCountSchema,
|
|
830
|
-
text:
|
|
831
|
-
trigger:
|
|
837
|
+
text: z13.string().optional(),
|
|
838
|
+
trigger: z13.enum(["threshold", "overflow"])
|
|
832
839
|
});
|
|
833
|
-
var compactionFailureSchema =
|
|
834
|
-
var ratingNoteRefSchema =
|
|
835
|
-
itemID:
|
|
840
|
+
var compactionFailureSchema = z13.object({ failures: z13.int().positive() });
|
|
841
|
+
var ratingNoteRefSchema = z13.object({
|
|
842
|
+
itemID: z13.string().min(1).max(200),
|
|
836
843
|
sequence: sequenceSchema
|
|
837
844
|
});
|
|
838
845
|
var ratingNoteSchema = ratingNoteRefSchema.extend({
|
|
839
|
-
status:
|
|
840
|
-
text:
|
|
846
|
+
status: z13.enum(["readable", "shredded", "unreadable", "missing"]),
|
|
847
|
+
text: z13.string().optional()
|
|
841
848
|
});
|
|
842
849
|
var versionTextSchema = versionRefSchema.extend({
|
|
843
|
-
status:
|
|
844
|
-
text:
|
|
850
|
+
status: z13.enum(["readable", "shredded", "unreadable", "missing"]),
|
|
851
|
+
text: z13.string().optional()
|
|
845
852
|
});
|
|
846
|
-
var listedActionSchema =
|
|
847
|
-
var taskMessageSchema =
|
|
853
|
+
var listedActionSchema = z13.object({ actionID: z13.string(), tool: z13.string() });
|
|
854
|
+
var taskMessageSchema = z13.object({
|
|
848
855
|
from: threadSchema,
|
|
849
|
-
fromName:
|
|
850
|
-
hop:
|
|
851
|
-
kind:
|
|
852
|
-
messageID:
|
|
853
|
-
replyTo:
|
|
854
|
-
text:
|
|
856
|
+
fromName: z13.string(),
|
|
857
|
+
hop: z13.int().nonnegative(),
|
|
858
|
+
kind: z13.string(),
|
|
859
|
+
messageID: z13.string(),
|
|
860
|
+
replyTo: z13.string().optional(),
|
|
861
|
+
text: z13.string().optional(),
|
|
855
862
|
to: threadSchema,
|
|
856
|
-
woke:
|
|
863
|
+
woke: z13.boolean()
|
|
857
864
|
});
|
|
858
|
-
var exchangeNoticeSchema =
|
|
859
|
-
link:
|
|
860
|
-
text:
|
|
865
|
+
var exchangeNoticeSchema = z13.object({
|
|
866
|
+
link: z13.object({ label: z13.string(), messageID: z13.string(), taskID: threadSchema }),
|
|
867
|
+
text: z13.string()
|
|
861
868
|
});
|
|
862
|
-
var recordSchema =
|
|
869
|
+
var recordSchema = z13.object({
|
|
863
870
|
compaction: compactionSchema.optional(),
|
|
864
871
|
exchangeNotice: exchangeNoticeSchema.optional(),
|
|
865
872
|
compactionFailure: compactionFailureSchema.optional(),
|
|
866
|
-
forget:
|
|
873
|
+
forget: z13.object({ sequence: sequenceSchema }).optional(),
|
|
867
874
|
context: contextSchema.optional(),
|
|
868
|
-
isRemoved:
|
|
869
|
-
isSilentTurn:
|
|
870
|
-
kind:
|
|
871
|
-
message:
|
|
872
|
-
clientMessageId:
|
|
873
|
-
images:
|
|
874
|
-
spans:
|
|
875
|
-
text:
|
|
875
|
+
isRemoved: z13.literal(true).optional(),
|
|
876
|
+
isSilentTurn: z13.literal(true).optional(),
|
|
877
|
+
kind: z13.string(),
|
|
878
|
+
message: z13.object({
|
|
879
|
+
clientMessageId: z13.uuid().optional(),
|
|
880
|
+
images: z13.array(imageSchema).optional(),
|
|
881
|
+
spans: z13.array(spanSchema).optional(),
|
|
882
|
+
text: z13.string()
|
|
876
883
|
}).optional(),
|
|
877
|
-
moment:
|
|
884
|
+
moment: z13.object({ momentID: z13.string(), shortID: z13.string(), title: z13.string().optional() }).optional(),
|
|
878
885
|
rating: ratingSchema.optional(),
|
|
886
|
+
proposal: z13.object({ proposalID: z13.string(), shortID: z13.string() }).optional(),
|
|
879
887
|
recall: recallSchema.optional(),
|
|
880
|
-
recordedAt:
|
|
888
|
+
recordedAt: z13.date(),
|
|
881
889
|
sequence: sequenceSchema,
|
|
882
|
-
stop:
|
|
890
|
+
stop: z13.object({ cancelledActions: z13.array(listedActionSchema) }).optional(),
|
|
883
891
|
summary: summarySchema.optional(),
|
|
884
892
|
thread: threadSchema,
|
|
885
893
|
task: taskSchema2.optional(),
|
|
886
894
|
taskMessage: taskMessageSchema.optional(),
|
|
887
895
|
toolCall: toolCallSchema.optional()
|
|
888
896
|
});
|
|
889
|
-
var writerErrorSchema =
|
|
890
|
-
var sessionSchema =
|
|
891
|
-
createdAt:
|
|
892
|
-
current:
|
|
893
|
-
deviceName:
|
|
894
|
-
lastUsedAt:
|
|
895
|
-
sessionID:
|
|
897
|
+
var writerErrorSchema = z13.object({ at: z13.date(), code: z13.string(), message: z13.string().nullable() }).nullable();
|
|
898
|
+
var sessionSchema = z13.object({
|
|
899
|
+
createdAt: z13.date(),
|
|
900
|
+
current: z13.boolean(),
|
|
901
|
+
deviceName: z13.string(),
|
|
902
|
+
lastUsedAt: z13.date(),
|
|
903
|
+
sessionID: z13.uuid()
|
|
896
904
|
});
|
|
897
905
|
var checkedAction = signedIn.errors(reusedIDErrors);
|
|
898
|
-
var
|
|
906
|
+
var taskStateSchema2 = z13.enum([
|
|
899
907
|
"ready",
|
|
900
908
|
"running",
|
|
901
909
|
"waiting",
|
|
@@ -905,33 +913,34 @@ var taskStateSchema = z12.enum([
|
|
|
905
913
|
"failed",
|
|
906
914
|
"closed"
|
|
907
915
|
]);
|
|
908
|
-
var taskControlSchema =
|
|
909
|
-
var actionCountSchema =
|
|
910
|
-
var forgetPreviewItemSchema =
|
|
911
|
-
var recordForgetPreviewSchema =
|
|
916
|
+
var taskControlSchema = z13.enum(["pause", "resume", "stop", "restart", "close", "interrupt"]);
|
|
917
|
+
var actionCountSchema = z13.int().nonnegative();
|
|
918
|
+
var forgetPreviewItemSchema = z13.object({ itemID: z13.string(), text: z13.string() });
|
|
919
|
+
var recordForgetPreviewSchema = z13.object({
|
|
912
920
|
momentCount: actionCountSchema,
|
|
913
|
-
memoryItems:
|
|
921
|
+
memoryItems: z13.array(forgetPreviewItemSchema)
|
|
914
922
|
});
|
|
915
|
-
var listedTaskSchema =
|
|
916
|
-
actions:
|
|
923
|
+
var listedTaskSchema = z13.object({
|
|
924
|
+
actions: z13.object({
|
|
917
925
|
cancelled: actionCountSchema,
|
|
918
926
|
queued: actionCountSchema,
|
|
919
927
|
started: actionCountSchema
|
|
920
928
|
}),
|
|
921
|
-
brief:
|
|
922
|
-
controls:
|
|
923
|
-
isPauseRequested:
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
929
|
+
brief: z13.string(),
|
|
930
|
+
controls: z13.array(taskControlSchema),
|
|
931
|
+
isPauseRequested: z13.boolean(),
|
|
932
|
+
isPausedByNixie: z13.boolean(),
|
|
933
|
+
isTakingMessages: z13.boolean(),
|
|
934
|
+
lastActivityAt: z13.date(),
|
|
935
|
+
name: z13.string(),
|
|
936
|
+
state: taskStateSchema2,
|
|
928
937
|
taskID: threadSchema,
|
|
929
938
|
waitingOn: threadSchema.optional()
|
|
930
939
|
});
|
|
931
|
-
var controlledTaskSchema =
|
|
932
|
-
controlledAt:
|
|
933
|
-
isPauseRequested:
|
|
934
|
-
state:
|
|
940
|
+
var controlledTaskSchema = z13.object({
|
|
941
|
+
controlledAt: z13.date(),
|
|
942
|
+
isPauseRequested: z13.boolean(),
|
|
943
|
+
state: taskStateSchema2,
|
|
935
944
|
taskID: threadSchema
|
|
936
945
|
});
|
|
937
946
|
var taskControl = checkedAction.errors({
|
|
@@ -939,69 +948,74 @@ var taskControl = checkedAction.errors({
|
|
|
939
948
|
TASK_STATE_REFUSED: {
|
|
940
949
|
message: "The task is in a state that does not take this control",
|
|
941
950
|
status: 409,
|
|
942
|
-
data:
|
|
951
|
+
data: z13.object({ isPauseRequested: z13.boolean(), state: taskStateSchema2 })
|
|
943
952
|
}
|
|
944
|
-
}).input(
|
|
945
|
-
var
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
953
|
+
}).input(z13.object({ clientActionID: clientActionIDSchema, taskID: threadSchema })).output(controlledTaskSchema);
|
|
954
|
+
var nixieControl = checkedAction.input(z13.object({ clientActionID: clientActionIDSchema })).output(z13.object({ paused: pauseStateSchema }));
|
|
955
|
+
var backupNoticeSchema = z13.object({
|
|
956
|
+
cause: z13.enum(["failed", "missing"]),
|
|
957
|
+
sequence: z13.int().positive(),
|
|
958
|
+
raisedAt: z13.date()
|
|
959
|
+
});
|
|
960
|
+
var followRecords = signedIn.input(z13.object({ afterSequence: sequenceSchema, thread: threadSchema.optional() })).output(eventIterator2(z13.object({ record: recordSchema })));
|
|
951
961
|
var contract = {
|
|
952
962
|
conversation: {
|
|
953
|
-
read: signedIn.errors({ THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 } }).input(
|
|
963
|
+
read: signedIn.errors({ THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 } }).input(z13.object({
|
|
954
964
|
beforeSequence: sequenceSchema.optional(),
|
|
955
|
-
limit:
|
|
965
|
+
limit: z13.int().min(1).max(200).optional(),
|
|
956
966
|
thread: threadSchema
|
|
957
|
-
})).output(
|
|
958
|
-
hasEarlier:
|
|
967
|
+
})).output(z13.object({
|
|
968
|
+
hasEarlier: z13.boolean(),
|
|
959
969
|
readAtSequence: sequenceSchema,
|
|
960
|
-
records:
|
|
970
|
+
records: z13.array(recordSchema),
|
|
961
971
|
lastStepEnd: recordSchema.nullable().optional()
|
|
962
972
|
})),
|
|
963
973
|
send: checkedAction.errors({
|
|
964
974
|
IMAGE_REFUSED: imageRefusedError,
|
|
965
975
|
THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 }
|
|
966
|
-
}).input(
|
|
976
|
+
}).input(z13.object({
|
|
967
977
|
clientMessageId: clientActionIDSchema,
|
|
968
978
|
images: imageFilesSchema.optional(),
|
|
969
|
-
spans:
|
|
970
|
-
text:
|
|
979
|
+
spans: z13.array(spanSchema).max(1e5),
|
|
980
|
+
text: z13.string().min(1).max(1e5),
|
|
971
981
|
thread: threadSchema,
|
|
972
|
-
timeZone:
|
|
973
|
-
writtenAt:
|
|
974
|
-
})).output(
|
|
982
|
+
timeZone: z13.string().min(1).max(100).optional(),
|
|
983
|
+
writtenAt: z13.iso.datetime().optional()
|
|
984
|
+
})).output(z13.object({ duplicate: z13.boolean(), sequence: sequenceSchema })),
|
|
975
985
|
retry: checkedAction.errors({
|
|
976
986
|
NOTHING_TO_RETRY: {
|
|
977
987
|
message: "The last turn of the conversation did not fail, or it runs again already",
|
|
978
988
|
status: 409
|
|
979
989
|
}
|
|
980
|
-
}).input(
|
|
981
|
-
readImage: signedIn.errors({ IMAGE_NOT_FOUND: imageNotFoundError }).input(imageRefSchema).output(
|
|
990
|
+
}).input(z13.object({ clientActionID: clientActionIDSchema })).output(z13.object({ retriedAt: z13.date() })),
|
|
991
|
+
readImage: signedIn.errors({ IMAGE_NOT_FOUND: imageNotFoundError }).input(imageRefSchema).output(z13.file()),
|
|
982
992
|
previewForget: signedIn.errors({
|
|
983
993
|
RECORD_NOT_FOUND: {
|
|
984
|
-
message: "No
|
|
994
|
+
message: "No record on this thread with its own text that a forget removes has this sequence",
|
|
985
995
|
status: 404
|
|
986
996
|
}
|
|
987
|
-
}).input(
|
|
997
|
+
}).input(z13.object({ thread: threadSchema, sequence: sequenceSchema })).output(recordForgetPreviewSchema),
|
|
988
998
|
forget: checkedAction.errors({
|
|
989
999
|
RECORD_NOT_FOUND: {
|
|
990
|
-
message: "No
|
|
1000
|
+
message: "No record on this thread with its own text that a forget removes has this sequence",
|
|
991
1001
|
status: 404
|
|
1002
|
+
},
|
|
1003
|
+
ACTION_NOT_FINISHED: {
|
|
1004
|
+
message: "The queued action has not run yet. Cancel it, or wait for it to run.",
|
|
1005
|
+
status: 409
|
|
992
1006
|
}
|
|
993
|
-
}).input(
|
|
1007
|
+
}).input(z13.object({
|
|
994
1008
|
clientActionID: clientActionIDSchema,
|
|
995
1009
|
sequence: sequenceSchema,
|
|
996
1010
|
thread: threadSchema
|
|
997
|
-
})).output(
|
|
1011
|
+
})).output(z13.object({ forgottenAt: z13.date(), backup: forgetBackupSchema }))
|
|
998
1012
|
},
|
|
999
1013
|
tasks: {
|
|
1000
|
-
list: signedIn.output(
|
|
1001
|
-
read: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(
|
|
1002
|
-
readActions: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(
|
|
1003
|
-
queued:
|
|
1004
|
-
started:
|
|
1014
|
+
list: signedIn.output(z13.object({ readAtSequence: sequenceSchema, tasks: z13.array(listedTaskSchema) })),
|
|
1015
|
+
read: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(z13.object({ taskID: threadSchema })).output(listedTaskSchema),
|
|
1016
|
+
readActions: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(z13.object({ taskID: threadSchema })).output(z13.object({
|
|
1017
|
+
queued: z13.array(listedActionSchema),
|
|
1018
|
+
started: z13.array(listedActionSchema)
|
|
1005
1019
|
})),
|
|
1006
1020
|
pause: taskControl,
|
|
1007
1021
|
resume: taskControl,
|
|
@@ -1013,23 +1027,31 @@ var contract = {
|
|
|
1013
1027
|
interrupt: taskControl
|
|
1014
1028
|
},
|
|
1015
1029
|
memory: {
|
|
1016
|
-
readVersions: signedIn.input(
|
|
1017
|
-
readRatingNotes: signedIn.input(
|
|
1018
|
-
writerStatus: signedIn.output(
|
|
1019
|
-
isEnabled:
|
|
1020
|
-
backlog:
|
|
1021
|
-
batches:
|
|
1030
|
+
readVersions: signedIn.input(z13.object({ versions: z13.array(versionRefSchema).min(1).max(100) })).output(z13.object({ versions: z13.array(versionTextSchema) })),
|
|
1031
|
+
readRatingNotes: signedIn.input(z13.object({ notes: z13.array(ratingNoteRefSchema).min(1).max(100) })).output(z13.object({ notes: z13.array(ratingNoteSchema) })),
|
|
1032
|
+
writerStatus: signedIn.output(z13.object({
|
|
1033
|
+
isEnabled: z13.boolean(),
|
|
1034
|
+
backlog: z13.int().nonnegative(),
|
|
1035
|
+
batches: z13.int().nonnegative(),
|
|
1022
1036
|
cursor: sequenceSchema,
|
|
1023
|
-
failures:
|
|
1024
|
-
isCatchingUp:
|
|
1037
|
+
failures: z13.int().nonnegative(),
|
|
1038
|
+
isCatchingUp: z13.boolean(),
|
|
1025
1039
|
lastError: writerErrorSchema,
|
|
1026
|
-
retryAt:
|
|
1040
|
+
retryAt: z13.date().nullable()
|
|
1027
1041
|
})),
|
|
1028
|
-
consolidatorStatus: signedIn.output(
|
|
1042
|
+
consolidatorStatus: signedIn.output(z13.object({ isEnabled: z13.boolean() })),
|
|
1029
1043
|
...memoryViewContract
|
|
1030
1044
|
},
|
|
1045
|
+
nixie: {
|
|
1046
|
+
read: signedIn.output(z13.object({ paused: pauseStateSchema })),
|
|
1047
|
+
pause: nixieControl,
|
|
1048
|
+
resume: nixieControl
|
|
1049
|
+
},
|
|
1050
|
+
recovery: {
|
|
1051
|
+
read: signedIn.output(z13.object({ recovery: recoverySchema }))
|
|
1052
|
+
},
|
|
1031
1053
|
backups: {
|
|
1032
|
-
readNotice: signedIn.output(
|
|
1054
|
+
readNotice: signedIn.output(z13.object({ notice: backupNoticeSchema.nullable() }))
|
|
1033
1055
|
},
|
|
1034
1056
|
rules: ruleContract,
|
|
1035
1057
|
approvals: approvalContract,
|
|
@@ -1045,28 +1067,28 @@ var contract = {
|
|
|
1045
1067
|
message: "The enrolment code is unknown, used or lapsed",
|
|
1046
1068
|
status: 400
|
|
1047
1069
|
}
|
|
1048
|
-
}).input(
|
|
1070
|
+
}).input(z13.object({
|
|
1049
1071
|
clientActionID: clientActionIDSchema,
|
|
1050
|
-
code:
|
|
1051
|
-
deviceName:
|
|
1052
|
-
tokenDelivery:
|
|
1053
|
-
})).output(
|
|
1054
|
-
issueCode: checkedAction.input(
|
|
1055
|
-
list: signedIn.output(
|
|
1056
|
-
revoke: checkedAction.errors({ SESSION_NOT_FOUND: { message: "No session has this ID", status: 404 } }).input(
|
|
1072
|
+
code: z13.string().min(1).max(100),
|
|
1073
|
+
deviceName: z13.string().min(1).max(100),
|
|
1074
|
+
tokenDelivery: z13.enum(["cookie", "bearer"])
|
|
1075
|
+
})).output(z13.object({ sessionID: z13.uuid(), token: z13.string().optional() })),
|
|
1076
|
+
issueCode: checkedAction.input(z13.object({ clientActionID: clientActionIDSchema })).output(z13.object({ code: z13.string(), expiresAt: z13.date() })),
|
|
1077
|
+
list: signedIn.output(z13.object({ sessions: z13.array(sessionSchema) })),
|
|
1078
|
+
revoke: checkedAction.errors({ SESSION_NOT_FOUND: { message: "No session has this ID", status: 404 } }).input(z13.object({ clientActionID: clientActionIDSchema, sessionID: z13.uuid() })).output(z13.object({ revokedAt: z13.date() }))
|
|
1057
1079
|
}
|
|
1058
1080
|
};
|
|
1059
|
-
// src/host-contract.ts
|
|
1081
|
+
// src/contract/host-contract.ts
|
|
1060
1082
|
import { oc as oc4 } from "@orpc/contract";
|
|
1061
|
-
import { z as
|
|
1083
|
+
import { z as z19 } from "zod";
|
|
1062
1084
|
|
|
1063
|
-
// src/action-proposal-schema.ts
|
|
1064
|
-
import { z as
|
|
1065
|
-
var
|
|
1066
|
-
proposalID:
|
|
1067
|
-
tool:
|
|
1068
|
-
effects:
|
|
1069
|
-
cause:
|
|
1085
|
+
// src/contract/action-proposal-schema.ts
|
|
1086
|
+
import { z as z14 } from "zod";
|
|
1087
|
+
var actionProposalSchema = z14.object({
|
|
1088
|
+
proposalID: z14.string(),
|
|
1089
|
+
tool: z14.string(),
|
|
1090
|
+
effects: z14.array(z14.string()),
|
|
1091
|
+
cause: z14.enum([
|
|
1070
1092
|
"outside_steering",
|
|
1071
1093
|
"always_ask",
|
|
1072
1094
|
"ask_rule",
|
|
@@ -1074,33 +1096,33 @@ var actionProposalSchema2 = z13.object({
|
|
|
1074
1096
|
"direct_request",
|
|
1075
1097
|
"repeat"
|
|
1076
1098
|
]),
|
|
1077
|
-
sentence:
|
|
1078
|
-
destinations:
|
|
1079
|
-
createdAt:
|
|
1080
|
-
lapseAt:
|
|
1099
|
+
sentence: z14.string(),
|
|
1100
|
+
destinations: z14.array(z14.string()),
|
|
1101
|
+
createdAt: z14.date(),
|
|
1102
|
+
lapseAt: z14.date()
|
|
1081
1103
|
});
|
|
1082
1104
|
|
|
1083
|
-
// src/known-contact-schema.ts
|
|
1084
|
-
import { z as
|
|
1085
|
-
var knownContactSchema =
|
|
1086
|
-
contactID:
|
|
1087
|
-
name:
|
|
1088
|
-
destination:
|
|
1089
|
-
markedAt:
|
|
1105
|
+
// src/contract/known-contact-schema.ts
|
|
1106
|
+
import { z as z15 } from "zod";
|
|
1107
|
+
var knownContactSchema = z15.object({
|
|
1108
|
+
contactID: z15.string(),
|
|
1109
|
+
name: z15.string().nullable(),
|
|
1110
|
+
destination: z15.string().nullable(),
|
|
1111
|
+
markedAt: z15.date()
|
|
1090
1112
|
});
|
|
1091
1113
|
|
|
1092
|
-
// src/turn-inputs-contract.ts
|
|
1114
|
+
// src/contract/turn-inputs-contract.ts
|
|
1093
1115
|
import { oc as oc3 } from "@orpc/contract";
|
|
1094
|
-
import { z as
|
|
1116
|
+
import { z as z18 } from "zod";
|
|
1095
1117
|
|
|
1096
|
-
// src/input-miss-schema.ts
|
|
1097
|
-
import { z as
|
|
1098
|
-
var inputMissSchema =
|
|
1099
|
-
missID:
|
|
1100
|
-
captureID:
|
|
1101
|
-
taskID:
|
|
1102
|
-
stepRunID:
|
|
1103
|
-
reason:
|
|
1118
|
+
// src/contract/input-miss-schema.ts
|
|
1119
|
+
import { z as z16 } from "zod";
|
|
1120
|
+
var inputMissSchema = z16.object({
|
|
1121
|
+
missID: z16.string(),
|
|
1122
|
+
captureID: z16.string().nullable(),
|
|
1123
|
+
taskID: z16.string(),
|
|
1124
|
+
stepRunID: z16.string(),
|
|
1125
|
+
reason: z16.enum([
|
|
1104
1126
|
"queue_full",
|
|
1105
1127
|
"spool_full",
|
|
1106
1128
|
"spool_write_failed",
|
|
@@ -1112,45 +1134,45 @@ var inputMissSchema = z15.object({
|
|
|
1112
1134
|
"intake_failed",
|
|
1113
1135
|
"holds_own_value"
|
|
1114
1136
|
]),
|
|
1115
|
-
count:
|
|
1116
|
-
writer:
|
|
1117
|
-
counter:
|
|
1118
|
-
createdAt:
|
|
1137
|
+
count: z16.int().positive(),
|
|
1138
|
+
writer: z16.string().nullable(),
|
|
1139
|
+
counter: z16.int().nullable(),
|
|
1140
|
+
createdAt: z16.date()
|
|
1119
1141
|
});
|
|
1120
1142
|
|
|
1121
|
-
// src/logged-input-schema.ts
|
|
1122
|
-
import { z as
|
|
1123
|
-
var loggedInputSchema =
|
|
1124
|
-
inputID:
|
|
1125
|
-
captureID:
|
|
1126
|
-
taskID:
|
|
1127
|
-
stepRunID:
|
|
1128
|
-
writer:
|
|
1129
|
-
counter:
|
|
1130
|
-
role:
|
|
1131
|
-
profile:
|
|
1132
|
-
model:
|
|
1133
|
-
harness:
|
|
1134
|
-
api:
|
|
1135
|
-
endpoint:
|
|
1136
|
-
route:
|
|
1137
|
-
isRewritten:
|
|
1138
|
-
upstreamStatus:
|
|
1139
|
-
bytes:
|
|
1140
|
-
intakeSequence:
|
|
1141
|
-
receivedAt:
|
|
1142
|
-
takenAt:
|
|
1143
|
-
state:
|
|
1144
|
-
removedCause:
|
|
1143
|
+
// src/contract/logged-input-schema.ts
|
|
1144
|
+
import { z as z17 } from "zod";
|
|
1145
|
+
var loggedInputSchema = z17.object({
|
|
1146
|
+
inputID: z17.string(),
|
|
1147
|
+
captureID: z17.string(),
|
|
1148
|
+
taskID: z17.string(),
|
|
1149
|
+
stepRunID: z17.string(),
|
|
1150
|
+
writer: z17.string(),
|
|
1151
|
+
counter: z17.int(),
|
|
1152
|
+
role: z17.string(),
|
|
1153
|
+
profile: z17.string(),
|
|
1154
|
+
model: z17.string(),
|
|
1155
|
+
harness: z17.string(),
|
|
1156
|
+
api: z17.string(),
|
|
1157
|
+
endpoint: z17.string(),
|
|
1158
|
+
route: z17.string(),
|
|
1159
|
+
isRewritten: z17.boolean(),
|
|
1160
|
+
upstreamStatus: z17.int(),
|
|
1161
|
+
bytes: z17.int(),
|
|
1162
|
+
intakeSequence: z17.int(),
|
|
1163
|
+
receivedAt: z17.date(),
|
|
1164
|
+
takenAt: z17.date(),
|
|
1165
|
+
state: z17.enum(["writing", "stored", "missing", "removed"]),
|
|
1166
|
+
removedCause: z17.enum(["retention_days", "retention_bytes", "forget", "dropped", "restore", "reset"]).nullable()
|
|
1145
1167
|
});
|
|
1146
1168
|
|
|
1147
|
-
// src/turn-inputs-contract.ts
|
|
1148
|
-
var turnInputOn =
|
|
1149
|
-
state:
|
|
1150
|
-
forMs:
|
|
1169
|
+
// src/contract/turn-inputs-contract.ts
|
|
1170
|
+
var turnInputOn = z18.strictObject({
|
|
1171
|
+
state: z18.literal("on"),
|
|
1172
|
+
forMs: z18.int().positive().nullable()
|
|
1151
1173
|
});
|
|
1152
|
-
var turnInputOff =
|
|
1153
|
-
var turnInputSetSchema =
|
|
1174
|
+
var turnInputOff = z18.strictObject({ state: z18.literal("off"), drop: z18.boolean() });
|
|
1175
|
+
var turnInputSetSchema = z18.discriminatedUnion("state", [turnInputOn, turnInputOff]);
|
|
1154
1176
|
var turnInputs = oc3.errors({
|
|
1155
1177
|
NOT_FOUND: { message: "no logged request has that ID", status: 404 },
|
|
1156
1178
|
REMOVED: { message: "that request is removed or its body is missing", status: 410 },
|
|
@@ -1160,27 +1182,27 @@ var turnInputs = oc3.errors({
|
|
|
1160
1182
|
},
|
|
1161
1183
|
NOT_CONFIGURED: { message: "the turn-input log is not configured", status: 409 }
|
|
1162
1184
|
});
|
|
1163
|
-
var listedInputsSchema =
|
|
1164
|
-
inputs:
|
|
1165
|
-
misses:
|
|
1185
|
+
var listedInputsSchema = z18.object({
|
|
1186
|
+
inputs: z18.array(loggedInputSchema),
|
|
1187
|
+
misses: z18.array(inputMissSchema)
|
|
1166
1188
|
});
|
|
1167
1189
|
var turnInputsContract = {
|
|
1168
|
-
list: turnInputs.input(
|
|
1169
|
-
open: turnInputs.input(
|
|
1170
|
-
set: turnInputs.input(turnInputSetSchema).output(
|
|
1190
|
+
list: turnInputs.input(z18.strictObject({ limit: z18.int().positive().max(500).default(50) })).output(listedInputsSchema),
|
|
1191
|
+
open: turnInputs.input(z18.strictObject({ inputID: z18.string().min(1) })).output(z18.object({ inputID: z18.string(), body: z18.base64() })),
|
|
1192
|
+
set: turnInputs.input(turnInputSetSchema).output(z18.object({ state: z18.enum(["on", "off"]), until: z18.number().nullable() }))
|
|
1171
1193
|
};
|
|
1172
1194
|
|
|
1173
|
-
// src/host-contract.ts
|
|
1174
|
-
var versionRefSchema2 =
|
|
1175
|
-
var versionTargetSchema2 =
|
|
1176
|
-
itemID:
|
|
1177
|
-
version:
|
|
1178
|
-
});
|
|
1179
|
-
var
|
|
1180
|
-
var proposalOriginSchema2 =
|
|
1181
|
-
var memoryOriginSchema =
|
|
1182
|
-
var contentSourceSchema =
|
|
1183
|
-
var reviewReasonSchema2 =
|
|
1195
|
+
// src/contract/host-contract.ts
|
|
1196
|
+
var versionRefSchema2 = z19.object({ itemID: z19.string(), version: z19.int().positive() });
|
|
1197
|
+
var versionTargetSchema2 = z19.strictObject({
|
|
1198
|
+
itemID: z19.string().min(1),
|
|
1199
|
+
version: z19.int().positive()
|
|
1200
|
+
});
|
|
1201
|
+
var itemTextSchema = z19.string().max(2000).regex(/\S/u);
|
|
1202
|
+
var proposalOriginSchema2 = z19.enum(["owner", "conversation", "task", "memory_writer"]);
|
|
1203
|
+
var memoryOriginSchema = z19.enum([...proposalOriginSchema2.options, "lapse"]);
|
|
1204
|
+
var contentSourceSchema = z19.enum(["owner", "owner_data", "untrusted"]);
|
|
1205
|
+
var reviewReasonSchema2 = z19.enum([
|
|
1184
1206
|
"no_quote",
|
|
1185
1207
|
"quote_not_typed",
|
|
1186
1208
|
"quote_in_quoted_block",
|
|
@@ -1196,107 +1218,108 @@ var reviewReasonSchema2 = z18.enum([
|
|
|
1196
1218
|
"self_note",
|
|
1197
1219
|
"from_photo",
|
|
1198
1220
|
"sensitive",
|
|
1199
|
-
"subject_change"
|
|
1221
|
+
"subject_change",
|
|
1222
|
+
"ask_rule"
|
|
1200
1223
|
]);
|
|
1201
|
-
var proposalSourceSchema2 =
|
|
1224
|
+
var proposalSourceSchema2 = z19.object({
|
|
1202
1225
|
origin: proposalOriginSchema2,
|
|
1203
|
-
thread:
|
|
1204
|
-
proposedAt:
|
|
1205
|
-
});
|
|
1206
|
-
var pendingProposalSchema =
|
|
1207
|
-
proposalID:
|
|
1208
|
-
operation:
|
|
1209
|
-
itemID:
|
|
1210
|
-
targetVersion:
|
|
1211
|
-
isPinned:
|
|
1212
|
-
subject:
|
|
1213
|
-
newSubject:
|
|
1214
|
-
isSensitive:
|
|
1215
|
-
kind:
|
|
1226
|
+
thread: z19.string().nullable(),
|
|
1227
|
+
proposedAt: z19.date()
|
|
1228
|
+
});
|
|
1229
|
+
var pendingProposalSchema = z19.object({
|
|
1230
|
+
proposalID: z19.string(),
|
|
1231
|
+
operation: z19.enum(["remember", "retire", "pin"]),
|
|
1232
|
+
itemID: z19.string(),
|
|
1233
|
+
targetVersion: z19.int().nullable(),
|
|
1234
|
+
isPinned: z19.boolean(),
|
|
1235
|
+
subject: z19.enum(["owner", "self", "shared"]),
|
|
1236
|
+
newSubject: z19.enum(["owner", "self", "shared"]).nullable(),
|
|
1237
|
+
isSensitive: z19.boolean(),
|
|
1238
|
+
kind: z19.enum(["fact", "self"]),
|
|
1216
1239
|
reason: reviewReasonSchema2,
|
|
1217
|
-
actionHash:
|
|
1240
|
+
actionHash: z19.string(),
|
|
1218
1241
|
origin: proposalOriginSchema2,
|
|
1219
1242
|
source: contentSourceSchema,
|
|
1220
|
-
createdAt:
|
|
1221
|
-
lapseAt:
|
|
1222
|
-
sources:
|
|
1223
|
-
text:
|
|
1224
|
-
quote:
|
|
1225
|
-
});
|
|
1226
|
-
var
|
|
1227
|
-
var approvalResultSchema =
|
|
1228
|
-
|
|
1229
|
-
|
|
1243
|
+
createdAt: z19.date(),
|
|
1244
|
+
lapseAt: z19.date(),
|
|
1245
|
+
sources: z19.array(proposalSourceSchema2),
|
|
1246
|
+
text: z19.string(),
|
|
1247
|
+
quote: z19.string().nullable()
|
|
1248
|
+
});
|
|
1249
|
+
var closeMatchSchema2 = z19.object({ itemID: z19.string(), version: z19.int(), text: z19.string() });
|
|
1250
|
+
var approvalResultSchema = z19.discriminatedUnion("status", [
|
|
1251
|
+
z19.object({ status: z19.literal("applied"), itemID: z19.string(), version: z19.int() }),
|
|
1252
|
+
z19.object({ status: z19.literal("close_match"), item: closeMatchSchema2 })
|
|
1230
1253
|
]);
|
|
1231
|
-
var historyVersionSchema =
|
|
1232
|
-
version:
|
|
1233
|
-
change:
|
|
1234
|
-
state:
|
|
1254
|
+
var historyVersionSchema = z19.object({
|
|
1255
|
+
version: z19.int(),
|
|
1256
|
+
change: z19.enum(["created", "edited", "retired", "restored", "undone"]),
|
|
1257
|
+
state: z19.enum(["active", "retired"]),
|
|
1235
1258
|
origin: memoryOriginSchema,
|
|
1236
1259
|
source: contentSourceSchema,
|
|
1237
|
-
recordedAt:
|
|
1238
|
-
status:
|
|
1239
|
-
text:
|
|
1240
|
-
});
|
|
1241
|
-
var itemHistorySchema =
|
|
1242
|
-
itemID:
|
|
1243
|
-
subject:
|
|
1244
|
-
kind:
|
|
1245
|
-
state:
|
|
1246
|
-
versions:
|
|
1247
|
-
});
|
|
1248
|
-
var changeInputSchema =
|
|
1249
|
-
itemID:
|
|
1250
|
-
version:
|
|
1251
|
-
text:
|
|
1252
|
-
isCurrent:
|
|
1253
|
-
});
|
|
1254
|
-
var changeCommentSchema =
|
|
1255
|
-
var consolidationChangeSchema =
|
|
1256
|
-
changeID:
|
|
1257
|
-
shortID:
|
|
1258
|
-
kind:
|
|
1259
|
-
inputs:
|
|
1260
|
-
text:
|
|
1261
|
-
reason:
|
|
1260
|
+
recordedAt: z19.date(),
|
|
1261
|
+
status: z19.enum(["readable", "shredded", "unreadable"]),
|
|
1262
|
+
text: z19.string().nullable()
|
|
1263
|
+
});
|
|
1264
|
+
var itemHistorySchema = z19.object({
|
|
1265
|
+
itemID: z19.string(),
|
|
1266
|
+
subject: z19.enum(["owner", "self", "shared"]),
|
|
1267
|
+
kind: z19.enum(["fact", "self"]),
|
|
1268
|
+
state: z19.enum(["active", "retired", "forgetting", "forgotten"]),
|
|
1269
|
+
versions: z19.array(historyVersionSchema)
|
|
1270
|
+
});
|
|
1271
|
+
var changeInputSchema = z19.object({
|
|
1272
|
+
itemID: z19.string(),
|
|
1273
|
+
version: z19.int(),
|
|
1274
|
+
text: z19.string().nullable(),
|
|
1275
|
+
isCurrent: z19.boolean()
|
|
1276
|
+
});
|
|
1277
|
+
var changeCommentSchema = z19.object({ text: z19.string(), at: z19.date() });
|
|
1278
|
+
var consolidationChangeSchema = z19.object({
|
|
1279
|
+
changeID: z19.string(),
|
|
1280
|
+
shortID: z19.string(),
|
|
1281
|
+
kind: z19.enum(["merge", "rewrite", "retire"]),
|
|
1282
|
+
inputs: z19.array(changeInputSchema),
|
|
1283
|
+
text: z19.string().nullable(),
|
|
1284
|
+
reason: z19.string(),
|
|
1262
1285
|
source: contentSourceSchema,
|
|
1263
|
-
actionHash:
|
|
1264
|
-
lapseAt:
|
|
1286
|
+
actionHash: z19.string(),
|
|
1287
|
+
lapseAt: z19.date(),
|
|
1265
1288
|
comment: changeCommentSchema.nullable()
|
|
1266
1289
|
});
|
|
1267
|
-
var consolidationDiffSchema =
|
|
1268
|
-
diffID:
|
|
1269
|
-
model:
|
|
1270
|
-
createdAt:
|
|
1271
|
-
changes:
|
|
1272
|
-
summary:
|
|
1273
|
-
});
|
|
1274
|
-
var changeOutcomeSchema =
|
|
1275
|
-
|
|
1276
|
-
changeID:
|
|
1277
|
-
status:
|
|
1278
|
-
versions:
|
|
1290
|
+
var consolidationDiffSchema = z19.object({
|
|
1291
|
+
diffID: z19.string(),
|
|
1292
|
+
model: z19.string().nullable(),
|
|
1293
|
+
createdAt: z19.date(),
|
|
1294
|
+
changes: z19.array(consolidationChangeSchema),
|
|
1295
|
+
summary: z19.string().nullable()
|
|
1296
|
+
});
|
|
1297
|
+
var changeOutcomeSchema = z19.discriminatedUnion("status", [
|
|
1298
|
+
z19.object({
|
|
1299
|
+
changeID: z19.string(),
|
|
1300
|
+
status: z19.literal("applied"),
|
|
1301
|
+
versions: z19.array(versionRefSchema2)
|
|
1279
1302
|
}),
|
|
1280
|
-
|
|
1303
|
+
z19.object({ changeID: z19.string(), status: z19.literal("refused"), code: z19.string() })
|
|
1281
1304
|
]);
|
|
1282
|
-
var changeAnswerSchema =
|
|
1283
|
-
changeID:
|
|
1284
|
-
actionHash:
|
|
1305
|
+
var changeAnswerSchema = z19.strictObject({
|
|
1306
|
+
changeID: z19.string().min(1),
|
|
1307
|
+
actionHash: z19.string().min(1)
|
|
1285
1308
|
});
|
|
1286
|
-
var
|
|
1287
|
-
proposalID:
|
|
1288
|
-
actionHash:
|
|
1309
|
+
var proposalAnswerSchema = z19.strictObject({
|
|
1310
|
+
proposalID: z19.string().min(1),
|
|
1311
|
+
actionHash: z19.string().min(1)
|
|
1289
1312
|
});
|
|
1290
|
-
var hostSessionSchema =
|
|
1291
|
-
sessionID:
|
|
1292
|
-
deviceName:
|
|
1293
|
-
createdAt:
|
|
1294
|
-
lastUsedAt:
|
|
1313
|
+
var hostSessionSchema = z19.object({
|
|
1314
|
+
sessionID: z19.string(),
|
|
1315
|
+
deviceName: z19.string(),
|
|
1316
|
+
createdAt: z19.date(),
|
|
1317
|
+
lastUsedAt: z19.date()
|
|
1295
1318
|
});
|
|
1296
|
-
var subjectCountSchema =
|
|
1297
|
-
owner:
|
|
1298
|
-
shared:
|
|
1299
|
-
self:
|
|
1319
|
+
var subjectCountSchema = z19.object({
|
|
1320
|
+
owner: z19.int().nonnegative(),
|
|
1321
|
+
shared: z19.int().nonnegative(),
|
|
1322
|
+
self: z19.int().nonnegative()
|
|
1300
1323
|
});
|
|
1301
1324
|
var memory = oc4.errors({
|
|
1302
1325
|
MEMORY_NOT_STARTED: { message: "the memory store has not started yet", status: 503 },
|
|
@@ -1311,28 +1334,28 @@ var memory = oc4.errors({
|
|
|
1311
1334
|
PIN_EDIT: { message: "a pin takes no edited text", status: 400 },
|
|
1312
1335
|
SELF_NOTE_REFUSED: { message: "a self-note never takes that change", status: 409 }
|
|
1313
1336
|
});
|
|
1314
|
-
var skillFileSchema =
|
|
1315
|
-
var pendingSkillProposalSchema =
|
|
1316
|
-
proposalID:
|
|
1317
|
-
name:
|
|
1318
|
-
skillHash:
|
|
1319
|
-
baseHash:
|
|
1320
|
-
files:
|
|
1321
|
-
inForce:
|
|
1322
|
-
skillHash:
|
|
1323
|
-
origin:
|
|
1324
|
-
files:
|
|
1337
|
+
var skillFileSchema = z19.object({ path: z19.string(), text: z19.string() });
|
|
1338
|
+
var pendingSkillProposalSchema = z19.object({
|
|
1339
|
+
proposalID: z19.string(),
|
|
1340
|
+
name: z19.string(),
|
|
1341
|
+
skillHash: z19.string(),
|
|
1342
|
+
baseHash: z19.string().nullable(),
|
|
1343
|
+
files: z19.array(skillFileSchema),
|
|
1344
|
+
inForce: z19.object({
|
|
1345
|
+
skillHash: z19.string(),
|
|
1346
|
+
origin: z19.enum(["definitions", "vendored", "nixie"]),
|
|
1347
|
+
files: z19.array(skillFileSchema)
|
|
1325
1348
|
}).nullable(),
|
|
1326
|
-
untypedToken:
|
|
1327
|
-
thread:
|
|
1328
|
-
provenance:
|
|
1329
|
-
createdAt:
|
|
1330
|
-
lapseAt:
|
|
1331
|
-
isStale:
|
|
1349
|
+
untypedToken: z19.object({ kind: z19.string(), raw: z19.string() }).nullable(),
|
|
1350
|
+
thread: z19.string().nullable(),
|
|
1351
|
+
provenance: z19.object({ runID: z19.string(), callID: z19.string(), profile: z19.string() }),
|
|
1352
|
+
createdAt: z19.date(),
|
|
1353
|
+
lapseAt: z19.date(),
|
|
1354
|
+
isStale: z19.boolean()
|
|
1332
1355
|
});
|
|
1333
|
-
var skillAnswerSchema =
|
|
1334
|
-
proposalID:
|
|
1335
|
-
skillHash:
|
|
1356
|
+
var skillAnswerSchema = z19.strictObject({
|
|
1357
|
+
proposalID: z19.string().min(1),
|
|
1358
|
+
skillHash: z19.string().min(1)
|
|
1336
1359
|
});
|
|
1337
1360
|
var skills = oc4.errors({
|
|
1338
1361
|
NOT_FOUND: { message: "nothing has that ID", status: 404 },
|
|
@@ -1342,38 +1365,38 @@ var skills = oc4.errors({
|
|
|
1342
1365
|
SKILL_CHECK: { message: "the files fail the seed checks", status: 400 },
|
|
1343
1366
|
WRONG_STATE: { message: "the skill nixie wrote is no longer in force", status: 409 }
|
|
1344
1367
|
});
|
|
1345
|
-
var definitionsSkillSchema =
|
|
1346
|
-
var writtenSkillSchema =
|
|
1347
|
-
approvalID:
|
|
1348
|
-
proposalID:
|
|
1349
|
-
name:
|
|
1350
|
-
skillHash:
|
|
1368
|
+
var definitionsSkillSchema = z19.object({ skillHash: z19.string(), origin: z19.enum(["definitions", "vendored"]) }).nullable();
|
|
1369
|
+
var writtenSkillSchema = z19.object({
|
|
1370
|
+
approvalID: z19.string(),
|
|
1371
|
+
proposalID: z19.string(),
|
|
1372
|
+
name: z19.string(),
|
|
1373
|
+
skillHash: z19.string(),
|
|
1351
1374
|
base: definitionsSkillSchema,
|
|
1352
1375
|
definitions: definitionsSkillSchema,
|
|
1353
|
-
isConflict:
|
|
1354
|
-
pullRequestURL:
|
|
1355
|
-
approvedAt:
|
|
1356
|
-
});
|
|
1357
|
-
var promptPartFileSchema =
|
|
1358
|
-
var promptEntrySchema =
|
|
1359
|
-
var pendingPromptProposalSchema =
|
|
1360
|
-
proposalID:
|
|
1361
|
-
promptID:
|
|
1362
|
-
proposalHash:
|
|
1363
|
-
baseHash:
|
|
1376
|
+
isConflict: z19.boolean(),
|
|
1377
|
+
pullRequestURL: z19.url().nullable(),
|
|
1378
|
+
approvedAt: z19.date()
|
|
1379
|
+
});
|
|
1380
|
+
var promptPartFileSchema = z19.object({ path: z19.string(), text: z19.string() });
|
|
1381
|
+
var promptEntrySchema = z19.record(z19.string(), z19.string());
|
|
1382
|
+
var pendingPromptProposalSchema = z19.object({
|
|
1383
|
+
proposalID: z19.string(),
|
|
1384
|
+
promptID: z19.string(),
|
|
1385
|
+
proposalHash: z19.string(),
|
|
1386
|
+
baseHash: z19.string().nullable(),
|
|
1364
1387
|
entry: promptEntrySchema,
|
|
1365
|
-
files:
|
|
1366
|
-
reason:
|
|
1367
|
-
inForce:
|
|
1368
|
-
thread:
|
|
1369
|
-
provenance:
|
|
1370
|
-
createdAt:
|
|
1371
|
-
lapseAt:
|
|
1372
|
-
isStale:
|
|
1373
|
-
});
|
|
1374
|
-
var promptAnswerSchema =
|
|
1375
|
-
proposalID:
|
|
1376
|
-
proposalHash:
|
|
1388
|
+
files: z19.array(promptPartFileSchema),
|
|
1389
|
+
reason: z19.string(),
|
|
1390
|
+
inForce: z19.object({ parts: promptEntrySchema, template: z19.string().nullable() }).nullable(),
|
|
1391
|
+
thread: z19.string().nullable(),
|
|
1392
|
+
provenance: z19.object({ runID: z19.string(), callID: z19.string(), profile: z19.string() }),
|
|
1393
|
+
createdAt: z19.date(),
|
|
1394
|
+
lapseAt: z19.date(),
|
|
1395
|
+
isStale: z19.boolean()
|
|
1396
|
+
});
|
|
1397
|
+
var promptAnswerSchema = z19.strictObject({
|
|
1398
|
+
proposalID: z19.string().min(1),
|
|
1399
|
+
proposalHash: z19.string().min(1)
|
|
1377
1400
|
});
|
|
1378
1401
|
var prompts = oc4.errors({
|
|
1379
1402
|
NOT_FOUND: { message: "nothing has that ID", status: 404 },
|
|
@@ -1382,49 +1405,49 @@ var prompts = oc4.errors({
|
|
|
1382
1405
|
STALE_BASE: { message: "the override in force moved past the proposal", status: 409 },
|
|
1383
1406
|
PROMPT_CHECK: { message: "the override fails the definitions checks", status: 400 }
|
|
1384
1407
|
});
|
|
1385
|
-
var
|
|
1386
|
-
var ruleInForceSchema =
|
|
1387
|
-
ruleID:
|
|
1388
|
-
revision:
|
|
1389
|
-
ruleHash:
|
|
1390
|
-
sentence:
|
|
1391
|
-
origin:
|
|
1392
|
-
changeID:
|
|
1393
|
-
lastFiredAt:
|
|
1394
|
-
});
|
|
1395
|
-
var ruleConflictSchema =
|
|
1396
|
-
ruleID:
|
|
1397
|
-
changeID:
|
|
1398
|
-
nixie:
|
|
1399
|
-
repo:
|
|
1400
|
-
base:
|
|
1401
|
-
changedBy:
|
|
1402
|
-
reason:
|
|
1403
|
-
changedAt:
|
|
1404
|
-
});
|
|
1405
|
-
var ruleProposalChangeSchema =
|
|
1406
|
-
ruleID:
|
|
1407
|
-
before:
|
|
1408
|
-
after:
|
|
1409
|
-
});
|
|
1410
|
-
var
|
|
1411
|
-
tool:
|
|
1412
|
-
remove:
|
|
1413
|
-
sentence:
|
|
1414
|
-
});
|
|
1415
|
-
var pendingRuleProposalSchema =
|
|
1416
|
-
proposalID:
|
|
1417
|
-
changes:
|
|
1418
|
-
effectChanges:
|
|
1419
|
-
createdAt:
|
|
1420
|
-
lapseAt:
|
|
1421
|
-
});
|
|
1422
|
-
var ruleProposalAnswerSchema =
|
|
1408
|
+
var ruleVersionSchema = z19.object({ ruleHash: z19.string(), sentence: z19.string() }).nullable();
|
|
1409
|
+
var ruleInForceSchema = z19.object({
|
|
1410
|
+
ruleID: z19.string(),
|
|
1411
|
+
revision: z19.int().positive(),
|
|
1412
|
+
ruleHash: z19.string(),
|
|
1413
|
+
sentence: z19.string(),
|
|
1414
|
+
origin: z19.enum(["definitions", "nixie"]),
|
|
1415
|
+
changeID: z19.string().nullable(),
|
|
1416
|
+
lastFiredAt: z19.date().nullable()
|
|
1417
|
+
});
|
|
1418
|
+
var ruleConflictSchema = z19.object({
|
|
1419
|
+
ruleID: z19.string(),
|
|
1420
|
+
changeID: z19.string(),
|
|
1421
|
+
nixie: ruleVersionSchema,
|
|
1422
|
+
repo: ruleVersionSchema,
|
|
1423
|
+
base: ruleVersionSchema,
|
|
1424
|
+
changedBy: z19.enum(["owner", "nixie"]),
|
|
1425
|
+
reason: z19.string(),
|
|
1426
|
+
changedAt: z19.date()
|
|
1427
|
+
});
|
|
1428
|
+
var ruleProposalChangeSchema = z19.object({
|
|
1429
|
+
ruleID: z19.string(),
|
|
1430
|
+
before: ruleVersionSchema,
|
|
1431
|
+
after: ruleVersionSchema
|
|
1432
|
+
});
|
|
1433
|
+
var effectChangeSchema = z19.object({
|
|
1434
|
+
tool: z19.string(),
|
|
1435
|
+
remove: z19.array(z19.string()),
|
|
1436
|
+
sentence: z19.string()
|
|
1437
|
+
});
|
|
1438
|
+
var pendingRuleProposalSchema = z19.object({
|
|
1439
|
+
proposalID: z19.string(),
|
|
1440
|
+
changes: z19.array(ruleProposalChangeSchema),
|
|
1441
|
+
effectChanges: z19.array(effectChangeSchema),
|
|
1442
|
+
createdAt: z19.date(),
|
|
1443
|
+
lapseAt: z19.date()
|
|
1444
|
+
});
|
|
1445
|
+
var ruleProposalAnswerSchema = z19.strictObject({ proposalID: z19.string().min(1) });
|
|
1423
1446
|
var ruleProposalRejectionSchema = ruleProposalAnswerSchema.extend({
|
|
1424
|
-
reason:
|
|
1447
|
+
reason: z19.string().max(500).regex(/\S/u)
|
|
1425
1448
|
});
|
|
1426
1449
|
var actionRejectionSchema = ruleProposalAnswerSchema.extend({
|
|
1427
|
-
reason:
|
|
1450
|
+
reason: z19.string().max(500).regex(/\S/u).optional()
|
|
1428
1451
|
});
|
|
1429
1452
|
var ruleProposalErrors = {
|
|
1430
1453
|
NOT_FOUND: { message: "nothing has that ID", status: 404 },
|
|
@@ -1434,11 +1457,11 @@ var rules = oc4.errors(ruleProposalErrors);
|
|
|
1434
1457
|
var contacts = oc4.errors({
|
|
1435
1458
|
NOT_FOUND: { message: "no known contact has that ID", status: 404 }
|
|
1436
1459
|
});
|
|
1437
|
-
var forgottenItemsSchema =
|
|
1438
|
-
itemIDs:
|
|
1460
|
+
var forgottenItemsSchema = z19.object({
|
|
1461
|
+
itemIDs: z19.array(z19.string()),
|
|
1439
1462
|
backup: forgetBackupSchema
|
|
1440
1463
|
});
|
|
1441
|
-
var hostTaskStateSchema =
|
|
1464
|
+
var hostTaskStateSchema = z19.enum([
|
|
1442
1465
|
"ready",
|
|
1443
1466
|
"running",
|
|
1444
1467
|
"waiting",
|
|
@@ -1454,23 +1477,30 @@ var taskControl2 = oc4.errors({
|
|
|
1454
1477
|
message: "the task is in a state that does not take this control",
|
|
1455
1478
|
status: 409
|
|
1456
1479
|
}
|
|
1457
|
-
}).input(
|
|
1458
|
-
taskID:
|
|
1480
|
+
}).input(z19.strictObject({ taskID: z19.string().min(1) })).output(z19.object({
|
|
1481
|
+
taskID: z19.string(),
|
|
1459
1482
|
state: hostTaskStateSchema,
|
|
1460
|
-
isPauseRequested:
|
|
1483
|
+
isPauseRequested: z19.boolean()
|
|
1461
1484
|
}));
|
|
1462
1485
|
var hostContract = {
|
|
1463
|
-
reset: oc4.output(
|
|
1464
|
-
resetAt:
|
|
1465
|
-
lastSequence:
|
|
1466
|
-
keptSessions:
|
|
1486
|
+
reset: oc4.output(z19.object({
|
|
1487
|
+
resetAt: z19.date(),
|
|
1488
|
+
lastSequence: z19.int().nonnegative(),
|
|
1489
|
+
keptSessions: z19.int().nonnegative()
|
|
1467
1490
|
})),
|
|
1468
|
-
resetConversations: oc4.output(
|
|
1469
|
-
resetAt:
|
|
1470
|
-
lastSequence:
|
|
1471
|
-
shreddedRecords:
|
|
1491
|
+
resetConversations: oc4.output(z19.object({
|
|
1492
|
+
resetAt: z19.date(),
|
|
1493
|
+
lastSequence: z19.int().nonnegative(),
|
|
1494
|
+
shreddedRecords: z19.int().nonnegative(),
|
|
1472
1495
|
backup: forgetBackupSchema
|
|
1473
1496
|
})),
|
|
1497
|
+
nixie: {
|
|
1498
|
+
pause: oc4.output(z19.object({ paused: pauseStateSchema })),
|
|
1499
|
+
resume: oc4.output(z19.object({ paused: pauseStateSchema }))
|
|
1500
|
+
},
|
|
1501
|
+
recovery: {
|
|
1502
|
+
read: oc4.output(z19.object({ recovery: recoverySchema }))
|
|
1503
|
+
},
|
|
1474
1504
|
tasks: {
|
|
1475
1505
|
pause: taskControl2,
|
|
1476
1506
|
resume: taskControl2,
|
|
@@ -1484,109 +1514,109 @@ var hostContract = {
|
|
|
1484
1514
|
TASK_NOT_FOUND: { message: "no task has that ID", status: 404 },
|
|
1485
1515
|
TASK_NOT_AT_LIMIT: { message: "the task is not paused at its limit", status: 409 },
|
|
1486
1516
|
LIMIT_NOT_RAISED: { message: "the new limits are not above the old ones", status: 409 }
|
|
1487
|
-
}).input(
|
|
1488
|
-
taskID:
|
|
1489
|
-
turns:
|
|
1490
|
-
dollars:
|
|
1517
|
+
}).input(z19.strictObject({
|
|
1518
|
+
taskID: z19.string().min(1),
|
|
1519
|
+
turns: z19.int().positive().optional(),
|
|
1520
|
+
dollars: z19.number().positive().optional()
|
|
1491
1521
|
}).refine((input) => input.turns !== undefined || input.dollars !== undefined, {
|
|
1492
1522
|
message: "a raise sets turns, dollars or both"
|
|
1493
|
-
})).output(
|
|
1494
|
-
taskID:
|
|
1523
|
+
})).output(z19.object({
|
|
1524
|
+
taskID: z19.string(),
|
|
1495
1525
|
state: hostTaskStateSchema,
|
|
1496
|
-
isPauseRequested:
|
|
1497
|
-
turns:
|
|
1498
|
-
dollars:
|
|
1526
|
+
isPauseRequested: z19.boolean(),
|
|
1527
|
+
turns: z19.int().positive(),
|
|
1528
|
+
dollars: z19.number().positive()
|
|
1499
1529
|
}))
|
|
1500
1530
|
},
|
|
1501
1531
|
sessions: {
|
|
1502
|
-
issueCode: oc4.output(
|
|
1503
|
-
list: oc4.output(
|
|
1532
|
+
issueCode: oc4.output(z19.object({ code: z19.string(), expiresAt: z19.date() })),
|
|
1533
|
+
list: oc4.output(z19.array(hostSessionSchema)),
|
|
1504
1534
|
label: oc4.errors({
|
|
1505
1535
|
SESSION_NOT_FOUND: {
|
|
1506
1536
|
message: "no device session that is still signed in has that ID",
|
|
1507
1537
|
status: 404
|
|
1508
1538
|
},
|
|
1509
1539
|
LABEL_INVALID: { message: "a label holds 1 to 100 characters besides spaces", status: 400 }
|
|
1510
|
-
}).input(
|
|
1540
|
+
}).input(z19.strictObject({ sessionID: z19.string().min(1), label: z19.string() })).output(z19.object({ sessionID: z19.string(), label: z19.string() }))
|
|
1511
1541
|
},
|
|
1512
1542
|
memory: {
|
|
1513
1543
|
proposals: {
|
|
1514
|
-
list: memory.output(
|
|
1515
|
-
approve: memory.input(
|
|
1544
|
+
list: memory.output(z19.array(pendingProposalSchema)),
|
|
1545
|
+
approve: memory.input(proposalAnswerSchema.extend({
|
|
1516
1546
|
revisionOf: versionTargetSchema2.optional(),
|
|
1517
|
-
ignoreCloseMatch:
|
|
1518
|
-
editedText:
|
|
1547
|
+
ignoreCloseMatch: z19.boolean().optional(),
|
|
1548
|
+
editedText: itemTextSchema.optional()
|
|
1519
1549
|
})).output(approvalResultSchema),
|
|
1520
|
-
reject: memory.input(
|
|
1550
|
+
reject: memory.input(proposalAnswerSchema.extend({ reason: z19.string().max(500).regex(/\S/u).optional() })).output(z19.object({ proposalID: z19.string() }))
|
|
1521
1551
|
},
|
|
1522
|
-
subjects: memory.output(
|
|
1552
|
+
subjects: memory.output(z19.object({ items: subjectCountSchema, proposals: subjectCountSchema })),
|
|
1523
1553
|
items: {
|
|
1524
|
-
read: memory.input(
|
|
1525
|
-
edit: memory.input(versionTargetSchema2.extend({ text:
|
|
1554
|
+
read: memory.input(z19.strictObject({ itemID: z19.string().min(1) })).output(itemHistorySchema),
|
|
1555
|
+
edit: memory.input(versionTargetSchema2.extend({ text: itemTextSchema })).output(versionRefSchema2),
|
|
1526
1556
|
retire: memory.input(versionTargetSchema2).output(versionRefSchema2),
|
|
1527
1557
|
restore: memory.input(versionTargetSchema2).output(versionRefSchema2),
|
|
1528
|
-
forget: memory.input(versionTargetSchema2).output(
|
|
1558
|
+
forget: memory.input(versionTargetSchema2).output(z19.object({ itemID: z19.string(), backup: forgetBackupSchema })),
|
|
1529
1559
|
forgetAll: memory.output(forgottenItemsSchema),
|
|
1530
|
-
pin: memory.input(
|
|
1560
|
+
pin: memory.input(z19.strictObject({ itemID: z19.string().min(1), isPinned: z19.boolean() })).output(z19.object({ itemID: z19.string(), isPinned: z19.boolean() }))
|
|
1531
1561
|
},
|
|
1532
1562
|
consolidation: {
|
|
1533
1563
|
read: memory.output(consolidationDiffSchema.nullable()),
|
|
1534
|
-
approve: memory.input(
|
|
1535
|
-
reject: memory.input(changeAnswerSchema).output(
|
|
1564
|
+
approve: memory.input(z19.strictObject({ answers: z19.array(changeAnswerSchema).min(1).max(30) })).output(z19.object({ outcomes: z19.array(changeOutcomeSchema) })),
|
|
1565
|
+
reject: memory.input(changeAnswerSchema).output(z19.object({ changeID: z19.string() }))
|
|
1536
1566
|
}
|
|
1537
1567
|
},
|
|
1538
1568
|
skills: {
|
|
1539
1569
|
proposals: {
|
|
1540
|
-
list: skills.output(
|
|
1541
|
-
approve: skills.input(skillAnswerSchema.extend({ files:
|
|
1542
|
-
reject: skills.input(skillAnswerSchema.extend({ reason:
|
|
1570
|
+
list: skills.output(z19.array(pendingSkillProposalSchema)),
|
|
1571
|
+
approve: skills.input(skillAnswerSchema.extend({ files: z19.array(skillFileSchema).min(1).optional() })).output(z19.object({ proposalID: z19.string(), approvalID: z19.string(), skillHash: z19.string() })),
|
|
1572
|
+
reject: skills.input(skillAnswerSchema.extend({ reason: z19.string().max(500).regex(/\S/u) })).output(z19.object({ proposalID: z19.string() }))
|
|
1543
1573
|
},
|
|
1544
1574
|
written: {
|
|
1545
|
-
list: skills.output(
|
|
1546
|
-
resolve: skills.input(
|
|
1547
|
-
approvalID:
|
|
1548
|
-
keep:
|
|
1549
|
-
})).output(
|
|
1575
|
+
list: skills.output(z19.array(writtenSkillSchema)),
|
|
1576
|
+
resolve: skills.input(z19.strictObject({
|
|
1577
|
+
approvalID: z19.string().min(1),
|
|
1578
|
+
keep: z19.enum(["nixie", "definitions"])
|
|
1579
|
+
})).output(z19.object({ approvalID: z19.string(), keep: z19.enum(["nixie", "definitions"]) }))
|
|
1550
1580
|
}
|
|
1551
1581
|
},
|
|
1552
1582
|
rules: {
|
|
1553
|
-
list: rules.output(
|
|
1554
|
-
conflicts: rules.output(
|
|
1555
|
-
resolve: rules.input(
|
|
1583
|
+
list: rules.output(z19.array(ruleInForceSchema)),
|
|
1584
|
+
conflicts: rules.output(z19.array(ruleConflictSchema)),
|
|
1585
|
+
resolve: rules.input(z19.strictObject({ ruleID: z19.string().min(1), keep: z19.enum(["nixie", "repo"]) })).output(z19.object({ ruleID: z19.string(), changeID: z19.string(), keep: z19.enum(["nixie", "repo"]) })),
|
|
1556
1586
|
proposals: {
|
|
1557
|
-
list: rules.output(
|
|
1558
|
-
approve: rules.input(ruleProposalAnswerSchema).output(
|
|
1559
|
-
reject: rules.input(ruleProposalRejectionSchema).output(
|
|
1587
|
+
list: rules.output(z19.array(pendingRuleProposalSchema)),
|
|
1588
|
+
approve: rules.input(ruleProposalAnswerSchema).output(z19.object({ proposalID: z19.string() })),
|
|
1589
|
+
reject: rules.input(ruleProposalRejectionSchema).output(z19.object({ proposalID: z19.string() }))
|
|
1560
1590
|
}
|
|
1561
1591
|
},
|
|
1562
1592
|
actions: {
|
|
1563
1593
|
proposals: {
|
|
1564
|
-
list: rules.output(
|
|
1565
|
-
approve: rules.input(ruleProposalAnswerSchema).output(
|
|
1566
|
-
reject: rules.input(actionRejectionSchema).output(
|
|
1594
|
+
list: rules.output(z19.array(actionProposalSchema)),
|
|
1595
|
+
approve: rules.input(ruleProposalAnswerSchema).output(z19.object({ proposalID: z19.string() })),
|
|
1596
|
+
reject: rules.input(actionRejectionSchema).output(z19.object({ proposalID: z19.string() }))
|
|
1567
1597
|
}
|
|
1568
1598
|
},
|
|
1569
1599
|
contacts: {
|
|
1570
|
-
list: contacts.output(
|
|
1571
|
-
markKnown: contacts.input(
|
|
1572
|
-
destination:
|
|
1573
|
-
name:
|
|
1574
|
-
})).output(
|
|
1575
|
-
unmark: contacts.input(
|
|
1600
|
+
list: contacts.output(z19.array(knownContactSchema)),
|
|
1601
|
+
markKnown: contacts.input(z19.strictObject({
|
|
1602
|
+
destination: z19.string().min(1).max(500),
|
|
1603
|
+
name: z19.string().min(1).max(200).optional()
|
|
1604
|
+
})).output(z19.object({ contact: knownContactSchema, isNew: z19.boolean() })),
|
|
1605
|
+
unmark: contacts.input(z19.strictObject({ contactID: z19.string().min(1) })).output(z19.object({ contactID: z19.string() }))
|
|
1576
1606
|
},
|
|
1577
1607
|
turnInputs: turnInputsContract,
|
|
1578
1608
|
prompts: {
|
|
1579
1609
|
proposals: {
|
|
1580
|
-
list: prompts.output(
|
|
1610
|
+
list: prompts.output(z19.array(pendingPromptProposalSchema)),
|
|
1581
1611
|
approve: prompts.input(promptAnswerSchema.extend({
|
|
1582
1612
|
entry: promptEntrySchema.optional(),
|
|
1583
|
-
files:
|
|
1584
|
-
})).output(
|
|
1585
|
-
reject: prompts.input(promptAnswerSchema.extend({ reason:
|
|
1613
|
+
files: z19.array(promptPartFileSchema).optional()
|
|
1614
|
+
})).output(z19.object({ proposalID: z19.string(), approvalID: z19.string(), proposalHash: z19.string() })),
|
|
1615
|
+
reject: prompts.input(promptAnswerSchema.extend({ reason: z19.string().max(500).regex(/\S/u) })).output(z19.object({ proposalID: z19.string() }))
|
|
1586
1616
|
}
|
|
1587
1617
|
}
|
|
1588
1618
|
};
|
|
1589
|
-
// src/is-time-zone.ts
|
|
1619
|
+
// src/contract/is-time-zone.ts
|
|
1590
1620
|
function isTimeZone(zone) {
|
|
1591
1621
|
try {
|
|
1592
1622
|
return new Intl.DateTimeFormat("en-US", { timeZone: zone }).resolvedOptions().timeZone !== "";
|
|
@@ -1594,21 +1624,21 @@ function isTimeZone(zone) {
|
|
|
1594
1624
|
return false;
|
|
1595
1625
|
}
|
|
1596
1626
|
}
|
|
1597
|
-
// src/session-cookie-name.ts
|
|
1627
|
+
// src/contract/session-cookie-name.ts
|
|
1598
1628
|
var sessionCookieName = "nixie_session";
|
|
1599
1629
|
|
|
1600
|
-
// src/render-session-cookie.ts
|
|
1630
|
+
// src/contract/render-session-cookie.ts
|
|
1601
1631
|
var MAX_AGE_S = 400 * 24 * 60 * 60;
|
|
1602
1632
|
function renderSessionCookie(token) {
|
|
1603
1633
|
const maxAgeS = token === null ? 0 : MAX_AGE_S;
|
|
1604
1634
|
return `${sessionCookieName}=${token ?? ""}; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=${maxAgeS}`;
|
|
1605
1635
|
}
|
|
1606
|
-
// src/task-message-input-schema.ts
|
|
1607
|
-
import { z as
|
|
1636
|
+
// src/message/task-message-input-schema.ts
|
|
1637
|
+
import { z as z21 } from "zod";
|
|
1608
1638
|
|
|
1609
|
-
// src/task-message-kind-schema.ts
|
|
1610
|
-
import { z as
|
|
1611
|
-
var taskMessageKindSchema =
|
|
1639
|
+
// src/message/task-message-kind-schema.ts
|
|
1640
|
+
import { z as z20 } from "zod";
|
|
1641
|
+
var taskMessageKindSchema = z20.enum([
|
|
1612
1642
|
"progress",
|
|
1613
1643
|
"question",
|
|
1614
1644
|
"request",
|
|
@@ -1617,22 +1647,22 @@ var taskMessageKindSchema = z19.enum([
|
|
|
1617
1647
|
"chat"
|
|
1618
1648
|
]);
|
|
1619
1649
|
|
|
1620
|
-
// src/task-message-input-schema.ts
|
|
1621
|
-
var taskMessageInputSchema =
|
|
1622
|
-
to:
|
|
1650
|
+
// src/message/task-message-input-schema.ts
|
|
1651
|
+
var taskMessageInputSchema = z21.object({
|
|
1652
|
+
to: z21.string(),
|
|
1623
1653
|
kind: taskMessageKindSchema,
|
|
1624
|
-
body:
|
|
1625
|
-
replyTo:
|
|
1626
|
-
onBehalfOf:
|
|
1627
|
-
wake:
|
|
1628
|
-
});
|
|
1629
|
-
// src/task-message-result-schema.ts
|
|
1630
|
-
import { z as
|
|
1631
|
-
var taskMessageResultSchema =
|
|
1632
|
-
messageID:
|
|
1633
|
-
woke:
|
|
1634
|
-
hop:
|
|
1635
|
-
note:
|
|
1654
|
+
body: z21.string(),
|
|
1655
|
+
replyTo: z21.string().optional(),
|
|
1656
|
+
onBehalfOf: z21.string().array().optional(),
|
|
1657
|
+
wake: z21.boolean().optional()
|
|
1658
|
+
});
|
|
1659
|
+
// src/message/task-message-result-schema.ts
|
|
1660
|
+
import { z as z22 } from "zod";
|
|
1661
|
+
var taskMessageResultSchema = z22.object({
|
|
1662
|
+
messageID: z22.string(),
|
|
1663
|
+
woke: z22.boolean(),
|
|
1664
|
+
hop: z22.int().nonnegative(),
|
|
1665
|
+
note: z22.string().optional()
|
|
1636
1666
|
});
|
|
1637
1667
|
export {
|
|
1638
1668
|
buildPendingInput,
|
|
@@ -1645,7 +1675,6 @@ export {
|
|
|
1645
1675
|
imageLimits,
|
|
1646
1676
|
isTimeZone,
|
|
1647
1677
|
pickSpanSource,
|
|
1648
|
-
proposalOutcomeSchema,
|
|
1649
1678
|
renderSessionCookie,
|
|
1650
1679
|
sessionCookieName,
|
|
1651
1680
|
spanSchema,
|