@wirecat/cli-core 0.663.0 → 0.664.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.
Files changed (97) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/cli/chat-sending-command.d.ts +14 -0
  4. package/dist/cli/chat-sending-command.js +64 -0
  5. package/dist/cli/context.d.ts +7 -0
  6. package/dist/cli/context.js +12 -4
  7. package/dist/cli/index.d.ts +2 -0
  8. package/dist/cli/index.js +2 -0
  9. package/dist/cli/meeting-meaning-command.d.ts +47 -0
  10. package/dist/cli/meeting-meaning-command.js +136 -0
  11. package/dist/cli/meeting-preparation-answer.d.ts +6 -0
  12. package/dist/cli/meeting-preparation-projects.d.ts +6 -0
  13. package/dist/cli/meeting-preparation-read.d.ts +6 -0
  14. package/dist/cli/meeting-tags-command.d.ts +18 -0
  15. package/dist/cli/meeting-tags-command.js +74 -0
  16. package/dist/cli/messenger/conversation-answers.d.ts +1 -1
  17. package/dist/cli/messenger/conversation-answers.js +1 -0
  18. package/dist/cli/messenger/conversations-command.js +38 -12
  19. package/dist/cli/messenger/models-command.js +7 -0
  20. package/dist/cli/messenger/records-command.d.ts +4 -1
  21. package/dist/cli/messenger/records-command.js +6 -1
  22. package/dist/cli/model-catalogue-command.js +2 -0
  23. package/dist/cli/profile-token.d.ts +15 -1
  24. package/dist/cli/profile-token.js +103 -7
  25. package/dist/cli/program.js +2 -2
  26. package/dist/domain/links.d.ts +11 -0
  27. package/dist/domain/links.js +4 -0
  28. package/dist/entities/chat-sending.d.ts +10 -0
  29. package/dist/entities/chat-sending.js +11 -0
  30. package/dist/entities/index.d.ts +43 -1
  31. package/dist/entities/index.js +6 -2
  32. package/dist/entities/meeting-preparation.d.ts +6 -0
  33. package/dist/entities/meeting.d.ts +1 -1
  34. package/dist/entities/meeting.js +1 -1
  35. package/dist/errors/reasons.js +25 -1
  36. package/dist/mcp/meeting-preparation.d.ts +6 -0
  37. package/dist/meetings/answers.d.ts +7 -0
  38. package/dist/meetings/answers.js +4 -0
  39. package/dist/meetings/index.d.ts +1 -0
  40. package/dist/meetings/index.js +1 -0
  41. package/dist/meetings/mcp/search.d.ts +6 -0
  42. package/dist/meetings/project-evidence-answer.d.ts +6 -0
  43. package/dist/meetings/tag-answers.d.ts +43 -0
  44. package/dist/meetings/tag-answers.js +41 -0
  45. package/dist/models/chat-sending.d.ts +24 -0
  46. package/dist/models/chat-sending.js +40 -0
  47. package/dist/runs/events.d.ts +1 -1
  48. package/dist/search/question-plan.d.ts +2 -0
  49. package/dist/search/question-plan.js +2 -0
  50. package/dist/search/task-similarity.d.ts +1 -0
  51. package/dist/search/task-similarity.js +1 -1
  52. package/dist/services/embeddings-search.js +19 -5
  53. package/dist/services/embeddings.d.ts +4 -0
  54. package/dist/services/index.d.ts +2 -0
  55. package/dist/services/index.js +2 -0
  56. package/dist/services/meeting-meaning.d.ts +47 -0
  57. package/dist/services/meeting-meaning.js +158 -0
  58. package/dist/services/meeting-tags.d.ts +27 -0
  59. package/dist/services/meeting-tags.js +81 -0
  60. package/dist/services/messages-discovery.js +2 -2
  61. package/dist/sftp/index.d.ts +1 -1
  62. package/dist/sftp/index.js +1 -1
  63. package/dist/sftp/session.d.ts +30 -4
  64. package/dist/sftp/session.js +195 -11
  65. package/dist/sftp/ssh2.d.ts +19 -4
  66. package/dist/sftp/ssh2.js +144 -17
  67. package/dist/speech/cloud.d.ts +47 -0
  68. package/dist/speech/cloud.js +73 -0
  69. package/dist/speech/decode.d.ts +36 -9
  70. package/dist/speech/decode.js +208 -61
  71. package/dist/speech/index.d.ts +2 -1
  72. package/dist/speech/index.js +2 -1
  73. package/dist/speech/openai.d.ts +4 -0
  74. package/dist/speech/openai.js +13 -12
  75. package/dist/sql/index.d.ts +1 -0
  76. package/dist/sql/index.js +1 -0
  77. package/dist/sql/reader.d.ts +95 -0
  78. package/dist/sql/reader.js +214 -0
  79. package/dist/store/sqlite/drizzle/bun.js +4 -4
  80. package/dist/store/sqlite/drizzle/bun.js.map +1 -1
  81. package/dist/store/sqlite/drizzle/core.js +5 -5
  82. package/dist/store/sqlite/drizzle/core.js.map +1 -1
  83. package/dist/store/sqlite/drizzle/node.js +4 -4
  84. package/dist/store/sqlite/drizzle/node.js.map +1 -1
  85. package/dist/store/sqlite/drizzle/{shared-55XJMTPA.js → shared-5XR7K42U.js} +58 -58
  86. package/dist/store/sqlite/drizzle/{shared-55XJMTPA.js.map → shared-5XR7K42U.js.map} +1 -1
  87. package/dist/store/sqlite/knowledge.d.ts +1 -1
  88. package/dist/store/sqlite/knowledge.js +8 -4
  89. package/dist/store/sqlite/labelled.d.ts +5 -0
  90. package/dist/store/sqlite/labelled.js +6 -0
  91. package/dist/store/sqlite/link-row.d.ts +1 -0
  92. package/dist/store/sqlite/link-row.js +2 -0
  93. package/dist/store/sqlite/notes.d.ts +1 -1
  94. package/dist/store/sqlite/notes.js +1 -1
  95. package/package.json +18 -3
  96. package/parity.json +20 -1
  97. package/skills/link-conversations/SKILL.md +1 -1
