@wirecat/cli-core 0.703.0 → 0.705.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 (88) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/cli/bot/api-http.d.ts +8 -2
  4. package/dist/cli/bot/api-http.js +20 -4
  5. package/dist/cli/documents/words.d.ts +1 -1
  6. package/dist/cli/index.d.ts +3 -3
  7. package/dist/cli/index.js +3 -3
  8. package/dist/cli/messenger/store-maintenance-command.js +6 -2
  9. package/dist/cli/service-api-call.d.ts +13 -3
  10. package/dist/cli/service-api-call.js +19 -9
  11. package/dist/cli/service-api-manifest.d.ts +11 -2
  12. package/dist/cli/service-api-manifest.js +30 -9
  13. package/dist/cli/service-api.d.ts +14 -6
  14. package/dist/cli/service-api.js +137 -29
  15. package/dist/cli/token-session.d.ts +5 -2
  16. package/dist/cli/token-session.js +13 -4
  17. package/dist/content/cli/index.d.ts +33 -0
  18. package/dist/content/cli/index.js +368 -0
  19. package/dist/content/index.d.ts +8 -0
  20. package/dist/content/index.js +7 -0
  21. package/dist/content/manifest/index.d.ts +4 -0
  22. package/dist/content/manifest/index.js +4 -0
  23. package/dist/content/manifest/manifest.d.ts +92 -0
  24. package/dist/content/manifest/manifest.js +137 -0
  25. package/dist/content/manifest/map.d.ts +25 -0
  26. package/dist/content/manifest/map.js +94 -0
  27. package/dist/content/manifest/source.d.ts +41 -0
  28. package/dist/content/manifest/source.js +288 -0
  29. package/dist/content/manifest/writer.d.ts +26 -0
  30. package/dist/content/manifest/writer.js +133 -0
  31. package/dist/content/source.d.ts +64 -0
  32. package/dist/content/source.js +2 -0
  33. package/dist/content/sync.d.ts +61 -0
  34. package/dist/content/sync.js +387 -0
  35. package/dist/content/testing/index.d.ts +4 -0
  36. package/dist/content/testing/index.js +4 -0
  37. package/dist/content/testing/source-contract.d.ts +38 -0
  38. package/dist/content/testing/source-contract.js +274 -0
  39. package/dist/content/testing/source.d.ts +55 -0
  40. package/dist/content/testing/source.js +276 -0
  41. package/dist/content/testing/sync-contract.d.ts +10 -0
  42. package/dist/content/testing/sync-contract.js +172 -0
  43. package/dist/content/testing/write-contract.d.ts +14 -0
  44. package/dist/content/testing/write-contract.js +102 -0
  45. package/dist/content/writer.d.ts +64 -0
  46. package/dist/content/writer.js +38 -0
  47. package/dist/content/writes.d.ts +58 -0
  48. package/dist/content/writes.js +129 -0
  49. package/dist/documents/file-mirror-model.d.ts +90 -0
  50. package/dist/documents/file-mirror-model.js +1 -0
  51. package/dist/documents/index.d.ts +6 -3
  52. package/dist/documents/index.js +3 -1
  53. package/dist/documents/push-model.d.ts +3 -0
  54. package/dist/domain/content.d.ts +102 -0
  55. package/dist/domain/content.js +11 -0
  56. package/dist/embeddings/onnx-runtime.d.ts +1 -1
  57. package/dist/embeddings/onnx-runtime.js +42 -61
  58. package/dist/errors/reasons.js +22 -0
  59. package/dist/manifest/index.d.ts +21 -7
  60. package/dist/manifest/index.js +7 -4
  61. package/dist/ports/wirecat-tools.js +7 -0
  62. package/dist/sends/upload.js +0 -1
  63. package/dist/services/documents/mirror-watch.d.ts +12 -4
  64. package/dist/services/documents/mirror-watch.js +2 -0
  65. package/dist/services/documents/mirrors.d.ts +67 -35
  66. package/dist/services/documents/mirrors.js +72 -66
  67. package/dist/services/documents/push.d.ts +56 -4
  68. package/dist/services/documents/push.js +131 -24
  69. package/dist/services/files/mirror.d.ts +157 -0
  70. package/dist/services/files/mirror.js +660 -0
  71. package/dist/services/files/versions.d.ts +60 -0
  72. package/dist/services/files/versions.js +177 -0
  73. package/dist/services/metadata.d.ts +1 -1
  74. package/dist/store/exports.d.ts +1 -0
  75. package/dist/store/exports.js +1 -0
  76. package/dist/store/recover.js +2 -0
  77. package/dist/store/sqlite/account-purge.js +7 -0
  78. package/dist/store/sqlite/content.d.ts +100 -0
  79. package/dist/store/sqlite/content.js +375 -0
  80. package/dist/store/sqlite/entity-types.d.ts +1 -0
  81. package/dist/store/sqlite/entity-types.js +1 -0
  82. package/dist/store/sqlite/manifest.js +2 -0
  83. package/dist/store/sqlite/migrations.generated.js +26 -0
  84. package/dist/store/sqlite/schema.d.ts +1140 -0
  85. package/dist/store/sqlite/schema.js +100 -0
  86. package/dist/store/store.d.ts +3 -0
  87. package/dist/store/store.js +5 -0
  88. package/package.json +12 -4
