@redaksjon/protokoll 1.0.14 → 1.0.15-dev.20260218065403.154eebf

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.
@@ -3,8 +3,8 @@
3
3
  "byProject": {},
4
4
  "transcriptSnapshots": {},
5
5
  "metadata": {
6
- "builtAt": "2026-02-16T15:04:17.495Z",
7
- "lastUpdatedAt": "2026-02-16T15:04:17.495Z",
6
+ "builtAt": "2026-02-18T06:05:55.713Z",
7
+ "lastUpdatedAt": "2026-02-18T06:05:55.713Z",
8
8
  "transcriptCount": 0,
9
9
  "entityCount": 0,
10
10
  "version": "1.0.0"
@@ -9,6 +9,7 @@ import { create as create$1, parseEntityUri as parseEntityUri$1, createRelations
9
9
  import os from 'node:os';
10
10
  import winston from 'winston';
11
11
  import { glob } from 'glob';
12
+ import { randomUUID } from 'crypto';
12
13
  import { PklTranscript, listTranscripts as listTranscripts$1, readTranscript } from '@redaksjon/protokoll-format';
13
14
  import * as Cardigantime from '@utilarium/cardigantime';
14
15
 
@@ -277,7 +278,7 @@ const resourceTemplates = [
277
278
  }
278
279
  ];
279
280
 
280
- const VERSION = "1.0.14 (HEAD/3bef147 T:v1.0.14 2026-02-16 07:27:27 -0800) linux arm64 v24.13.1";
281
+ const VERSION = "1.0.15-dev.20260218065403.154eebf (working/154eebf 2026-02-17 22:52:56 -0800) linux arm64 v24.13.1";
281
282
  const PROGRAM_NAME = "protokoll";
282
283
  const DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS = "YYYY-M-D-HHmmss";
283
284
  const DEFAULT_AUDIO_EXTENSIONS = ["mp3", "mp4", "mpeg", "mpga", "m4a", "wav", "webm", "qta"];
@@ -2544,6 +2545,10 @@ async function handlePredictEntities(args) {
2544
2545
  return { success: true, predictions };
2545
2546
  }
2546
2547
 
2548
+ function isValidUUID(str) {
2549
+ const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
2550
+ return uuidRegex.test(str);
2551
+ }
2547
2552
  const addPersonTool = {
2548
2553
  name: "protokoll_add_person",
2549
2554
  description: "Add a new person to the context. People entries help Protokoll recognize names that Whisper mishears. Include sounds_like variants for phonetic matching.",
@@ -3172,12 +3177,14 @@ async function handleAddPerson(args) {
3172
3177
  if (!context.hasContext()) {
3173
3178
  throw new Error("No .protokoll directory found. Initialize context first.");
3174
3179
  }
3175
- const id = args.id || slugify(args.name);
3180
+ const id = args.id && isValidUUID(args.id) ? args.id : randomUUID();
3181
+ const slug = slugify(args.name);
3176
3182
  if (context.getPerson(id)) {
3177
3183
  throw new Error(`Person with ID "${id}" already exists`);
3178
3184
  }
3179
3185
  const person = {
3180
3186
  id,
3187
+ slug,
3181
3188
  name: args.name,
3182
3189
  type: "person",
3183
3190
  ...args.firstName && { firstName: args.firstName },
@@ -3248,7 +3255,8 @@ async function handleAddProject(args) {
3248
3255
  if (!context.hasContext()) {
3249
3256
  throw new Error("No .protokoll directory found. Initialize context first.");
3250
3257
  }
3251
- const id = args.id || slugify(args.name);
3258
+ const id = args.id && isValidUUID(args.id) ? args.id : randomUUID();
3259
+ const slug = slugify(args.name);
3252
3260
  if (context.getProject(id)) {
3253
3261
  throw new Error(`Project with ID "${id}" already exists`);
3254
3262
  }
@@ -3263,6 +3271,7 @@ async function handleAddProject(args) {
3263
3271
  }
3264
3272
  const project = {
3265
3273
  id,
3274
+ slug,
3266
3275
  name: args.name,
3267
3276
  type: "project",
3268
3277
  classification: {
@@ -3490,12 +3499,14 @@ async function handleAddTerm(args) {
3490
3499
  if (!context.hasContext()) {
3491
3500
  throw new Error("No .protokoll directory found. Initialize context first.");
3492
3501
  }
3493
- const id = args.id || slugify(args.term);
3502
+ const id = args.id && isValidUUID(args.id) ? args.id : randomUUID();
3503
+ const slug = slugify(args.term);
3494
3504
  if (context.getTerm(id)) {
3495
3505
  throw new Error(`Term with ID "${id}" already exists`);
3496
3506
  }
3497
3507
  const term = {
3498
3508
  id,
3509
+ slug,
3499
3510
  name: args.term,
3500
3511
  type: "term",
3501
3512
  ...args.expansion && { expansion: args.expansion },
@@ -3651,12 +3662,14 @@ async function handleAddCompany(args) {
3651
3662
  if (!context.hasContext()) {
3652
3663
  throw new Error("No .protokoll directory found. Initialize context first.");
3653
3664
  }
3654
- const id = args.id || slugify(args.name);
3665
+ const id = args.id && isValidUUID(args.id) ? args.id : randomUUID();
3666
+ const slug = slugify(args.name);
3655
3667
  if (context.getCompany(id)) {
3656
3668
  throw new Error(`Company with ID "${id}" already exists`);
3657
3669
  }
3658
3670
  const company = {
3659
3671
  id,
3672
+ slug,
3660
3673
  name: args.name,
3661
3674
  type: "company",
3662
3675
  ...args.fullName && { fullName: args.fullName },
@@ -4500,15 +4513,20 @@ async function handleUpdateTranscriptEntityReferences(args) {
4500
4513
  }
4501
4514
  if (id.includes("},") || id.includes("{") || id.includes("}") || id.includes(",")) {
4502
4515
  throw new Error(
4503
- `Invalid entity ID "${id}" for ${type} "${name}". Entity IDs should be slugified identifiers (e.g., "jack-smith", "discursive"), not JSON syntax. Please provide a valid slugified ID.`
4516
+ `Invalid entity ID "${id}" for ${type} "${name}". Entity IDs should be UUIDs or slugified identifiers (e.g., "a1b2c3d4-...", "jack-smith"), not JSON syntax. Please provide a valid ID.`
4504
4517
  );
4505
4518
  }
4506
- if (!/^[a-z0-9_-]+$/i.test(id)) {
4507
- throw new Error(
4508
- `Invalid entity ID "${id}" for ${type} "${name}". Entity IDs should only contain letters, numbers, hyphens, and underscores.`
4509
- );
4519
+ const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
4520
+ if (uuidRegex.test(id)) {
4521
+ return id.trim();
4510
4522
  }
4511
- return id.trim();
4523
+ const slugRegex = /^[a-z0-9_-]+$/i;
4524
+ if (slugRegex.test(id)) {
4525
+ return id.trim();
4526
+ }
4527
+ throw new Error(
4528
+ `Invalid entity ID "${id}" for ${type} "${name}". Entity IDs should be UUIDs or slugified identifiers (letters, numbers, hyphens, underscores).`
4529
+ );
4512
4530
  };
4513
4531
  const entityReferences = [];
4514
4532
  if (args.entities.people) {