@wirecat/cli-core 1.2.0 → 2.0.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 +170 -0
- package/dist/attachments/container.d.ts +1 -1
- package/dist/attachments/container.js +16 -7
- package/dist/attachments/limits.d.ts +10 -0
- package/dist/attachments/limits.js +30 -1
- package/dist/attachments/transfer.js +2 -2
- package/dist/cli/app-doctor-command.d.ts +61 -7
- package/dist/cli/app-doctor-command.js +24 -11
- package/dist/cli/contract-templates.js +3 -0
- package/dist/cli/documents/file-edit.js +6 -6
- package/dist/cli/documents/library.js +4 -2
- package/dist/cli/help/first-screen.js +2 -2
- package/dist/cli/index.d.ts +7 -6
- package/dist/cli/index.js +3 -2
- package/dist/cli/messenger/account-command.js +0 -10
- package/dist/cli/messenger/accounts.d.ts +1 -1
- package/dist/cli/messenger/accounts.js +1 -1
- package/dist/cli/messenger/context.d.ts +17 -1
- package/dist/cli/messenger/doctor-command.js +16 -1
- package/dist/cli/messenger/flooded.js +9 -1
- package/dist/cli/messenger/serve-relay.d.ts +2 -0
- package/dist/cli/messenger/session-commands.d.ts +1 -1
- package/dist/cli/messenger/session-commands.js +1 -1
- package/dist/cli/oauth-session.d.ts +3 -2
- package/dist/cli/oauth-session.js +19 -3
- package/dist/cli/profile-store.d.ts +24 -10
- package/dist/cli/profile-store.js +43 -28
- package/dist/cli/program.js +2 -2
- package/dist/cli/settings.d.ts +3 -3
- package/dist/cli/shared-command-exports.d.ts +1 -1
- package/dist/cli/token-session.d.ts +21 -2
- package/dist/cli/token-session.js +27 -11
- package/dist/crm/cli/files.js +7 -7
- package/dist/documents.d.ts +1 -1
- package/dist/documents.js +1 -1
- package/dist/domain/person-kinds.d.ts +7 -3
- package/dist/domain/person-kinds.js +7 -3
- package/dist/domain/ref-summaries.js +1 -0
- package/dist/domain/references.d.ts +3 -2
- package/dist/domain/references.js +19 -10
- package/dist/entities/deal.d.ts +2 -2
- package/dist/entities/deal.js +1 -1
- package/dist/entities/fact.d.ts +2 -2
- package/dist/entities/fact.js +1 -1
- package/dist/entities/fields.d.ts +1 -1
- package/dist/entities/fields.js +1 -1
- package/dist/entities/index.d.ts +15 -15
- package/dist/entities/mail-findings.d.ts +2 -2
- package/dist/entities/mail-findings.js +1 -1
- package/dist/entities/meeting-findings.d.ts +2 -2
- package/dist/entities/meeting-findings.js +1 -1
- package/dist/entities/memory.d.ts +1 -1
- package/dist/entities/store-maintenance.js +1 -1
- package/dist/entities/task-results.d.ts +5 -5
- package/dist/entities/task-results.js +1 -1
- package/dist/entities/task.d.ts +1 -1
- package/dist/entities/task.js +1 -1
- package/dist/errors/failures.d.ts +6 -0
- package/dist/errors/failures.js +18 -4
- package/dist/errors/reasons.js +2 -1
- package/dist/errors/store-reasons.js +1 -0
- package/dist/fetch/page.js +1 -2
- package/dist/mail/headers.d.ts +4 -3
- package/dist/mail/headers.js +21 -3
- package/dist/mail/sort-rules.d.ts +13 -6
- package/dist/mail/sort-rules.js +20 -16
- package/dist/mail/sync.js +2 -0
- package/dist/mcp/tool.js +2 -2
- package/dist/mcp/tools/attachments.js +1 -1
- package/dist/office/zip.js +1 -1
- package/dist/ports/messenger.d.ts +31 -1
- package/dist/runs/recording.js +2 -2
- package/dist/services/archive.js +61 -11
- package/dist/services/attachments.js +4 -4
- package/dist/services/documents/file-text.js +2 -2
- package/dist/services/metadata.d.ts +1 -1
- package/dist/services/proposals/kinds/shared.d.ts +1 -1
- package/dist/services/proposals/kinds/shared.js +2 -2
- package/dist/services/proposals/kinds/task-close.js +1 -1
- package/dist/store/areas.d.ts +2 -0
- package/dist/store/areas.js +1 -0
- package/dist/store/decisions.d.ts +1 -1
- package/dist/store/decisions.js +4 -4
- package/dist/store/evidence-findings.d.ts +2 -2
- package/dist/store/index.d.ts +3 -1
- package/dist/store/index.js +2 -1
- package/dist/store/mail-findings.d.ts +2 -2
- package/dist/store/meeting-findings.d.ts +2 -2
- package/dist/store/people.d.ts +4 -4
- package/dist/store/people.js +2 -1
- package/dist/store/project-transfer/manifest.js +3 -3
- package/dist/store/public.d.ts +1 -1
- package/dist/store/public.js +1 -1
- package/dist/store/sqlite/actors.d.ts +1 -1
- package/dist/store/sqlite/actors.js +6 -6
- package/dist/store/sqlite/agent-actions.js +2 -2
- package/dist/store/sqlite/agent-links.js +1 -1
- package/dist/store/sqlite/bot-sends.d.ts +19 -0
- package/dist/store/sqlite/bot-sends.js +36 -0
- package/dist/store/sqlite/business-contracts.js +1 -1
- package/dist/store/sqlite/deals.js +1 -1
- package/dist/store/sqlite/document-transfer/plan.js +1 -1
- package/dist/store/sqlite/document-transfer/snapshot.js +1 -1
- package/dist/store/sqlite/email-index.d.ts +11 -2
- package/dist/store/sqlite/email-index.js +56 -5
- package/dist/store/sqlite/email-types.d.ts +15 -3
- package/dist/store/sqlite/email-types.js +32 -1
- package/dist/store/sqlite/emails.d.ts +2 -1
- package/dist/store/sqlite/emails.js +6 -1
- package/dist/store/sqlite/entity-types.d.ts +1 -1
- package/dist/store/sqlite/entity-types.js +1 -1
- package/dist/store/sqlite/evidence-findings.js +1 -1
- package/dist/store/sqlite/facts.js +1 -1
- package/dist/store/sqlite/finance.js +2 -2
- package/dist/store/sqlite/knowledge.js +1 -0
- package/dist/store/sqlite/mail-findings.js +1 -1
- package/dist/store/sqlite/mail-sorting.d.ts +1 -1
- package/dist/store/sqlite/mail-sorting.js +96 -60
- package/dist/store/sqlite/mail-subscriptions.d.ts +70 -0
- package/dist/store/sqlite/mail-subscriptions.js +132 -0
- package/dist/store/sqlite/manifest.js +45 -0
- package/dist/store/sqlite/meeting-findings.js +1 -1
- package/dist/store/sqlite/memories.js +3 -3
- package/dist/store/sqlite/migrations.generated.js +80 -0
- package/dist/store/sqlite/money-transactions.js +1 -1
- package/dist/store/sqlite/note-index.d.ts +4 -1
- package/dist/store/sqlite/note-index.js +40 -17
- package/dist/store/sqlite/orders.js +1 -1
- package/dist/store/sqlite/payment-facts.js +2 -2
- package/dist/store/sqlite/products.js +1 -1
- package/dist/store/sqlite/project-transfer/sources.js +2 -2
- package/dist/store/sqlite/proposed-actions.js +3 -3
- package/dist/store/sqlite/record-projection.js +1 -1
- package/dist/store/sqlite/ref-summaries.js +2 -1
- package/dist/store/sqlite/relation-proposals.js +1 -1
- package/dist/store/sqlite/reviewed.d.ts +2 -2
- package/dist/store/sqlite/reviewed.js +1 -1
- package/dist/store/sqlite/sender-bots.d.ts +19 -4
- package/dist/store/sqlite/sender-bots.js +48 -4
- package/dist/store/sqlite/subscriptions.js +2 -2
- package/dist/store/sqlite/task-close.js +1 -1
- package/dist/store/sqlite/task-comments.js +1 -1
- package/dist/store/sqlite/things.js +1 -1
- package/dist/store/sqlite/transaction.d.ts +5 -0
- package/dist/store/sqlite/transaction.js +6 -1
- package/dist/store/sqlite/wallets.js +1 -1
- package/dist/store/sqlite/work-tasks.js +2 -2
- package/dist/tracker/tasks.js +4 -2
- package/package.json +7 -5
- package/parity.json +9 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { CacheDatabase } from "../driver.js";
|
|
1
|
+
import type { CacheDatabase, SqlValue } from "../driver.js";
|
|
2
2
|
import type { IdentityRef, PersonRecord } from "../types.js";
|
|
3
|
+
import type { BotSends } from "./bot-sends.js";
|
|
3
4
|
import type { StoreContext } from "./open.js";
|
|
4
5
|
import { type Reach, type SenderSignal } from "./sender-signals.js";
|
|
5
6
|
export type BotAuthor = "rules" | "owner";
|
|
@@ -12,7 +13,7 @@ export interface BotIdentity {
|
|
|
12
13
|
}
|
|
13
14
|
/** A program that writes to the owner, apart from people: it has no ties, no tasks and no merge review. @experimental */
|
|
14
15
|
export interface SenderBot {
|
|
15
|
-
/** `
|
|
16
|
+
/** `bot:<id>`. */
|
|
16
17
|
bot: string;
|
|
17
18
|
/** The owner's name for it; `displayName` falls back to its identities'. */
|
|
18
19
|
name: string | null;
|
|
@@ -33,7 +34,7 @@ export interface SenderBot {
|
|
|
33
34
|
/** One move of an identity between a person and a bot. @experimental */
|
|
34
35
|
export interface BotMove {
|
|
35
36
|
identity: IdentityRef;
|
|
36
|
-
/** `person:<uid>` or `
|
|
37
|
+
/** `person:<uid>` or `bot:<id>`; `null` for none. */
|
|
37
38
|
from: string | null;
|
|
38
39
|
to: string | null;
|
|
39
40
|
author: BotAuthor;
|
|
@@ -51,6 +52,8 @@ export interface BotListOptions {
|
|
|
51
52
|
query?: string;
|
|
52
53
|
/** `organization:<id>`: the bots that send for it. */
|
|
53
54
|
organization?: string;
|
|
55
|
+
/** Only bots that send any of these (`BOT_SENDS`). */
|
|
56
|
+
sends?: readonly BotSends[];
|
|
54
57
|
limit: number;
|
|
55
58
|
offset?: number;
|
|
56
59
|
}
|
|
@@ -93,7 +96,11 @@ export declare const hasLegacyBots: (database: CacheDatabase) => boolean;
|
|
|
93
96
|
*/
|
|
94
97
|
export declare const settleLegacyBots: (database: CacheDatabase, at: number) => void;
|
|
95
98
|
/** The sender bots, by name; a bot a build before version 75 sorted shows once a list has settled it. */
|
|
96
|
-
|
|
99
|
+
/** `sent` is `sendsWhere` of `options.sends`, worked out before the read: it may keep mail types. */
|
|
100
|
+
export declare const listBots: (database: CacheDatabase, options: BotListOptions, sent?: {
|
|
101
|
+
sql: string;
|
|
102
|
+
params: SqlValue[];
|
|
103
|
+
}) => BotList;
|
|
97
104
|
/** One sender bot with its identities and every move to or from it. */
|
|
98
105
|
export declare const showBot: (database: CacheDatabase, ref: string) => SenderBotDetails;
|
|
99
106
|
/**
|
|
@@ -115,3 +122,11 @@ export declare const moveToPerson: (context: StoreContext, subject: string | Ide
|
|
|
115
122
|
person?: string;
|
|
116
123
|
reason?: string;
|
|
117
124
|
}) => PersonRecord;
|
|
125
|
+
/** Who put an identity where it is: its bot's author, else its last move's; `rules` when nothing moved it. */
|
|
126
|
+
export declare const holdingAuthorOf: (database: CacheDatabase, identity: number) => BotAuthor;
|
|
127
|
+
/**
|
|
128
|
+
* Puts an identity back where it was held, `person:<id>` or `bot:<id>`, under the author that put it there: a
|
|
129
|
+
* removed sorting rule leaves no owner's mark the owner never made, so the program may sort it again. A bot gone with
|
|
130
|
+
* its last identity comes back as a new one. The caller holds the write lock.
|
|
131
|
+
*/
|
|
132
|
+
export declare const putBack: (context: StoreContext, identity: number, holder: string, author: BotAuthor) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { displayName } from "../../domain/display-names.js";
|
|
3
|
-
import { SENDER_BOT_PREFIX } from "../../domain/person-kinds.js";
|
|
3
|
+
import { SENDER_BOT_PREFIX, senderBotRef } from "../../domain/person-kinds.js";
|
|
4
4
|
import { fold } from "../normalize.js";
|
|
5
5
|
import { groupByDomain, releaseDomainHolds } from "./domain-organizations.js";
|
|
6
6
|
import { currentPerson } from "./merged-persons.js";
|
|
@@ -220,7 +220,8 @@ export const settleLegacyBots = (database, at) => {
|
|
|
220
220
|
database.prepare("DELETE FROM sender_bots WHERE id = ?").run(bot);
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
|
-
const botIdOf = (database,
|
|
223
|
+
const botIdOf = (database, given) => {
|
|
224
|
+
const ref = senderBotRef(given);
|
|
224
225
|
const id = ref.startsWith(SENDER_BOT_PREFIX) ? ref.slice(SENDER_BOT_PREFIX.length) : "";
|
|
225
226
|
const row = /^[1-9]\d*$/.test(id)
|
|
226
227
|
? database.prepare("SELECT id FROM sender_bots WHERE id = ?").get(Number(id))
|
|
@@ -246,7 +247,7 @@ const identityIdOf = (database, { provider, id }) => {
|
|
|
246
247
|
const subjectOf = (database, subject) => {
|
|
247
248
|
if (typeof subject !== "string")
|
|
248
249
|
return { identities: [identityIdOf(database, subject)] };
|
|
249
|
-
if (subject.startsWith(SENDER_BOT_PREFIX)) {
|
|
250
|
+
if (senderBotRef(subject).startsWith(SENDER_BOT_PREFIX)) {
|
|
250
251
|
const bot = botIdOf(database, subject);
|
|
251
252
|
return { bot, identities: botIdentitiesOf(database, bot) };
|
|
252
253
|
}
|
|
@@ -355,7 +356,8 @@ const detailsOf = (database, bot) => {
|
|
|
355
356
|
return { ...found, moves: movesOf(database, bot) };
|
|
356
357
|
};
|
|
357
358
|
/** The sender bots, by name; a bot a build before version 75 sorted shows once a list has settled it. */
|
|
358
|
-
|
|
359
|
+
/** `sent` is `sendsWhere` of `options.sends`, worked out before the read: it may keep mail types. */
|
|
360
|
+
export const listBots = (database, options, sent) => {
|
|
359
361
|
const { limit, offset = 0 } = options;
|
|
360
362
|
const where = [HOLDS];
|
|
361
363
|
const params = [];
|
|
@@ -378,6 +380,11 @@ export const listBots = (database, options) => {
|
|
|
378
380
|
where.push("b.organization_id = ?");
|
|
379
381
|
params.push(Number(id));
|
|
380
382
|
}
|
|
383
|
+
if (sent !== undefined) {
|
|
384
|
+
where.push(sent.sql);
|
|
385
|
+
for (const param of sent.params)
|
|
386
|
+
params.push(param);
|
|
387
|
+
}
|
|
381
388
|
return read(database, () => {
|
|
382
389
|
const filter = where.join(" AND ");
|
|
383
390
|
const total = Number(database.prepare(`SELECT count(*) AS n FROM sender_bots b WHERE ${filter}`).get(...params)?.n);
|
|
@@ -468,3 +475,40 @@ export const moveToPerson = (context, subject, options = {}) => {
|
|
|
468
475
|
return recordOf(context, first ?? target ?? chosen.person);
|
|
469
476
|
});
|
|
470
477
|
};
|
|
478
|
+
/** Who put an identity where it is: its bot's author, else its last move's; `rules` when nothing moved it. */
|
|
479
|
+
export const holdingAuthorOf = (database, identity) => {
|
|
480
|
+
const { bot } = holderOf(database, identity);
|
|
481
|
+
const row = bot === undefined
|
|
482
|
+
? database
|
|
483
|
+
.prepare("SELECT author FROM sender_bot_moves WHERE identity_id = ? ORDER BY id DESC LIMIT 1")
|
|
484
|
+
.get(identity)
|
|
485
|
+
: database.prepare("SELECT author FROM sender_bots WHERE id = ?").get(bot);
|
|
486
|
+
return row?.author === "owner" ? "owner" : "rules";
|
|
487
|
+
};
|
|
488
|
+
/**
|
|
489
|
+
* Puts an identity back where it was held, `person:<id>` or `bot:<id>`, under the author that put it there: a
|
|
490
|
+
* removed sorting rule leaves no owner's mark the owner never made, so the program may sort it again. A bot gone with
|
|
491
|
+
* its last identity comes back as a new one. The caller holds the write lock.
|
|
492
|
+
*/
|
|
493
|
+
export const putBack = (context, identity, holder, author) => {
|
|
494
|
+
const { database } = context;
|
|
495
|
+
const at = context.now();
|
|
496
|
+
const log = { author, reason: "a mail sorting rule was removed", at };
|
|
497
|
+
if (holder.startsWith(SENDER_BOT_PREFIX)) {
|
|
498
|
+
const kept = Number(holder.slice(SENDER_BOT_PREFIX.length));
|
|
499
|
+
const bot = database.prepare("SELECT 1 FROM sender_bots WHERE id = ?").get(kept) === undefined
|
|
500
|
+
? createBot(database, log)
|
|
501
|
+
: kept;
|
|
502
|
+
for (const [person, gone] of intoBot(database, [identity], bot, log))
|
|
503
|
+
if (identitiesOf(database, person).length > 0)
|
|
504
|
+
renameAfterLeaving(context, person, gone);
|
|
505
|
+
groupByDomain(database, [{ id: bot, displayName: null, holds: true, bot: true }], at);
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
const person = Number(holder.slice("person:".length));
|
|
509
|
+
const target = database.prepare("SELECT 1 FROM persons WHERE id = ?").get(person) === undefined
|
|
510
|
+
? undefined
|
|
511
|
+
: currentPerson(database, person);
|
|
512
|
+
outOfBot(database, [identity], target, log);
|
|
513
|
+
releaseDomainHolds(database, [identity]);
|
|
514
|
+
};
|
|
@@ -9,9 +9,9 @@ import { iso, isoDate, limitOf, oneOf, reasonOf, refuse, reviewedRowsOver, text,
|
|
|
9
9
|
import { pageOfRows } from "./rows-page.js";
|
|
10
10
|
import { write } from "./transaction.js";
|
|
11
11
|
const SUBSCRIPTIONS = "SELECT s.*, b.name AS author_name, b.kind AS author_kind FROM subscriptions s " +
|
|
12
|
-
"LEFT JOIN bots b ON s.author_type = '
|
|
12
|
+
"LEFT JOIN bots b ON s.author_type = 'agent' AND b.id = s.author_id";
|
|
13
13
|
const PRICES = "SELECT p.*, b.name AS author_name, b.kind AS author_kind FROM subscription_prices p " +
|
|
14
|
-
"LEFT JOIN bots b ON p.author_type = '
|
|
14
|
+
"LEFT JOIN bots b ON p.author_type = 'agent' AND b.id = p.author_id";
|
|
15
15
|
const PRICE_REF = /^subscription_price:([1-9]\d{0,15})$/;
|
|
16
16
|
export const subscriptionOperationsOver = (context) => {
|
|
17
17
|
const { database, now } = context;
|
|
@@ -44,7 +44,7 @@ export const saveAgentClose = (database, change, now) => {
|
|
|
44
44
|
export const closeSuggestionOf = (database, row) => {
|
|
45
45
|
if (row.close_suggested_as == null)
|
|
46
46
|
return null;
|
|
47
|
-
const name = row.close_suggested_by_type === "
|
|
47
|
+
const name = row.close_suggested_by_type === "agent"
|
|
48
48
|
? database.prepare("SELECT name FROM bots WHERE id = ?").get(Number(row.close_suggested_by_id))?.name
|
|
49
49
|
: "owner";
|
|
50
50
|
return {
|
|
@@ -4,7 +4,7 @@ export const authorNamed = (database, row) => {
|
|
|
4
4
|
if (row.author_type == null)
|
|
5
5
|
return null;
|
|
6
6
|
const named = database
|
|
7
|
-
.prepare(row.author_type === "
|
|
7
|
+
.prepare(row.author_type === "agent"
|
|
8
8
|
? "SELECT name, 0 AS owner FROM bots WHERE id = ?"
|
|
9
9
|
: "SELECT name, owner FROM persons WHERE id = ?")
|
|
10
10
|
.get(Number(row.author_id));
|
|
@@ -14,7 +14,7 @@ const REFERABLE = {
|
|
|
14
14
|
task: { tombstone: true },
|
|
15
15
|
memory: { tombstone: true },
|
|
16
16
|
fact: { tombstone: true },
|
|
17
|
-
|
|
17
|
+
agent: { tombstone: false },
|
|
18
18
|
event: { tombstone: true },
|
|
19
19
|
message: { tombstone: true },
|
|
20
20
|
email: { tombstone: true },
|
|
@@ -29,6 +29,11 @@ export declare const write: <T>(database: CacheDatabase, body: () => T, { before
|
|
|
29
29
|
* process's `write` a gap of microseconds, and it misses that gap until its 5 s wait runs out.
|
|
30
30
|
*/
|
|
31
31
|
export declare const writeBatch: <T>(database: CacheDatabase, body: () => T) => T;
|
|
32
|
+
/**
|
|
33
|
+
* A short pause between two writes of one loop: another process waiting for the lock tries every millisecond, and a
|
|
34
|
+
* loop that begins again at once leaves it a gap of microseconds, so it waits out its 5 s however short each write is.
|
|
35
|
+
*/
|
|
36
|
+
export declare const letWaitersIn: () => void;
|
|
32
37
|
/** Whether a dry run holds a connection of this process now. */
|
|
33
38
|
export declare const rehearsing: () => boolean;
|
|
34
39
|
/** Calls `call` outside any dry run: a statement it runs is refused while one holds the connection. */
|
|
@@ -72,6 +72,11 @@ export const write = (database, body, { beforeCommit } = {}) => transact(databas
|
|
|
72
72
|
*/
|
|
73
73
|
export const writeBatch = (database, body) => transact(database, body, false);
|
|
74
74
|
const BATCH_PAUSE_MS = 2;
|
|
75
|
+
/**
|
|
76
|
+
* A short pause between two writes of one loop: another process waiting for the lock tries every millisecond, and a
|
|
77
|
+
* loop that begins again at once leaves it a gap of microseconds, so it waits out its 5 s however short each write is.
|
|
78
|
+
*/
|
|
79
|
+
export const letWaitersIn = () => void Atomics.wait(pause, 0, 0, BATCH_PAUSE_MS);
|
|
75
80
|
const transact = (database, body, drain, beforeCommit) => {
|
|
76
81
|
const connection = connectionOf(database);
|
|
77
82
|
if (connection.reading)
|
|
@@ -100,7 +105,7 @@ const transact = (database, body, drain, beforeCommit) => {
|
|
|
100
105
|
// A write that had to wait has others waiting behind it, and its caller's next write would begin before they see
|
|
101
106
|
// the lock free. Pausing only then costs an uncontended write nothing.
|
|
102
107
|
if (outer && (waited || !drain))
|
|
103
|
-
|
|
108
|
+
letWaitersIn();
|
|
104
109
|
return result;
|
|
105
110
|
}
|
|
106
111
|
catch (error) {
|
|
@@ -7,7 +7,7 @@ import { iso, isoDate, limitOf, oneOf, refuse, reviewedRowsOver, text, } from ".
|
|
|
7
7
|
import { pageOfRows } from "./rows-page.js";
|
|
8
8
|
import { write } from "./transaction.js";
|
|
9
9
|
const WALLETS = "SELECT w.*, b.name AS author_name, b.kind AS author_kind FROM financial_accounts w " +
|
|
10
|
-
"LEFT JOIN bots b ON w.author_type = '
|
|
10
|
+
"LEFT JOIN bots b ON w.author_type = 'agent' AND b.id = w.author_id";
|
|
11
11
|
const SIGNED = "CASE t.direction WHEN 'in' THEN t.amount ELSE -t.amount END";
|
|
12
12
|
export const walletOperationsOver = (context) => {
|
|
13
13
|
const { database, now } = context;
|
|
@@ -645,9 +645,9 @@ export const workTaskOperationsOver = (context) => {
|
|
|
645
645
|
comments: async (id) => commentsOf(database, required(id)),
|
|
646
646
|
events: async (id) => database
|
|
647
647
|
.prepare("SELECT e.actor_type, e.actor_id, e.kind, e.changes, e.created_at, " +
|
|
648
|
-
"CASE e.actor_type WHEN 'person' THEN p.name WHEN '
|
|
648
|
+
"CASE e.actor_type WHEN 'person' THEN p.name WHEN 'agent' THEN b.name END AS actor_name FROM task_events e " +
|
|
649
649
|
"LEFT JOIN persons p ON e.actor_type = 'person' AND p.id = e.actor_id " +
|
|
650
|
-
"LEFT JOIN bots b ON e.actor_type = '
|
|
650
|
+
"LEFT JOIN bots b ON e.actor_type = 'agent' AND b.id = e.actor_id WHERE e.task_id = ? ORDER BY e.id")
|
|
651
651
|
.all(required(id))
|
|
652
652
|
.map((row) => ({
|
|
653
653
|
kind: row.kind,
|
package/dist/tracker/tasks.js
CHANGED
|
@@ -73,13 +73,15 @@ const PICKED = "tracker:owner-picks";
|
|
|
73
73
|
*/
|
|
74
74
|
const lastClose = async (store, id) => {
|
|
75
75
|
const statuses = (await store.tasks.events(id)).filter((event) => event.kind === "status");
|
|
76
|
-
const at = statuses.findLastIndex((event) => event.actor?.type === "
|
|
76
|
+
const at = statuses.findLastIndex((event) => event.actor?.type === "agent" &&
|
|
77
|
+
event.actor.name === SYNC.bot &&
|
|
78
|
+
isClosedState(String(event.changes?.status?.[1])));
|
|
77
79
|
if (at < 0)
|
|
78
80
|
return undefined;
|
|
79
81
|
const from = statuses[at]?.changes?.status?.[0];
|
|
80
82
|
return {
|
|
81
83
|
from: typeof from === "string" && !isClosedState(from) ? from : "open",
|
|
82
|
-
owner: statuses.slice(at + 1).find((event) => event.actor?.type !== "
|
|
84
|
+
owner: statuses.slice(at + 1).find((event) => event.actor?.type !== "agent")?.at,
|
|
83
85
|
};
|
|
84
86
|
};
|
|
85
87
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.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",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"./update"
|
|
28
28
|
],
|
|
29
29
|
"store": {
|
|
30
|
-
"speaks":
|
|
31
|
-
"minCompatible":
|
|
30
|
+
"speaks": 78,
|
|
31
|
+
"minCompatible": 78
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
@@ -267,7 +267,8 @@
|
|
|
267
267
|
"lint:fix": "biome check --write .",
|
|
268
268
|
"db:generate": "drizzle-kit generate",
|
|
269
269
|
"db:bundle": "node scripts/bundle-migrations.ts",
|
|
270
|
-
"docs:check": "pnpm build &&
|
|
270
|
+
"docs:check": "pnpm build && pnpm docs:check:built",
|
|
271
|
+
"docs:check:built": "node --experimental-strip-types scripts/docs-check.ts && node scripts/search-docs.ts --check && node scripts/standard-docs.ts --check && node scripts/reasons-docs.ts --check",
|
|
271
272
|
"standard:docs": "node scripts/standard-docs.ts",
|
|
272
273
|
"test": "vitest run",
|
|
273
274
|
"test:watch": "vitest",
|
|
@@ -284,7 +285,8 @@
|
|
|
284
285
|
"parity:render": "node --experimental-strip-types scripts/parity-render.ts",
|
|
285
286
|
"parity:audit": "tsc --build && node --experimental-strip-types scripts/parity-audit.ts",
|
|
286
287
|
"search:docs": "pnpm build && node scripts/search-docs.ts",
|
|
287
|
-
"check:agent-process": "pnpm build &&
|
|
288
|
+
"check:agent-process": "pnpm build && pnpm check:agent-process:built",
|
|
289
|
+
"check:agent-process:built": "node --experimental-strip-types scripts/check-agent-process.ts",
|
|
288
290
|
"standards:check": "node config/wirecat/check.mjs",
|
|
289
291
|
"docs:images": "node docs/images/src/render.ts",
|
|
290
292
|
"docs:lint": "markdownlint-cli2",
|
package/parity.json
CHANGED
|
@@ -1226,9 +1226,6 @@
|
|
|
1226
1226
|
"account": {
|
|
1227
1227
|
"in": "all"
|
|
1228
1228
|
},
|
|
1229
|
-
"account list": {
|
|
1230
|
-
"in": "all"
|
|
1231
|
-
},
|
|
1232
1229
|
"account privacy": {
|
|
1233
1230
|
"in": ["max"],
|
|
1234
1231
|
"planned": {
|
|
@@ -4525,6 +4522,9 @@
|
|
|
4525
4522
|
"session end": {
|
|
4526
4523
|
"in": "all"
|
|
4527
4524
|
},
|
|
4525
|
+
"session list": {
|
|
4526
|
+
"in": "all"
|
|
4527
|
+
},
|
|
4528
4528
|
"session start": {
|
|
4529
4529
|
"in": "all",
|
|
4530
4530
|
"options": {
|
|
@@ -4548,6 +4548,12 @@
|
|
|
4548
4548
|
}
|
|
4549
4549
|
}
|
|
4550
4550
|
},
|
|
4551
|
+
"session status": {
|
|
4552
|
+
"in": "all",
|
|
4553
|
+
"options": {
|
|
4554
|
+
"--check": "all"
|
|
4555
|
+
}
|
|
4556
|
+
},
|
|
4551
4557
|
"setup": {
|
|
4552
4558
|
"in": "all",
|
|
4553
4559
|
"options": {
|