@@ -0,0 +1,90 @@
1
+ /** A file in the remote folder, as one listing returns it. */
2
+ export interface RemoteFile {
3
+ /** Relative to the listed folder, with `/` separators. */
4
+ path: string;
5
+ /** Stays the same across a move or an overwrite, so a remote rename is found by it. */
6
+ id: string;
7
+ size: number;
8
+ /** The plain sha256 of the content. A file without one (still being processed) is left for the next run. */
9
+ sha256?: string;
10
+ md5?: string;
11
+ modifiedAt: string;
12
+ }
13
+ /**
14
+ * What a remote write expects to find at the path, from the last listing: nothing, or the file with these hashes.
15
+ * A target that cannot check the condition atomically checks it just before the write.
16
+ */
17
+ export type Expect = {
18
+ absent: true;
19
+ } | {
20
+ sha256: string;
21
+ md5?: string;
22
+ };
23
+ /**
24
+ * A remote folder of plain files. Writes take the remote path (`root` joined with the relative path) and refuse with
25
+ * a `conflict` CliError when the file is not what `expect` says.
26
+ */
27
+ export interface FileTarget {
28
+ identity(): Promise<string>;
29
+ /**
30
+ * Every file under `root`, with the root folder's own id; undefined when the folder does not exist. `complete` is
31
+ * false when any page was skipped or a cap was hit: a file missing from such a listing is not taken as deleted.
32
+ */
33
+ list(root: string, signal?: AbortSignal): Promise<{
34
+ rootId: string;
35
+ files: RemoteFile[];
36
+ complete: boolean;
37
+ } | undefined>;
38
+ /** Streams the file into `into`, a new local file. */
39
+ download(path: string, into: string, signal?: AbortSignal): Promise<void>;
40
+ /** Streams the local file `from` to `path` and returns the file as the remote now has it. */
41
+ upload(path: string, from: string, expect: Expect, signal?: AbortSignal): Promise<RemoteFile>;
42
+ /** Moves the file to the remote's trash, where the owner can restore it. */
43
+ trash(path: string, expect: Exclude<Expect, {
44
+ absent: true;
45
+ }>, signal?: AbortSignal): Promise<void>;
46
+ /** Creates the folder and its parents; a folder that exists is fine. */
47
+ ensureFolder(path: string, signal?: AbortSignal): Promise<void>;
48
+ /** A value that moves with every change on the remote, when the provider has one: a watch reads it before listing. */
49
+ revision?(signal?: AbortSignal): Promise<string>;
50
+ }
51
+ /** The last sync of one path: the base of the three-way comparison. */
52
+ export interface FileEntry {
53
+ id: string;
54
+ size: number;
55
+ sha256: string;
56
+ md5?: string;
57
+ remoteModified: string;
58
+ localMtimeMs: number;
59
+ localSize: number;
60
+ syncedAt: string;
61
+ }
62
+ export interface FileMirrorState {
63
+ version: 1;
64
+ principal: string;
65
+ root: string;
66
+ target: string;
67
+ /** Set at the first sync; a later listing with another id means the remote folder was moved or replaced. */
68
+ rootId?: string;
69
+ /** The local folder's device and inode at the first sync: another folder at the same path is not this mirror. */
70
+ localRoot?: {
71
+ dev: number;
72
+ ino: number;
73
+ };
74
+ entries: Record<string, FileEntry>;
75
+ /**
76
+ * Saved before each write. After a crash the next listing settles the write (same content on both sides is
77
+ * adopted); this only names the temporary file to remove and the operation to look up. `created` is false for a
78
+ * download that replaces a file, which is renamed into place whole and so never left partial.
79
+ */
80
+ pending: Record<string, {
81
+ op: FileStepKind;
82
+ operationId: string;
83
+ created?: boolean;
84
+ }>;
85
+ }
86
+ export interface FileMirrorStatePort {
87
+ read(): FileMirrorState;
88
+ save(state: FileMirrorState): void;
89
+ }
90
+ export type FileStepKind = "upload" | "download" | "adopt" | "trash-remote" | "trash-local" | "rename-local" | "keep-both" | "forget" | "conflict" | "unknown";
@@ -0,0 +1 @@
1
+ export {};
@@ -4,14 +4,17 @@ export { fileText, readableFile } from "../services/documents/file-text.js";
4
4
  export { documentIngestion, type IngestionOptions } from "../services/documents/ingestion.js";
5
5
  export { type DocumentKnowledge, documentKnowledge } from "../services/documents/knowledge.js";
6
6
  export { blocksMarkdown, inlineMarkdown, spliceMarkdown } from "../services/documents/markdown-splice.js";
7
- export { type MirrorTrigger, type MirrorWatchEvent, type MirrorWatchOptions, watchMirrors, } from "../services/documents/mirror-watch.js";
8
- export { conflictReport, fileMirrorState, type Mirror, type MirrorSyncOptions, mirrorId, mirrorStatus, syncMirrors, } from "../services/documents/mirrors.js";
7
+ export { type MirrorLocalCheck, type MirrorTrigger, type MirrorWatchEvent, type MirrorWatchOptions, watchMirrors, } from "../services/documents/mirror-watch.js";
8
+ export { conflictReport, fileMirrorState, type HeldLock, type Mirror, type MirrorSyncOptions, mirrorId, mirrorStatus, syncMirrors, } from "../services/documents/mirrors.js";
9
9
  export type { SyncOptions } from "../services/documents/ports.js";