@@ -143,7 +143,7 @@ export interface KnowledgeStore extends VocabularyStore, MeetingProjectsStore, O
143
143
  } & TagCreationOptions): Promise<TagRow>;
144
144
  /** Marks a topic as the thing's main one, or clears it with `null`; one per thing. */
145
145
  setMainTopic(key: KnowledgeScope, target: KnowledgeTarget, topic: string | null): Promise<void>;
146
- /** Every labelled note, document, person, organization, project, task and folder. */
146
+ /** Every labelled note, document, person, organization, project, task, meeting and folder; an account: its meetings. */
147
147
  labelled(key: KnowledgeScope, options?: {
148
148
  tag?: string;
149
149
  type?: LabelledType;
@@ -13,12 +13,12 @@ import { fold } from "../normalize.js";
13
13
  import { ulid } from "../ulid.js";
14
14
  import { ownerPerson } from "./actors.js";
15
15
  import { forgetEvidenceToRow } from "./evidence-signature.js";
16
- import { LABELLED } from "./labelled.js";
16
+ import { accountMeetingTagging, LABELLED } from "./labelled.js";
17
17
  import { linkKind, RELATION_KINDS, REPORTER_SQL } from "./link-kinds.js";
18
18
  import { meetingProjectsStoreOver } from "./meeting-projects.js";
19
19
  import { idsOf } from "./merged-persons.js";
20
20
  import { holdingText } from "./note-index.js";
21
- import { insertLink, linkOf } from "./notes.js";
21
+ import { hasBothEnds, insertLink, linkOf } from "./notes.js";
22
22
  import { organizationOf, organizationsStoreOver } from "./organizations.js";
23
23
  import { queryFilter } from "./query-filter.js";
24
24
  import { relationOf as relationAt, relationProposalsOver, } from "./relation-proposals.js";
@@ -430,6 +430,7 @@ export const knowledgeStoreOver = (context) => {
430
430
  labelled: async (key, options = {}) => {
431
431
  const { limit, offset } = bounded(options.limit, options.offset);
432
432
  checked(key);
433
+ const meetingAccount = key === null ? null : account(key);
433
434
  const tag = options.tag === undefined ? null : canonicalTagName(options.tag);
434
435
  const types = Object.entries(LABELLED)
435
436
  .filter(([, type]) => options.type === undefined || type === options.type)
@@ -439,10 +440,11 @@ export const knowledgeStoreOver = (context) => {
439
440
  .prepare("SELECT * FROM (" +
440
441
  "SELECT DISTINCT g.taggable_type AS type, g.taggable_id AS id, NULL AS path FROM taggings g JOIN resolved_tags t ON t.id=g.tag_id " +
441
442
  `WHERE g.taggable_type IN (${types.map(() => "?").join(",") || "NULL"}) AND (? IS NULL OR t.name = ?) AND ${liveTagging("g")} ` +
443
+ `AND ${accountMeetingTagging("g")} ` +
442
444
  "UNION SELECT DISTINCT 'account' AS type, l.from_id AS id, l.anchor AS path FROM links l JOIN resolved_tags t ON t.id=l.to_id " +
443
445
  `WHERE ? = 1 AND l.from_type = 'account' AND l.kind = ${linkKind("labelled")} AND l.to_type = 'tag' AND (? IS NULL OR t.name = ?)` +
444
446
  ") ORDER BY type = 'account', type, id, path LIMIT ? OFFSET ?")
445
- .all(...types, tag, tag, subfolders ? 1 : 0, tag, tag, limit + 1, offset);
447
+ .all(...types, tag, tag, meetingAccount, meetingAccount, subfolders ? 1 : 0, tag, tag, limit + 1, offset);
446
448
  return {
447
449
  items: rows.slice(0, limit).flatMap((row) => {
448
450
  const thing = storedThing(row.type, row.id);
@@ -535,7 +537,9 @@ export const knowledgeStoreOver = (context) => {
535
537
  // Live ones first: a long history of withdrawn links never pushes them past the cap.
536
538
  `${RELATIONS} AND ${notOverriddenSql("links")} AND (? IS NULL OR (from_type=? AND from_id IN (SELECT value FROM json_each(?))) OR (to_type=? AND to_id IN (SELECT value FROM json_each(?)))) ORDER BY deleted_at IS NOT NULL, created_at, id LIMIT 500`)
537
539
  .all(thing?.type ?? null, thing?.type ?? null, ids(thing), thing?.type ?? null, ids(thing))
538
- .map((row) => relationOf(linkOf(database, row)));
540
+ .map((row) => linkOf(database, row))
541
+ .filter(hasBothEnds)
542
+ .map(relationOf);
539
543
  },
540
544
  removeRelation: async (key, id, by) => {
541
545
  checked(key);
@@ -1,3 +1,8 @@
1
1
  export type LabelledType = "note" | "document" | "person" | "organization" | "project" | "task" | "meeting" | "folder";
2
2
  /** What a label without an account may sit on; a chat, contact or message is the messenger's tag. */
3
3
  export declare const LABELLED: Record<string, LabelledType>;
4
+ /**
5
+ * A meeting is one account's, like a chat: with the account id bound twice, a tagging of another account's meeting is
6
+ * left out, and with `NULL` none is; a deleted meeting's never counts.
7
+ */
8
+ export declare const accountMeetingTagging: (alias: string) => string;
@@ -9,3 +9,9 @@ export const LABELLED = {
9
9
  meeting: "meeting",
10
10
  account: "folder",
11
11
  };
12
+ /**
13
+ * A meeting is one account's, like a chat: with the account id bound twice, a tagging of another account's meeting is
14
+ * left out, and with `NULL` none is; a deleted meeting's never counts.
15
+ */
16
+ export const accountMeetingTagging = (alias) => `(${alias}.taggable_type <> 'meeting' OR EXISTS (SELECT 1 FROM meetings mt WHERE mt.id = ${alias}.taggable_id ` +
17
+ "AND mt.deleted_at IS NULL AND (? IS NULL OR mt.account_id = ?)))";
@@ -2,5 +2,6 @@ import type { CacheDatabase } from "../driver.js";
2
2
  import type { Link } from "./notes.js";
3
3
  type Row = Record<string, unknown>;
4
4
  export declare const thingRef: (database: CacheDatabase, type: unknown, id: unknown) => string | null;
5
+ export declare const hasBothEnds: (link: Link) => boolean;
5
6
  export declare const linkOf: (database: CacheDatabase, row: Row) => Link;
6
7
  export {};
@@ -3,6 +3,8 @@ import { sourceOf } from "./link-source.js";
3
3
  import { referenceOfThing, storedThing } from "./things.js";
4
4
  const iso = (value) => new Date(Number(value)).toISOString();
5
5
  export const thingRef = (database, type, id) => type == null || id == null ? null : (referenceOfThing(database, storedThing(type, id)) ?? null);
6
+ // A chat or meeting deleted since leaves its links behind with no end to name.
7
+ export const hasBothEnds = (link) => link.from !== null && link.to !== null;
6
8
  export const linkOf = (database, row) => {
7
9
  const metadata = row.metadata == null ? {} : JSON.parse(String(row.metadata));
8
10
  // An older row holds one word; every reader gets a list.
@@ -6,7 +6,7 @@ import type { AddedSources } from "./added-sources.js";
6
6
  import { type DocumentMetadata } from "./document-metadata.js";
7
7
  import { type ImportedDocuments } from "./imported-documents.js";
8
8
  import { LINK_KINDS, LINK_ORIGINS, type LINK_SOURCES } from "./link-kinds.js";
9
- export { linkOf, thingRef } from "./link-row.js";
9
+ export { hasBothEnds, linkOf, thingRef } from "./link-row.js";
10
10
  import type { NoteSearch } from "./note-search.js";
11
11
  import type { StoreContext } from "./open.js";
12
12
  import { type Label } from "./tags.js";
@@ -17,7 +17,7 @@ import { importedDocumentWhere } from "./imported-documents.js";
17
17
  import { LINK_KINDS, LINK_ORIGINS, linkKind, RELATION_KINDS } from "./link-kinds.js";
18
18
  import { reviewLink } from "./link-reviews.js";
19
19
  import { linkOf } from "./link-row.js";
20
- export { linkOf, thingRef } from "./link-row.js";
20
+ export { hasBothEnds, linkOf, thingRef } from "./link-row.js";
21
21
  import { currentPerson, idsOf } from "./merged-persons.js";
22
22
  import { dateFileNotes } from "./note-dates.js";
23
23
  import { holdingText } from "./note-index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "0.663.0",
3
+ "version": "0.664.0",
4
4
  "description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Viacheslav Ptsarev",
@@ -187,6 +187,10 @@
187
187
  "types": "./dist/sftp/index.d.ts",
188
188
  "default": "./dist/sftp/index.js"
189
189
  },
190
+ "./sql": {
191
+ "types": "./dist/sql/index.d.ts",
192
+ "default": "./dist/sql/index.js"
193
+ },
190
194
  "./google": {
191
195
  "types": "./dist/google/index.d.ts",
192
196
  "default": "./dist/google/index.js"
@@ -284,10 +288,11 @@
284
288
  "@napi-rs/canvas": "1.0.13",
285
289
  "@types/mdast": "4.0.4",
286
290
  "@types/node": "^22.20.5",
291
+ "@types/pg": "8.23.1",
287
292
  "@types/pngjs": "6.0.5",
288
293
  "@types/ssh2": "1.15.5",
289
294
  "@vitest/coverage-v8": "^5.0.5",
290
- "@wirecat/cli-base": "0.100.0",
295
+ "@wirecat/cli-base": "0.101.0",
291
296
  "@wirecat/cli-core-legacy-tags": "npm:@wirecat/cli-core@0.414.0",
292
297
  "ajv": "8.17.1",
293
298
  "commander": "15.0.0",
@@ -299,6 +304,8 @@
299
304
  "lefthook": "2.2.2",
300
305
  "libphonenumber-js": "1.13.15",
301
306
  "markdownlint-cli2": "0.24.0",
307
+ "mysql2": "3.24.6",
308
+ "pg": "8.23.1",
302
309
  "pngjs": "7.0.0",
303
310
  "ssh2": "1.17.0",
304
311
  "typescript": "^7.0.2",
@@ -309,8 +316,10 @@
309
316
  },
310
317
  "peerDependencies": {
311
318
  "@napi-rs/canvas": ">=0.1.69 <2",
312
- "@wirecat/cli-base": ">=0.100.0 <1.0.0",
319
+ "@wirecat/cli-base": ">=0.101.0 <1.0.0",
313
320
  "commander": ">=15",
321
+ "mysql2": "^3.24.6",
322
+ "pg": "^8.23.1",
314
323
  "ssh2": "^1.17.0"
315
324
  },
316
325
  "bin": {
@@ -320,6 +329,12 @@
320
329
  "@napi-rs/canvas": {
321
330
  "optional": true
322
331
  },
332
+ "mysql2": {
333
+ "optional": true
334
+ },
335
+ "pg": {
336
+ "optional": true
337
+ },
323
338
  "ssh2": {
324
339
  "optional": true
325
340
  }
package/parity.json CHANGED
@@ -445,6 +445,9 @@
445
445
  "value": "<person>",
446
446
  "meaning": "a person: the one an identity leaves in `contacts unlink`, the sender in `bot search messages`"
447
447
  },
448
+ "--from-app": {
449
+ "meaning": "you did this in WireCat Desktop"
450
+ },
448
451
  "--from-dir": {
449
452
  "value": "<dir>",
450
453
  "meaning": "read nonrecursive files from this directory for one explicit chat"
@@ -3043,7 +3046,8 @@
3043
3046
  },
3044
3047
  "--max-tokens": "all",
3045
3048
  "--model": "all",
3046
- "--threads": "all"
3049
+ "--threads": "all",
3050
+ "--yes": "all"
3047
3051
  }
3048
3052
  },
3049
3053
  "conversations embeddings": {
@@ -3115,6 +3119,9 @@
3115
3119
  },
3116
3120
  "--size": {
3117
3121
  "in": "all"
3122
+ },
3123
+ "--yes": {
3124
+ "in": "all"
3118
3125
  }
3119
3126
  }
3120
3127
  },
@@ -3696,6 +3703,18 @@
3696
3703
  "--payload": "all"
3697
3704
  }
3698
3705
  },
3706
+ "models chats": {
3707
+ "in": "all"
3708
+ },
3709
+ "models chats set": {
3710
+ "in": "all",
3711
+ "options": {
3712
+ "--from-app": "all"
3713
+ }
3714
+ },
3715
+ "models chats show": {
3716
+ "in": "all"
3717
+ },
3699
3718
  "models download": {
3700
3719
  "in": "all",
3701
3720
  "options": {
@@ -10,7 +10,7 @@ metadata:
10
10
  A busy group mixes several conversations at once. `{{command}}` already links what it can without
11
11
  you: the messenger's own replies, mentions, and one person's messages in a row. You decide the rest:
12
12
  for each message, **which earlier message it answers**, or that it starts a new conversation. You
13
- read the messages; `{{command}}` checks and stores your answers. By default it leaves analysis to your agent. An explicit configured analysis provider can also process these batches through `conversations links rebuild --analyze`; that path asks for consent and validates the same answers.
13
+ read the messages; `{{command}}` checks and stores your answers. By default it leaves analysis to your agent. An explicit configured analysis provider can also process these batches through `conversations links rebuild --analyze`; that path validates the same answers. To a model outside this computer it follows the owner's `models chats` setting: `allowed` needs no yes, `ask` needs `--yes`, which you may pass, `denied` refuses even with it; only the owner changes it.
14
14
 
15
15
  ## Before the first batch: say what it costs, and wait
16
16