@wirecat/cli-core 0.702.0 → 0.704.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/CHANGELOG.md +68 -0
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/cli/messenger/conversation-answers.d.ts +1 -1
- package/dist/cli/messenger/conversation-answers.js +4 -1
- package/dist/cli/messenger/conversations-command.js +2 -1
- package/dist/crm/cli/index.js +8 -5
- package/dist/crm/manifest/source.js +2 -2
- package/dist/crm/testing/manifest-fake.js +18 -0
- package/dist/documents/file-mirror-model.d.ts +88 -0
- package/dist/documents/file-mirror-model.js +1 -0
- package/dist/documents/index.d.ts +5 -2
- package/dist/documents/index.js +2 -0
- package/dist/documents/push-model.d.ts +3 -0
- package/dist/embeddings/onnx-runtime.d.ts +1 -1
- package/dist/embeddings/onnx-runtime.js +42 -61
- package/dist/errors/reasons.js +8 -0
- package/dist/ports/wirecat-tools.js +7 -0
- package/dist/sends/upload.js +0 -1
- package/dist/services/documents/mirror-watch.d.ts +12 -4
- package/dist/services/documents/mirror-watch.js +2 -0
- package/dist/services/documents/mirrors.d.ts +55 -35
- package/dist/services/documents/mirrors.js +63 -66
- package/dist/services/documents/push.d.ts +56 -4
- package/dist/services/documents/push.js +131 -24
- package/dist/services/embeddings-search.js +35 -10
- package/dist/services/embeddings.d.ts +2 -0
- package/dist/services/files/mirror.d.ts +145 -0
- package/dist/services/files/mirror.js +603 -0
- package/dist/services/files/versions.d.ts +50 -0
- package/dist/services/files/versions.js +142 -0
- package/dist/services/metadata.d.ts +1 -1
- package/dist/store/sqlite/vectors.d.ts +1 -0
- package/dist/store/sqlite/vectors.js +25 -2
- package/dist/store/vectors.d.ts +2 -0
- package/dist/store/vectors.js +4 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,74 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
|
|
|
5
5
|
minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
|
|
6
6
|
shape of this file.
|
|
7
7
|
|
|
8
|
+
## 0.704.0 — 19.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`syncFileMirror` and the `FileTarget` port in `@wirecat/cli-core/documents`: two-way sync of plain files.** A CLI
|
|
13
|
+
for a file store (Yandex Disk next) keeps a local folder and a remote folder the same, whole files at a time,
|
|
14
|
+
binary and large files included, streamed both ways. A change on one side is copied, the same content on both is
|
|
15
|
+
adopted, different changes are a conflict that `keep` (`local`, `remote`, `both`) settles; deletions go to the
|
|
16
|
+
remote's trash and to `<mirror>/.wirecat-trash/`, and a run that would delete more than 2 files and also more than
|
|
17
|
+
50 or a quarter of the mirror stops first. Symbolic links are never followed, and a file system without hard links
|
|
18
|
+
(exFAT, FAT, FUSE, SMB) works through exclusive copies. Every write is conditional on the last listing, so a crash at any step is settled by the next
|
|
19
|
+
run. `syncFileMirrors`, `fileSyncState`, `fileMirrorStatus` and `fileRemoteChanges` (the watch lists only when the
|
|
20
|
+
remote's revision moved) complete it ([DOCUMENTS.md](docs/dev/DOCUMENTS.md#sync-plain-files-with-a-provider)).
|
|
21
|
+
- **A file mirror deletes only what it can prove was deleted.** The last sync saw the file, the side's listing is
|
|
22
|
+
complete, and the side's root is the same folder (the remote root's id; the local folder's device and inode, and
|
|
23
|
+
not empty while the state has files, as an unmounted drive is). Anything else is reported as `unknown` and the run
|
|
24
|
+
is partial, with a root problem reported as an error even at a first sync. Files under a symbolic link are
|
|
25
|
+
`unknown` too, as is a file moved remotely to a path the mirror refuses. When the owner confirms a replaced root
|
|
26
|
+
is the right folder, `repin: true` records it again and runs a first sync that deletes nothing and settles no
|
|
27
|
+
conflict; a mirror whose root was not replaced ignores it. A download cut off midway stays a conflict until its
|
|
28
|
+
partial file is moved away.
|
|
29
|
+
- **`fileVersions`: a local version store for mirrors.** Before a sync overwrites or deletes a local file, its content
|
|
30
|
+
is kept by sha256 under the profile's state folder, with an append-only log of every change both ways; versions stay
|
|
31
|
+
30 days, and a deleted file's last version stays for good; a version kept just before a crash stays 30 days too.
|
|
32
|
+
`restoreFileVersion` puts one back under the sync lock.
|
|
33
|
+
- **`watchMirrors` takes `localChanges` instead of `kindOf` and `stateOf`**, for an engine with its own state. A
|
|
34
|
+
document mirror passes `kindOf` and `stateOf` as before.
|
|
35
|
+
- **`scanLocal` reports each file's `size` and `mtimeMs`, and the symbolic links it skipped in `links`,** and takes an optional lookup that reuses a known hash when
|
|
36
|
+
both match, so a sync does not read unchanged files again. `conflictReport` adds `local_size` and `<remote>_size`
|
|
37
|
+
when a conflict has them. A mirror guard's `action` can also be `delete` and `move`.
|
|
38
|
+
|
|
39
|
+
### Changed — may break callers
|
|
40
|
+
|
|
41
|
+
- **`PushConflict.url` is optional, and `MirrorWatchOptions` is a type, not an interface.** A file conflict has no
|
|
42
|
+
URL, so `conflictReport` leaves `url` out when there is none; a document conflict still has one. Code that reads
|
|
43
|
+
`conflict.url` as a string, or extends `MirrorWatchOptions` with `interface … extends`, needs a small change. drive
|
|
44
|
+
needs none.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- **`models download` takes the native ONNX Runtime from WireCat's own npm packages.** Microsoft's GitHub repository,
|
|
49
|
+
and every release download in it, answers 404 since 17.11.2026, so the download failed on Linux and macOS and the
|
|
50
|
+
models ran through WebAssembly. The library now comes from `@wirecat/onnxruntime-<platform>` on npm (linux-x64,
|
|
51
|
+
linux-arm64, darwin-arm64, win32-x64, win32-arm64), 10–13 MB each, with the same sha256 check of the library. No
|
|
52
|
+
download depends on Microsoft's hosting any more. `bin/publish-onnxruntime` builds the packages once from
|
|
53
|
+
Microsoft's NuGet package `Microsoft.ML.OnnxRuntime` 1.30.0, and on Windows from `onnxruntime-node`'s npm tarball as
|
|
54
|
+
before. The Linux and Windows libraries are byte for byte the ones used so far. The macOS one is NuGet's build of
|
|
55
|
+
the same version, with a new sha256. Windows downloads 11 MB instead of the 113 MB `onnxruntime-node` tarball.
|
|
56
|
+
|
|
57
|
+
## 0.703.0 — 18.11.2026
|
|
58
|
+
|
|
59
|
+
### Added
|
|
60
|
+
|
|
61
|
+
- **`search conversations` shows the owner's own conversations nearest in meaning in a block of their own**, up to 5
|
|
62
|
+
that the hits left out: in JSON they follow the hits with `from_owner: true`, in text under «your own messages».
|
|
63
|
+
The hits keep their order. A question about what the owner said or advised is often answered by a message a busy
|
|
64
|
+
group ranks low; on a test store of 220,000 chunks the block showed the answer to 31 of 40 questions instead of
|
|
65
|
+
24, for about 0.24 s more per query. Only the owner's chunks are scored, found by their messages.
|
|
66
|
+
|
|
67
|
+
### Fixed
|
|
68
|
+
|
|
69
|
+
- **`crmManifestFake`'s deals name the fake's own contacts and companies**: deal n links organization n and person n,
|
|
70
|
+
so a source with `linked: true` copies them and `crmManifestContract` passes over it. A linked kind's read of changes
|
|
71
|
+
answers `reset` to a dead cursor, as every other kind does.
|
|
72
|
+
- **`sync`'s summary fits WireCat Desktop's 300 characters again.** cli-base 0.119.0 checks the limit, and every CRM
|
|
73
|
+
CLI's `contracts/wirecat.json` failed to build on a 452-character summary; the activities and stage-tasks part moved
|
|
74
|
+
to `help sync`.
|
|
75
|
+
|
|
8
76
|
## 0.702.0 — 18.11.2026
|
|
9
77
|
|
|
10
78
|
### Added
|
|
@@ -24,12 +24,12 @@ export interface DailyArchiveTimerInput {
|
|
|
24
24
|
}
|
|
25
25
|
export declare const dailyArchiveTimer: (input: DailyArchiveTimerInput) => DailyArchiveTimer;
|
|
26
26
|
export declare const manageDailyArchiveTimer: (plan: DailyArchiveTimer, action: "install" | "start" | "stop" | "status" | "uninstall", system: Pick<ServerSystem, "platform" | "run">, env: NodeJS.ProcessEnv, signal?: AbortSignal) => Promise<{
|
|
27
|
-
action?: undefined;
|
|
28
27
|
name: string;
|
|
29
28
|
installed: boolean;
|
|
30
29
|
active: boolean;
|
|
31
30
|
servicePath: string;
|
|
32
31
|
timerPath: string;
|
|
32
|
+
action?: undefined;
|
|
33
33
|
} | {
|
|
34
34
|
active?: undefined;
|
|
35
35
|
name: string;
|
|
@@ -11,7 +11,7 @@ export declare const readinessGaps: ({ meaning, model, readiness, refreshed, cov
|
|
|
11
11
|
missing: Missing[];
|
|
12
12
|
};
|
|
13
13
|
/** `search conversations` and `conversations related`, CLI and MCP alike. */
|
|
14
|
-
export declare const foundConversations: (command: string, found: Readiness & Pick<FoundConversations, "hits" | "accounts" | "words">, limit: number, messenger: Syncing, chat?: string, meta?: Partial<Meta>) => import("../envelope.js").ListBody<unknown>;
|
|
14
|
+
export declare const foundConversations: (command: string, found: Readiness & Pick<FoundConversations, "hits" | "accounts" | "words" | "own">, limit: number, messenger: Syncing, chat?: string, meta?: Partial<Meta>) => import("../envelope.js").ListBody<unknown>;
|
|
15
15
|
/** `conversations status`: each built chat with the model it was measured by; group chats never built are missing. */
|
|
16
16
|
export declare const readinessList: ({ model, chats, unbuiltGroups, }: {
|
|
17
17
|
model: string;
|
|
@@ -54,7 +54,10 @@ export const readinessGaps = ({ meaning, model, readiness, refreshed, coverage }
|
|
|
54
54
|
};
|
|
55
55
|
/** `search conversations` and `conversations related`, CLI and MCP alike. */
|
|
56
56
|
export const foundConversations = (command, found, limit, messenger, chat, meta = {}) => listOf(command, {
|
|
57
|
-
items:
|
|
57
|
+
items: [
|
|
58
|
+
...found.hits.map((hit) => snakeKeys(hit)),
|
|
59
|
+
...(found.own ?? []).map((hit) => ({ ...snakeKeys(hit), from_owner: true })),
|
|
60
|
+
],
|
|
58
61
|
limit,
|
|
59
62
|
has_more: false,
|
|
60
63
|
...readinessGaps(found, messenger, chat),
|
|
@@ -632,7 +632,8 @@ export const conversationsSearchCommand = (messenger) => syncOptions(boundOption
|
|
|
632
632
|
context.renderer.note(`«${found.named.word}» is a name in chat ${found.named.title ?? found.named.chatId} (${found.named.chatId}): its hits come first`);
|
|
633
633
|
if (found.words === "out-of-time")
|
|
634
634
|
context.renderer.note("the word half ran out of time, so these are by meaning alone; --timeout gives it longer");
|
|
635
|
-
renderAnswer(this, context, foundConversations("search conversations", found, limit, messenger, chat, window.meta), () => found.hits.map((hit) => `${hitLine(hit)}\n`).join("")
|
|
635
|
+
renderAnswer(this, context, foundConversations("search conversations", found, limit, messenger, chat, window.meta), () => found.hits.map((hit) => `${hitLine(hit)}\n`).join("") +
|
|
636
|
+
(found.own?.length ? `your own messages:\n${found.own.map((hit) => `${hitLine(hit)}\n`).join("")}` : ""));
|
|
636
637
|
if (found.hits.length === 0 && context.format === "pretty")
|
|
637
638
|
context.renderer.note(found.meaning === "unavailable"
|
|
638
639
|
? "nothing matches in words"
|
package/dist/crm/cli/index.js
CHANGED
|
@@ -211,11 +211,14 @@ const addCrmCommandsDefinition = (program, options) => {
|
|
|
211
211
|
renderAnswer(command, outputFor(command), body, view);
|
|
212
212
|
});
|
|
213
213
|
const example = (command, ...lines) => annotate(command, { examples: lines.map((line) => `${options.app.command} work ${line}`) });
|
|
214
|
-
example(answerEntity(annotate(program.command("sync"), { effects: FETCH, offline: false, cooperative: true, partial: true }), "crm_sync", crmSync)
|
|
215
|
-
"
|
|
216
|
-
"
|
|
217
|
-
"
|
|
218
|
-
|
|
214
|
+
example(answerEntity(annotate(program.command("sync"), { effects: FETCH, offline: false, cooperative: true, partial: true }), "crm_sync", crmSync)
|
|
215
|
+
.description("bring the CRM's copy in the local store up to date: pipelines, companies, contacts, deals and leads that " +
|
|
216
|
+
"changed since the last sync, or everything with --rescan; a run stops before its deadline or " +
|
|
217
|
+
"--max-pages and the next one goes on from there")
|
|
218
|
+
// WireCat Desktop takes a summary of 300 characters at most; the settings' part is help only.
|
|
219
|
+
.addHelpText("after", "\nWith the activities setting on, it also copies the activities and tasks on the deals and leads it keeps. " +
|
|
220
|
+
"Then each deal or lead that moved into a stage the stage-tasks setting names opens a local task, once " +
|
|
221
|
+
"per move."), "sync", "sync --rescan", "sync --max-pages 20")
|
|
219
222
|
.option("--rescan", "list everything again, every id too, dropping a round in progress")
|
|
220
223
|
.option("--max-pages <pages>", "at most this many requests to the CRM in this run", integer(100_000))
|
|
221
224
|
.action(async (opts, command) => {
|
|
@@ -230,11 +230,11 @@ export const crmSourceFromManifest = (input, options) => {
|
|
|
230
230
|
};
|
|
231
231
|
const readChanges = async (kind, cursor, page, context) => {
|
|
232
232
|
const entity = entityOf(kind);
|
|
233
|
-
if (entity.linked && (kind === "person" || kind === "organization"))
|
|
234
|
-
return (await readLinked(kind, page, context));
|
|
235
233
|
const since = cursor === null ? null : Date.parse(cursor);
|
|
236
234
|
if (since !== null && Number.isNaN(since))
|
|
237
235
|
return { reset: true };
|
|
236
|
+
if (entity.linked && (kind === "person" || kind === "organization"))
|
|
237
|
+
return (await readLinked(kind, page, context));
|
|
238
238
|
const { token, started } = pageOf(page, now());
|
|
239
239
|
const send = metered(context);
|
|
240
240
|
const defined = entity.custom ? await fieldsOf(kind, send, context) : [];
|
|
@@ -284,6 +284,20 @@ export const crmManifestFake = (input, options) => {
|
|
|
284
284
|
putList(row, spec.stages.each, stages, node);
|
|
285
285
|
pipelines.set(kind, { rows: [row], id, stages: ids });
|
|
286
286
|
}
|
|
287
|
+
const idAt = (kind, n) => {
|
|
288
|
+
const index = manifest.kinds.indexOf(kind);
|
|
289
|
+
return index < 0 ? undefined : String((index + 1) * 1000 + n + 1);
|
|
290
|
+
};
|
|
291
|
+
/** A deal's people walk a list: its one entry names the contact the deal's row number holds. */
|
|
292
|
+
const linkPeople = (row, rule, node, person) => {
|
|
293
|
+
if (typeof rule !== "object" || !("each" in rule) || !("id" in rule))
|
|
294
|
+
return;
|
|
295
|
+
const entry = itemOf(nodeAt(node, rule.each), definitions);
|
|
296
|
+
const made = sample(entry && narrowed(entry, rule.id.split("."), person));
|
|
297
|
+
const item = isRaw(made) ? made : {};
|
|
298
|
+
put(item, rule.id, person, entry);
|
|
299
|
+
putList(row, rule.each, [item], node);
|
|
300
|
+
};
|
|
287
301
|
const rows = {};
|
|
288
302
|
const changeAt = {};
|
|
289
303
|
for (const [index, kind] of manifest.kinds.entries()) {
|
|
@@ -303,7 +317,11 @@ export const crmManifestFake = (input, options) => {
|
|
|
303
317
|
assignee: "7001",
|
|
304
318
|
...(pipeline ? { pipeline: pipeline.id, stage: pipeline.stages[n % pipeline.stages.length] } : {}),
|
|
305
319
|
...(money ? { amount: "100.50", currency: "EUR" } : { amount: undefined, currency: undefined }),
|
|
320
|
+
...(pipeline && idAt("organization", n) ? { organization: idAt("organization", n) } : {}),
|
|
306
321
|
});
|
|
322
|
+
const person = idAt("person", n);
|
|
323
|
+
if (pipeline && person)
|
|
324
|
+
linkPeople(row, map.people, node, person);
|
|
307
325
|
if (keyset)
|
|
308
326
|
put(row, keyset, time, node);
|
|
309
327
|
return row;
|
|
@@ -0,0 +1,88 @@
|
|
|
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.
|
|
78
|
+
*/
|
|
79
|
+
pending: Record<string, {
|
|
80
|
+
op: FileStepKind;
|
|
81
|
+
operationId: string;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
84
|
+
export interface FileMirrorStatePort {
|
|
85
|
+
read(): FileMirrorState;
|
|
86
|
+
save(state: FileMirrorState): void;
|
|
87
|
+
}
|
|
88
|
+
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";
|
|
7
|
+
export { type MirrorLocalCheck, type MirrorTrigger, type MirrorWatchEvent, type MirrorWatchOptions, watchMirrors, } from "../services/documents/mirror-watch.js";
|
|
8
8
|
export { conflictReport, fileMirrorState, 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, } 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, 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";
|
package/dist/documents/index.js
CHANGED
|
@@ -9,6 +9,8 @@ export { conflictReport, fileMirrorState, mirrorId, mirrorStatus, syncMirrors, }
|
|
|
9
9
|
export { extractDocumentMemories } from "../services/documents/proposals.js";
|
|
10
10
|
export { planPush, pushDocuments, scanLocal, } 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;
|
|
@@ -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
|
|
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
|
|
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
|
-
*
|
|
16
|
-
*
|
|
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
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
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
|
|
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-"));
|
package/dist/errors/reasons.js
CHANGED
|
@@ -220,6 +220,14 @@ 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
|
+
["upload.mismatch", "conflict", "the uploaded file reads back with other content; the local file changed meanwhile"],
|
|
230
|
+
["download.mismatch", "invalid_response", "the downloaded file has other content than the listing said"],
|
|
223
231
|
["catalog.unavailable", "configuration_error", "the store has no shared catalog for this account"],
|
|
224
232
|
["catalog.not-found", "not_found", "the file or folder is not in the local catalog; run catalog import or sync"],
|
|
225
233
|
validation("catalog.depth-invalid", "tree depth must be between 0 and 50"),
|
|
@@ -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",
|
package/dist/sends/upload.js
CHANGED
|
@@ -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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
}
|