10
10
  export { extractDocumentMemories, type ImportedSource, type ProposalOptions } from "../services/documents/proposals.js";
11
- export { type PushConflict, type PushOptions, type PushResult, planPush, pushDocuments, scanLocal, } from "../services/documents/push.js";
11
+ export { type MirrorAction, type PushConflict, type PushOptions, type PushResult, planPush, pushDocuments, scanLocal, skippedName, } from "../services/documents/push.js";
12
12
  export { type SyncResult, syncDocuments } from "../services/documents/sync.js";
13
+ export { type FileMirrorOptions, type FileMirrorResult, type FileMirrorSyncOptions, type FileStep, fileMirrorStatus, fileRemoteChanges, fileSyncState, type MirrorHints, syncFileMirror, syncFileMirrors, } from "../services/files/mirror.js";
14
+ export { type FileVersion, type FileVersions, fileVersions, restoreFileVersion, type VersionDirection, type VersionEvent, } from "../services/files/versions.js";
13
15
  export { type Block, blockKey, blockShape, type Inline, type ListKind, normalizeInlines } from "./blocks.js";
14
16
  export { catalogFiles } from "./catalog.js";
17
+ export type { Expect, FileEntry, FileMirrorState, FileMirrorStatePort, FileStepKind, FileTarget, RemoteFile, } from "./file-mirror-model.js";
15
18
  export { htmlToMarkdown, markdownToHtml } from "./html-markdown.js";
16
19
  export { markdownBlocks, type PlacedBlock, placedMarkdownBlocks } from "./markdown-blocks.js";
17
20
  export type { DocumentSource, FeedlessDocumentSource, IndexedSource, PictureWriter, SourceChange, SourceContent, SourceFile, SourceIndex, SourceSkip, SourceState, SourceStatePort, SourceWalk, SourceWork, TabText, } from "./model.js";
@@ -7,8 +7,10 @@ export { blocksMarkdown, inlineMarkdown, spliceMarkdown } from "../services/docu
7
7
  export { watchMirrors, } from "../services/documents/mirror-watch.js";
8
8
  export { conflictReport, fileMirrorState, mirrorId, mirrorStatus, syncMirrors, } from "../services/documents/mirrors.js";
9
9
  export { extractDocumentMemories } from "../services/documents/proposals.js";
10
- export { planPush, pushDocuments, scanLocal, } from "../services/documents/push.js";
10
+ export { planPush, pushDocuments, scanLocal, skippedName, } from "../services/documents/push.js";
11
11
  export { syncDocuments } from "../services/documents/sync.js";
12
+ export { fileMirrorStatus, fileRemoteChanges, fileSyncState, syncFileMirror, syncFileMirrors, } from "../services/files/mirror.js";
13
+ export { fileVersions, restoreFileVersion, } from "../services/files/versions.js";
12
14
  export { blockKey, blockShape, normalizeInlines } from "./blocks.js";
13
15
  export { catalogFiles } from "./catalog.js";
14
16
  export { htmlToMarkdown, markdownToHtml } from "./html-markdown.js";
@@ -4,6 +4,9 @@ export interface LocalDocument {
4
4
  absolute: string;
5
5
  hash: string;
6
6
  kind: string;
7
+ /** Set by `scanLocal`, so the next scan can skip hashing a file whose size and mtime did not change. */
8
+ size?: number;
9
+ mtimeMs?: number;
7
10
  }
8
11
  export interface Pushed<S> {
9
12
  id: string;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * What a blog or a social account publishes, as the store copies it (WordPress first, then Ghost and social posts):
3
+ * the authors, the tags and categories, and the posts and pages. Authors and terms come before the posts that name
4
+ * them. The channel a post is published on (a site, a social account) is read on its own, not as a changes kind.
5
+ */
6
+ export declare const CONTENT_KINDS: readonly ["author", "term", "post"];
7
+ export type ContentKind = (typeof CONTENT_KINDS)[number];
8
+ /** Where a post stands. A trashed post still exists at the source: only a post gone from every list is deleted. */
9
+ export declare const POST_STATUSES: readonly ["draft", "pending", "scheduled", "published", "private", "trashed"];
10
+ export type PostStatus = (typeof POST_STATUSES)[number];
11
+ export declare const POST_TYPES: readonly ["post", "page"];
12
+ export type PostType = (typeof POST_TYPES)[number];
13
+ export declare const CHANNEL_KINDS: readonly ["blog", "social", "newsletter"];
14
+ export type ChannelKind = (typeof CHANNEL_KINDS)[number];
15
+ export declare const TERM_KINDS: readonly ["tag", "category"];
16
+ export type TermKind = (typeof TERM_KINDS)[number];
17
+ /**
18
+ * Every record has the source's id. A field left out means the source did not say, and the store keeps what it
19
+ * held; `null` means the source said there is none. Times are epoch milliseconds.
20
+ */
21
+ interface ContentRecord {
22
+ externalId: string;
23
+ createdAt?: number | null;
24
+ updatedAt?: number | null;
25
+ }
26
+ /** A site or a social account. Two profiles on one site read one channel. */
27
+ export interface ContentChannel {
28
+ externalId: string;
29
+ kind: ChannelKind;
30
+ /** `wordpress`, `ghost`, `linkedin`, `linkedin-page`, `x`. */
31
+ network: string;
32
+ name: string;
33
+ /** The site's address: a sync holds its deletions when it changes, as a moved root would empty the copy. */
34
+ url?: string | null;
35
+ handle?: string | null;
36
+ }
37
+ export interface ContentAuthor extends ContentRecord {
38
+ name: string;
39
+ /** How the store joins the author to a person it already knows: by this exact address, when read. */
40
+ email?: string | null;
41
+ slug?: string | null;
42
+ }
43
+ /** A tag or a category of the source; the store tags a post with the shared tag of the same name. */
44
+ export interface ContentTerm extends ContentRecord {
45
+ kind: TermKind;
46
+ name: string;
47
+ slug?: string | null;
48
+ parent?: string | null;
49
+ }
50
+ export interface ContentMedia {
51
+ externalId?: string | null;
52
+ url: string;
53
+ mime?: string | null;
54
+ alt?: string | null;
55
+ }
56
+ export interface ContentPost extends ContentRecord {
57
+ /** The channel's id; left out, the account's only channel. */
58
+ channel?: string | null;
59
+ type?: PostType;
60
+ /** A social post has none. */
61
+ title?: string | null;
62
+ /** Markdown. */
63
+ body?: string | null;
64
+ /**
65
+ * The source's text holds markup Markdown cannot keep (blocks, embeds, frames): writing the body back would flatten
66
+ * it, so a write of the body needs the owner's `--replace-body`.
67
+ */
68
+ lossy?: boolean | null;
69
+ excerpt?: string | null;
70
+ status: PostStatus;
71
+ url?: string | null;
72
+ slug?: string | null;
73
+ publishedAt?: number | null;
74
+ /** When a scheduled post goes out. */
75
+ scheduledFor?: number | null;
76
+ /** Authors' ids. */
77
+ authors?: string[];
78
+ /** Terms' ids. */
79
+ terms?: string[];
80
+ media?: ContentMedia[];
81
+ /** The post this one is a part of: one text sent to several social channels. */
82
+ parent?: string | null;
83
+ /** The source's own mark of this version, sent back with a write so a change made elsewhere is not overwritten. */
84
+ version?: string | null;
85
+ }
86
+ export interface ContentRecords {
87
+ author: ContentAuthor;
88
+ term: ContentTerm;
89
+ post: ContentPost;
90
+ }
91
+ /** One reading of a post's numbers; each reading is kept, never overwritten. A number the source lacks is absent. */
92
+ export interface ContentMetric {
93
+ post: string;
94
+ at: number;
95
+ views?: number | null;
96
+ reactions?: number | null;
97
+ comments?: number | null;
98
+ shares?: number | null;
99
+ clicks?: number | null;
100
+ raw?: Record<string, unknown>;
101
+ }
102
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * What a blog or a social account publishes, as the store copies it (WordPress first, then Ghost and social posts):
3
+ * the authors, the tags and categories, and the posts and pages. Authors and terms come before the posts that name
4
+ * them. The channel a post is published on (a site, a social account) is read on its own, not as a changes kind.
5
+ */
6
+ export const CONTENT_KINDS = ["author", "term", "post"];
7
+ /** Where a post stands. A trashed post still exists at the source: only a post gone from every list is deleted. */
8
+ export const POST_STATUSES = ["draft", "pending", "scheduled", "published", "private", "trashed"];
9
+ export const POST_TYPES = ["post", "page"];
10
+ export const CHANNEL_KINDS = ["blog", "social", "newsletter"];
11
+ export const TERM_KINDS = ["tag", "category"];
@@ -19,7 +19,7 @@ export declare const nativeRuntimeFor: ({ platform, arch, musl, }?: {
19
19
  }) => NativeRuntime | undefined;
20
20
  export declare const runtimeFolder: (runtime: NativeRuntime, env?: NodeJS.ProcessEnv) => string;
21
21
  /**
22
- * The library this system's binding links to, out of Microsoft's release archive, checked against its own sha256
22
+ * The library this system's binding links to, out of WireCat's npm package of it, checked against its own sha256
23
23
  * and placed beside a copy of the binding, which loads it from its own folder. Only from `models download`: a search
24
24
  * never downloads. `undefined` when this system runs models through WebAssembly only.
25
25
  */
@@ -5,69 +5,50 @@ import { CliError } from "@wirecat/cli-base";
5
5
  import { gunzipSync } from "fflate";
6
6
  import { installFiles, megabytes, sharedModelsDirectory } from "../speech/install.js";
7
7
  export const ONNX_RUNTIME_VERSION = "1.30.0";
8
- const release = (name, sha256, bytes) => ({
9
- name,
10
- url: `https://github.com/microsoft/onnxruntime/releases/download/v${ONNX_RUNTIME_VERSION}/${name}`,
11
- sha256,
12
- bytes,
13
- });
8
+ const REGISTRY = "https://registry.npmjs.org";
14
9
  /**
15
- * onnxruntime-node's own npm tarball, for Windows: its binding imports the DirectML build of onnxruntime.dll by
16
- * ordinal, which Microsoft's CPU release lacks; DirectML.dll is loaded only when used, so the DLL alone runs on CPU.
10
+ * WireCat's own package of this system's library, on npm: Microsoft's GitHub releases went away on 17.11.2026, so no
11
+ * download depends on Microsoft's hosting. `bin/publish-onnxruntime` builds them from Microsoft's NuGet package, and
12
+ * on Windows from onnxruntime-node's npm tarball: its binding imports the DirectML build of onnxruntime.dll by
13
+ * ordinal, which Microsoft's CPU build lacks; DirectML.dll is loaded only when used, so the DLL alone runs on CPU.
17
14
  */
18
- const npmTarball = {
19
- name: `onnxruntime-node-${ONNX_RUNTIME_VERSION}.tgz`,
20
- url: `https://registry.npmjs.org/onnxruntime-node/-/onnxruntime-node-${ONNX_RUNTIME_VERSION}.tgz`,
21
- sha256: "6e3390d6b783e7be946fad629292799da28d0b42f84856e50d2c1b0383291e75",
22
- bytes: 113_507_888,
23
- };
15
+ const wirecat = (target, sha256, bytes, library) => ({
16
+ archive: {
17
+ name: `onnxruntime-${target}-${ONNX_RUNTIME_VERSION}.tgz`,
18
+ url: `${REGISTRY}/@wirecat/onnxruntime-${target}/-/onnxruntime-${target}-${ONNX_RUNTIME_VERSION}.tgz`,
19
+ sha256,
20
+ bytes,
21
+ },
22
+ member: `package/${library.name}`,
23
+ library,
24
+ });
24
25
  /** The systems the native-runtime workflow runs natively; elsewhere, and on musl, the models run through WebAssembly. */
25
26
  const NATIVE = {
26
- "linux-x64": {
27
- archive: release("onnxruntime-linux-x64-1.30.0.tgz", "a5ed5a3cac51fbb2e90da632ae43d19212faaa20e76484e62bcb7c23ddb3b3fd", 11_306_877),
28
- member: "onnxruntime-linux-x64-1.30.0/lib/libonnxruntime.so.1.30.0",
29
- library: {
30
- name: "libonnxruntime.so.1",
31
- sha256: "245a6f8c38127551057a1cd1ffd59f0a186a227ade4f3492dea2494eb565542e",
32
- bytes: 28_985_152,
33
- },
34
- },
35
- "linux-arm64": {
36
- archive: release("onnxruntime-linux-aarch64-1.30.0.tgz", "e16a27a8ed330bbc698df7330b0cf56e722f354e3bcc92118682c74ef3c3e3da", 10_269_495),
37
- member: "onnxruntime-linux-aarch64-1.30.0/lib/libonnxruntime.so.1.30.0",
38
- library: {
39
- name: "libonnxruntime.so.1",
40
- sha256: "64e903a43a041240fd6bcffe0ac6d4fea47ef87bf24b9d097801bd00a9612a4b",
41
- bytes: 25_135_496,
42
- },
43
- },
44
- "darwin-arm64": {
45
- archive: release("onnxruntime-osx-arm64-1.30.0.tgz", "6ebb5062a934537c352937821f9fe9718e7de1a2db1122a93dd363ffd53a7012", 42_373_116),
46
- member: "onnxruntime-osx-arm64-1.30.0/lib/libonnxruntime.1.30.0.dylib",
47
- library: {
48
- name: "libonnxruntime.1.dylib",
49
- sha256: "bcc9110f9d638a119de2db7afb3ba9a1da8085f0cb3401e1c48ae1caf450b6fa",
50
- bytes: 43_879_424,
51
- },
52
- },
53
- "win32-x64": {
54
- archive: npmTarball,
55
- member: "package/bin/napi-v6/win32/x64/onnxruntime.dll",
56
- library: {
57
- name: "onnxruntime.dll",
58
- sha256: "508c362f5673483dd3a086379c392795b2e42d10d5e6f3f90ebd7ac21c97af67",
59
- bytes: 28_754_232,
60
- },
61
- },
62
- "win32-arm64": {
63
- archive: npmTarball,
64
- member: "package/bin/napi-v6/win32/arm64/onnxruntime.dll",
65
- library: {
66
- name: "onnxruntime.dll",
67
- sha256: "6c3a2abf5c6aca11c48a0d338a91af309f2266f25ce2e4084e6a87bbcb0fbfd0",
68
- bytes: 29_815_136,
69
- },
70
- },
27
+ "linux-x64": wirecat("linux-x64", "9c12e88ae495ae04e28802e52c2524a7a9c31aa715a67eeb636c85efcb08e5d9", 11_305_384, {
28
+ name: "libonnxruntime.so.1",
29
+ sha256: "245a6f8c38127551057a1cd1ffd59f0a186a227ade4f3492dea2494eb565542e",
30
+ bytes: 28_985_152,
31
+ }),
32
+ "linux-arm64": wirecat("linux-arm64", "4ec23a63f0e7f49edb63590f4bc8b0e8526bff5b3a2b19d768112f37dc50d09c", 10_386_392, {
33
+ name: "libonnxruntime.so.1",
34
+ sha256: "64e903a43a041240fd6bcffe0ac6d4fea47ef87bf24b9d097801bd00a9612a4b",
35
+ bytes: 25_135_496,
36
+ }),
37
+ "darwin-arm64": wirecat("darwin-arm64", "0e543a584a048b301ff96b81af4b001288e048577ce0f0b4a5a9c2df97979615", 12_921_423, {
38
+ name: "libonnxruntime.1.dylib",
39
+ sha256: "bffaa6ef856dba2c26f09c7c0e7018fd1562625f3485292c7ad28b83748c6879",
40
+ bytes: 43_879_424,
41
+ }),
42
+ "win32-x64": wirecat("win32-x64", "55924c8e4c3f975d131e943712c5fac6e5423fb2b0c356c96230f2ad18dc2792", 10_652_326, {
43
+ name: "onnxruntime.dll",
44
+ sha256: "508c362f5673483dd3a086379c392795b2e42d10d5e6f3f90ebd7ac21c97af67",
45
+ bytes: 28_754_232,
46
+ }),
47
+ "win32-arm64": wirecat("win32-arm64", "77e43743e580d6641e49b7cdeed57fd11f21a8cf27a186dd33a3db817b3ff7f2", 10_778_591, {
48
+ name: "onnxruntime.dll",
49
+ sha256: "6c3a2abf5c6aca11c48a0d338a91af309f2266f25ce2e4084e6a87bbcb0fbfd0",
50
+ bytes: 29_815_136,
51
+ }),
71
52
  };
72
53
  const onMusl = () => {
73
54
  try {
@@ -94,7 +75,7 @@ const sizeOf = (path) => {
94
75
  };
95
76
  const isInstalled = (runtime, folder) => sizeOf(join(folder, runtime.library.name)) === runtime.library.bytes && sizeOf(join(folder, BINDING)) !== undefined;
96
77
  /**
97
- * The library this system's binding links to, out of Microsoft's release archive, checked against its own sha256
78
+ * The library this system's binding links to, out of WireCat's npm package of it, checked against its own sha256
98
79
  * and placed beside a copy of the binding, which loads it from its own folder. Only from `models download`: a search
99
80
  * never downloads. `undefined` when this system runs models through WebAssembly only.
100
81
  */
@@ -107,7 +88,7 @@ export const installNativeRuntime = async ({ env = process.env, progress = () =>
107
88
  const folder = runtimeFolder(runtime, env);
108
89
  if (isInstalled(runtime, folder))
109
90
  return folder;
110
- progress(`ONNX Runtime ${ONNX_RUNTIME_VERSION} for ${runtime.target}: ${megabytes(runtime.archive.bytes)} from Microsoft`);
91
+ progress(`ONNX Runtime ${ONNX_RUNTIME_VERSION} for ${runtime.target}: ${megabytes(runtime.archive.bytes)} from npm`);
111
92
  const parent = sharedModelsDirectory("runtime", env);
112
93
  mkdirSync(parent, { recursive: true, mode: 0o700 });
113
94
  const staging = mkdtempSync(join(parent, ".onnxruntime-"));
@@ -220,6 +220,20 @@ const OTHERS = [
220
220
  ["mirror.none", "not_found", "the profile has no mirrors; add one with mirrors add"],
221
221
  ["mirror.not-found", "not_found", "no such mirror in this profile; see mirrors list"],
222
222
  validation("mirror.not-folder", "the path to mirror is not a folder"),
223
+ validation("mirror.symlink", "the file is under a symbolic link, which the sync does not follow"),
224
+ [
225
+ "mirror.too-many-deletions",
226
+ "confirmation_required",
227
+ "the sync would delete more files than the guard allows; check them with --dry-run and allow them explicitly",
228
+ ],
229
+ [
230
+ "mirror.version-not-kept",
231
+ "provider_error",
232
+ "the earlier content could not be kept in the version store, so the sync did not replace it",
233
+ ],
234
+ ["mirror.remote-changed", "conflict", "the remote file changed since the listing; the next sync settles it"],
235
+ ["upload.mismatch", "conflict", "the uploaded file reads back with other content; the local file changed meanwhile"],
236
+ ["download.mismatch", "invalid_response", "the downloaded file has other content than the listing said"],
223
237
  ["catalog.unavailable", "configuration_error", "the store has no shared catalog for this account"],
224
238
  ["catalog.not-found", "not_found", "the file or folder is not in the local catalog; run catalog import or sync"],
225
239
  validation("catalog.depth-invalid", "tree depth must be between 0 and 50"),
@@ -489,6 +503,14 @@ const OTHERS = [
489
503
  validation("crm.write-unsupported", "the CRM does not take this write, or does not recognise a repeated one"),
490
504
  validation("crm.unlisted-held", "a list of every id would mark most of a kind deleted; nothing was, until --rescan"),
491
505
  validation("tracker.unlisted-held", "a tracker's id list would mark too much deleted, or the sign-in read only part; nothing was, until --rescan"),
506
+ validation("content.unlisted-held", "a content id list would mark too much deleted, the sign-in read only part, or the site moved; nothing was"),
507
+ validation("content.conflict", "the post changed at the source since the last sync; sync, then write again"),
508
+ validation("content.lossy-body", "the post's text holds blocks or embeds Markdown does not keep; --replace-body"),
509
+ validation("content.schedule-past", "a post is scheduled for a time to come, not one that passed"),
510
+ validation("content.already-published", "a published post cannot be scheduled; unpublish it first"),
511
+ validation("content.empty", "a write names no field to set"),
512
+ ["content.get-unsupported", "configuration_error", "the source cannot read one post, author or term by its id"],
513
+ validation("content.write-unsupported", "the source does not take this write, such as a deletion past the trash"),
492
514
  validation("crm.narrowing-held", "the default scope mine would mark most of a kind's stored rows deleted; none is, until the owner sets the scope"),
493
515
  validation("crm.unassigned-dropped", "the CRM does not let this sign-in choose a user in unassigned; that user's deals are not copied"),
494
516
  validation("crm.not-reported", "the CRM did not list users or departments; what they would say is unknown, nothing withdrawn"),
@@ -1,3 +1,4 @@
1
+ import type { ContentManifest } from "../content/manifest/manifest.js";
1
2
  import type { CrmManifest } from "../crm/manifest/manifest.js";
2
3
  import type { OAuthProvider } from "../oauth/provider.js";
3
4
  import type { TrackerManifest } from "../tracker/manifest/manifest.js";
@@ -26,6 +27,14 @@ export type CliAuth = {
26
27
  preset: "token";
27
28
  verify?: CliVerify;
28
29
  }
30
+ /**
31
+ * A WordPress application password: the profile's own site (`--site host/blog`), a user name and the password, sent
32
+ * by Basic to that site alone.
33
+ */
34
+ | {
35
+ preset: "app-password";
36
+ verify?: CliVerify;
37
+ }
29
38
  /** The browser sign-in the spec's authorization code flow declares; the redirect is what the app registered. */
30
39
  | {
31
40
  preset: "oauth2-pkce";
@@ -38,7 +47,7 @@ export type CliAuth = {
38
47
  /** The provider sends a new refresh token on each refresh; the spec cannot say so. */
39
48
  rotating?: boolean;
40
49
  };
41
- export declare const CLI_CATEGORIES: readonly ["messenger", "mail", "notes", "files", "meetings", "calendar", "crm", "tracker", "other"];
50
+ export declare const CLI_CATEGORIES: readonly ["messenger", "mail", "notes", "files", "meetings", "calendar", "crm", "tracker", "content", "other"];
42
51
  export type CliCategory = (typeof CLI_CATEGORIES)[number];
43
52
  /** One file, `wirecat.config.ts`, that `new --from-config` builds a CLI from. */
44
53
  export interface CliConfig {
@@ -54,26 +63,31 @@ export interface CliConfig {
54
63
  /** The GitHub owner of the repository. */
55
64
  owner: string;
56
65
  };
57
- /** `from`: the https URL the description is published at. */
66
+ /**
67
+ * `from`: the https URL the description is published at. For `wp-json`, a WordPress site's REST index
68
+ * (`https://wp.example/wp-json/`), from a plain WordPress the CLI is made against, as it serves every site.
69
+ */
58
70
  spec: {
59
- kind: "openapi" | "swagger" | "graphql";
71
+ kind: "openapi" | "swagger" | "graphql" | "wp-json";
60
72
  from: string;
73
+ /** The WordPress version `from` runs, for the snapshot's provenance: the index does not say it. */
74
+ version?: string;
61
75
  };
62
76
  auth: CliAuth;
63
77
  /** cli-template's `--category`; `other` is any API outside them. */
64
78
  category: CliCategory;
65
79
  /**
66
- * A crm or tracker CLI's source; checked against the generated API by `parseCrmManifest` or `parseTrackerManifest`
67
- * once the api group exists.
80
+ * A crm, tracker or content CLI's source; checked against the generated API by `parseCrmManifest`,
81
+ * `parseTrackerManifest` or `parseContentManifest` once the api group exists.
68
82
  */
69
- source?: CrmManifest | TrackerManifest;
83
+ source?: CrmManifest | TrackerManifest | ContentManifest;
70
84
  /** The module of named hooks, relative to the config: `./src/hooks.ts`. */
71
85
  hooks?: string;
72
86
  }
73
87
  /** Types the config in the editor; it returns what it is given. */
74
88
  export declare const defineCli: (config: CliConfig) => CliConfig;
75
89
  /**
76
- * The config checked against its shape; every error names where it is. A crm or tracker CLI needs its source. `source` comes back
90
+ * The config checked against its shape; every error names where it is. A crm, tracker or content CLI needs its source. `source` comes back
77
91
  * unchecked: `parseCrmManifest` checks it against the generated API.
78
92
  */
79
93
  export declare const parseCliConfig: (input: unknown) => CliConfig;
@@ -11,6 +11,7 @@ export const CLI_CATEGORIES = [
11
11
  "calendar",
12
12
  "crm",
13
13
  "tracker",
14
+ "content",
14
15
  "other",
15
16
  ];
16
17
  /** Types the config in the editor; it returns what it is given. */
@@ -64,12 +65,14 @@ const schema = v.strictObject({
64
65
  owner: v.pipe(v.string(), v.regex(/^[A-Za-z0-9](?:-?[A-Za-z0-9]){0,38}$/, "a GitHub owner")),
65
66
  }),
66
67
  spec: v.strictObject({
67
- kind: v.picklist(["openapi", "swagger", "graphql"]),
68
+ kind: v.picklist(["openapi", "swagger", "graphql", "wp-json"]),
68
69
  from: httpsUrl,
70
+ version: v.optional(v.pipe(v.string(), v.regex(/^\d+\.\d+(\.\d+)?$/, "a version such as 6.9.4"))),
69
71
  }),
70
72
  auth: v.variant("preset", [
71
73
  v.strictObject({ preset: v.literal("none") }),
72
74
  v.strictObject({ preset: v.literal("token"), verify }),
75
+ v.strictObject({ preset: v.literal("app-password"), verify }),
73
76
  v.strictObject({
74
77
  preset: v.literal("oauth2-pkce"),
75
78
  verify,
@@ -89,7 +92,7 @@ const schema = v.strictObject({
89
92
  hooks: v.optional(v.pipe(v.string(), v.regex(/^\.\/([^\s]*\/)?[^/\s.][^/\s]*\.[cm]?[jt]s$/, "a module in the project, such as ./src/hooks.ts"), v.check((text) => !/\.d\.[cm]?ts$/.test(text), "a module, not a .d.ts declaration file"), v.check((text) => !text.split(/[\\/]/).includes(".."), "a module in the project, without .."))),
90
93
  });
91
94
  /**
92
- * The config checked against its shape; every error names where it is. A crm or tracker CLI needs its source. `source` comes back
95
+ * The config checked against its shape; every error names where it is. A crm, tracker or content CLI needs its source. `source` comes back
93
96
  * unchecked: `parseCrmManifest` checks it against the generated API.
94
97
  */
95
98
  export const parseCliConfig = (input) => {
@@ -111,9 +114,9 @@ export const parseCliConfig = (input) => {
111
114
  // Typed, not cast: a field CliConfig needs that the schema lacks or types otherwise fails to compile (not the reverse).
112
115
  const output = parsed.output;
113
116
  const config = output;
114
- const sourced = config.category === "crm" || config.category === "tracker";
117
+ const sourced = config.category === "crm" || config.category === "tracker" || config.category === "content";
115
118
  if (!sourced && config.source)
116
- throw new CliError("configuration_error", "wirecat.config: source: only a crm or tracker CLI reads a source yet", {
119
+ throw new CliError("configuration_error", "wirecat.config: source: only a crm, tracker or content CLI reads a source yet", {
117
120
  reason: "manifest.invalid",
118
121
  });
119
122
  if (sourced && !config.source)
@@ -64,6 +64,13 @@ export const WIRECAT_TOOLS = [
64
64
  package: "@wirecat/bitrix24-cli",
65
65
  does: "Bitrix24 CRM: deals, leads and pipelines, searchable with your other WireCat data",
66
66
  },
67
+ {
68
+ command: "amo",
69
+ appName: "amo-cli",
70
+ envPrefix: "AMO",
71
+ package: "@wirecat/amo-cli",
72
+ does: "amoCRM and Kommo: deals, contacts and companies, searchable with your other WireCat data",
73
+ },
67
74
  {
68
75
  command: "pbx",
69
76
  appName: "asterisk-cli",
@@ -115,7 +115,6 @@ const CREDENTIAL_RUNS = [
115
115
  */
116
116
  const WIRECAT_APPS = [
117
117
  ...WIRECAT_TOOLS.map(({ appName, envPrefix }) => ({ appName, prefix: envPrefix })),
118
- { appName: "amo-cli", prefix: "AMO" },
119
118
  { appName: "beeline-cli", prefix: "BEELINE" },
120
119
  { appName: "zm", prefix: "ZM" },
121
120
  { appName: "cli-messaging", prefix: "MESSAGING" },
@@ -12,11 +12,19 @@ export type MirrorWatchEvent<T> = {
12
12
  mirrors: string[];
13
13
  error: CliError;
14
14
  };
15
- export interface MirrorWatchOptions<S> {
16
- mirrors: Mirror[];
17
- signal: AbortSignal;
15
+ /**
16
+ * How a watch tells which mirrors' local files differ from their state: a document push's kinds and state, or the
17
+ * engine's own check.
18
+ */
19
+ export type MirrorLocalCheck<S> = {
18
20
  kindOf(path: string): string | undefined;
19
21
  stateOf(mirror: Mirror): PushStatePort<S>;
22
+ } | {
23
+ localChanges(mirrors: Mirror[]): Promise<string[]>;
24
+ };
25
+ export type MirrorWatchOptions<S> = MirrorLocalCheck<S> & {
26
+ mirrors: Mirror[];
27
+ signal: AbortSignal;
20
28
  /** Ids of the mirrors whose remote files changed since the last call, or `all` when the provider cannot tell. */
21
29
  remoteChanges?(signal: AbortSignal): Promise<string[] | "all">;
22
30
  pollMs?: number;
@@ -28,7 +36,7 @@ export interface MirrorWatchOptions<S> {
28
36
  watchFolder?(root: string, changed: () => void): () => void;
29
37
  sleep?(milliseconds: number, signal: AbortSignal): Promise<void>;
30
38
  now?(): number;
31
- }
39
+ };
32
40
  /**
33
41
  * Keeps mirrors in sync until `signal` aborts: a cycle at start, then one for each mirror whose files were saved
34
42
  * (after `quietMs` without another save), whose remote files changed, or whose files differ from the state at the
@@ -52,6 +52,8 @@ export async function* watchMirrors(sync, options) {
52
52
  const differs = async (ids) => {
53
53
  const chosen = [...ids].flatMap((id) => byId.get(id) ?? []);
54
54
  try {
55
+ if ("localChanges" in options)
56
+ return await options.localChanges(chosen);
55
57
  const items = await mirrorStatus(chosen, options.kindOf, options.stateOf);
56
58
  return items.filter((item) => item.create.length || item.update.length).map((item) => item.id);
57
59
  }