@wirecat/cli-core 0.410.0 → 0.412.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 (113) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/cli/bot/command.js +4 -3
  3. package/dist/cli/bot/messages-sync.d.ts +7 -0
  4. package/dist/cli/bot/{store.js → messages-sync.js} +4 -5
  5. package/dist/cli/bot/port.d.ts +4 -4
  6. package/dist/cli/bot/setup.js +11 -5
  7. package/dist/cli/commands-command.js +18 -12
  8. package/dist/cli/config-command.js +1 -0
  9. package/dist/cli/contract-evidence.d.ts +26 -0
  10. package/dist/cli/contract-evidence.js +58 -0
  11. package/dist/cli/contract-templates.d.ts +4 -0
  12. package/dist/cli/contract-templates.js +83 -0
  13. package/dist/cli/discovery-descriptions.d.ts +4 -0
  14. package/dist/cli/discovery-descriptions.js +4 -0
  15. package/dist/cli/index.d.ts +21 -55
  16. package/dist/cli/index.js +18 -55
  17. package/dist/cli/messenger/chat-answers.d.ts +1 -1
  18. package/dist/cli/messenger/chat-answers.js +1 -1
  19. package/dist/cli/messenger/chat-lists.d.ts +1 -1
  20. package/dist/cli/messenger/chats-command.js +3 -0
  21. package/dist/cli/messenger/contacts-command.js +23 -15
  22. package/dist/cli/messenger/guard-commands.d.ts +5 -1
  23. package/dist/cli/messenger/guard-commands.js +5 -3
  24. package/dist/cli/messenger/messages-press-command.js +4 -1
  25. package/dist/cli/messenger/models-command.js +3 -11
  26. package/dist/cli/messenger/records-command.js +1 -1
  27. package/dist/cli/messenger/store-maintenance-command.d.ts +1 -1
  28. package/dist/cli/messenger/tasks-command.js +14 -4
  29. package/dist/cli/model-catalogue-command.d.ts +15 -0
  30. package/dist/cli/model-catalogue-command.js +110 -0
  31. package/dist/cli/moved.js +1 -0
  32. package/dist/cli/program.js +2 -0
  33. package/dist/cli/runs/search-command.js +2 -3
  34. package/dist/cli/runs/search-query.d.ts +1 -1
  35. package/dist/cli/runs/search-query.js +18 -2
  36. package/dist/cli/runs/search.d.ts +2 -1
  37. package/dist/cli/runs/search.js +4 -3
  38. package/dist/cli/settings.d.ts +2 -0
  39. package/dist/cli/settings.js +5 -1
  40. package/dist/cli/shared-command-exports.d.ts +644 -0
  41. package/dist/cli/shared-command-exports.js +114 -0
  42. package/dist/cli/shared-contracts.d.ts +1 -0
  43. package/dist/cli/shared-contracts.js +1 -0
  44. package/dist/domain/providers.d.ts +25 -3
  45. package/dist/domain/providers.js +89 -5
  46. package/dist/entities/chat.d.ts +3 -3
  47. package/dist/entities/chat.js +2 -2
  48. package/dist/entities/contact-context.d.ts +8 -8
  49. package/dist/entities/contact.d.ts +4 -4
  50. package/dist/entities/index.d.ts +40 -13
  51. package/dist/entities/index.js +5 -1
  52. package/dist/entities/knowledge-lists.d.ts +28 -0
  53. package/dist/entities/knowledge-lists.js +29 -0
  54. package/dist/entities/list-results.d.ts +1 -1
  55. package/dist/entities/list-results.js +1 -1
  56. package/dist/entities/send-attempt.d.ts +0 -1
  57. package/dist/entities/send-attempt.js +0 -1
  58. package/dist/errors/reasons.d.ts +1 -1
  59. package/dist/errors/reasons.js +7 -0
  60. package/dist/index.d.ts +1 -0
  61. package/dist/index.js +1 -0
  62. package/dist/meetings/cli/index.d.ts +1 -1
  63. package/dist/meetings/cli/index.js +25 -9
  64. package/dist/meetings/cli/passage.d.ts +0 -1
  65. package/dist/meetings/cli/passage.js +5 -3
  66. package/dist/meetings/cli/project-evidence.js +3 -2
  67. package/dist/meetings/cli/search.d.ts +2 -2
  68. package/dist/meetings/cli/search.js +9 -7
  69. package/dist/meetings/event-query.d.ts +1 -0
  70. package/dist/meetings/event-query.js +15 -0
  71. package/dist/meetings/index.d.ts +1 -0
  72. package/dist/meetings/index.js +1 -0
  73. package/dist/meetings/store.d.ts +2 -0
  74. package/dist/meetings/testing/memory.js +5 -0
  75. package/dist/search/account-list.d.ts +5 -2
  76. package/dist/search/account-list.js +27 -11
  77. package/dist/search/query.js +3 -1
  78. package/dist/sends/permission-aliases.js +1 -0
  79. package/dist/services/documents/knowledge.d.ts +5 -3
  80. package/dist/services/documents/knowledge.js +4 -4
  81. package/dist/services/meeting-links.d.ts +3 -1
  82. package/dist/services/meeting-links.js +2 -2
  83. package/dist/services/messages-search.js +15 -3
  84. package/dist/services/search-all.js +5 -2
  85. package/dist/services/tasks.d.ts +2 -0
  86. package/dist/services/tasks.js +6 -4
  87. package/dist/store/accounts.d.ts +3 -0
  88. package/dist/store/accounts.js +2 -0
  89. package/dist/store/exports.d.ts +1 -0
  90. package/dist/store/exports.js +1 -0
  91. package/dist/store/index.d.ts +3 -1
  92. package/dist/store/index.js +2 -0
  93. package/dist/store/knowledge-query.d.ts +6 -0
  94. package/dist/store/knowledge-query.js +34 -0
  95. package/dist/store/providers.d.ts +7 -0
  96. package/dist/store/providers.js +5 -0
  97. package/dist/store/sqlite/events.d.ts +2 -1
  98. package/dist/store/sqlite/events.js +16 -1
  99. package/dist/store/sqlite/knowledge.d.ts +5 -4
  100. package/dist/store/sqlite/knowledge.js +50 -17
  101. package/dist/store/sqlite/mail-rules.d.ts +2 -1
  102. package/dist/store/sqlite/mail-rules.js +12 -2
  103. package/dist/store/sqlite/meetings.js +3 -0
  104. package/dist/store/sqlite/notes.d.ts +11 -5
  105. package/dist/store/sqlite/notes.js +9 -2
  106. package/dist/store/sqlite/open-store.js +2 -0
  107. package/dist/store/sqlite/providers.d.ts +12 -0
  108. package/dist/store/sqlite/providers.js +45 -0
  109. package/dist/store/sqlite/tags.d.ts +1 -1
  110. package/dist/store/sqlite/tags.js +3 -3
  111. package/package.json +3 -3
  112. package/parity.json +92 -111
  113. package/dist/cli/bot/store.d.ts +0 -7
@@ -1,9 +1,15 @@
1
- import { defineQuery, parseLucene, queryError, validateQuery } from "@wirecat/cli-base/query";
2
- import { LIST_QUERY_GUIDE, termField, typedQuery } from "../list-query.js";
1
+ import { defineQuery, parseLucene, queryError, validateQuery, } from "@wirecat/cli-base/query";
2
+ import { LIST_QUERY_GUIDE, nativeField, termField, timeBounds, typedQuery } from "../list-query.js";
3
3
  export const RUN_SEARCH_QUERY = defineQuery({
4
4
  entity: "run",
5
5
  backend: "native",
6
6
  fields: [
7
+ nativeField({
8
+ name: "started_at",
9
+ type: "time",
10
+ operators: ["term", "phrase", "range"],
11
+ example: "started_at>=7d",
12
+ }),
7
13
  termField("text", "kw", "text:timeout"),
8
14
  termField("status", "enum", "status:failed", { values: ["success", "failed", "partial", "running"] }),
9
15
  termField("error_code", "kw", "error_code:rate_limited"),
@@ -20,6 +26,7 @@ export const runSearchFilter = (words) => {
20
26
  validateQuery(ast, RUN_SEARCH_QUERY, context);
21
27
  const terms = [];
22
28
  const fields = new Map();
29
+ let started;
23
30
  const add = (node) => {
24
31
  if (node.kind === "boolean") {
25
32
  for (const clause of node.clauses) {
@@ -29,6 +36,12 @@ export const runSearchFilter = (words) => {
29
36
  }
30
37
  return;
31
38
  }
39
+ if (node.field === "started_at") {
40
+ if (started)
41
+ queryError("query.unsupported-placement", node.span, "started_at only once here; use a range", context);
42
+ started = node;
43
+ return;
44
+ }
32
45
  if (node.operator !== "term" && node.operator !== "phrase")
33
46
  queryError("query.unsupported-placement", node.span, "run search takes literal words and field:value terms", context);
34
47
  if (node.field === "text")
@@ -40,7 +53,10 @@ export const runSearchFilter = (words) => {
40
53
  }
41
54
  };
42
55
  add(ast.root);
56
+ const window = timeBounds(started);
43
57
  return {
58
+ ...(window.since === undefined ? {} : { since: new Date(window.since).toISOString() }),
59
+ ...(window.until === undefined ? {} : { until: new Date(window.until).toISOString() }),
44
60
  ...(terms.length ? { terms } : {}),
45
61
  ...(fields.has("status") ? { status: fields.get("status")?.toLowerCase() } : {}),
46
62
  ...(fields.has("error_code") ? { errorCode: fields.get("error_code") } : {}),
@@ -6,10 +6,11 @@ export interface RunSearch {
6
6
  operation?: string;
7
7
  profile?: string;
8
8
  since?: string;
9
+ until?: string;
9
10
  limit?: number;
10
11
  page?: number;
11
12
  }
12
- export declare const searchRuns: (dir: string, { query, terms, status, errorCode, operation, profile, since, limit, page }?: RunSearch) => {
13
+ export declare const searchRuns: (dir: string, { query, terms, status, errorCode, operation, profile, since, until, limit, page }?: RunSearch) => {
13
14
  items: {
14
15
  runId: string;
15
16
  command: string;
@@ -32,10 +32,10 @@ const safeEvent = (event) => Object.fromEntries(FIELDS.flatMap((name) => {
32
32
  }
33
33
  return typeof value === "string" || typeof value === "number" ? [[name, value]] : [];
34
34
  }));
35
- export const searchRuns = (dir, { query = "", terms = [], status, errorCode, operation, profile, since, limit = 20, page = 1 } = {}) => {
35
+ export const searchRuns = (dir, { query = "", terms = [], status, errorCode, operation, profile, since, until, limit = 20, page = 1 } = {}) => {
36
36
  if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100 || !Number.isSafeInteger(page) || page < 1)
37
37
  throw new CliError("validation_error", "run search uses a limit from 1 to 100 and a positive page");
38
- const window = dateWindow(since === undefined ? {} : { sinceTime: since });
38
+ const window = dateWindow({ sinceTime: since, untilTime: until });
39
39
  const from = window.since;
40
40
  if (from !== undefined && !Number.isFinite(from))
41
41
  throw new CliError("validation_error", "--since-time must be a valid date or ISO timestamp");
@@ -45,7 +45,8 @@ export const searchRuns = (dir, { query = "", terms = [], status, errorCode, ope
45
45
  for (const run of listRuns(dir, from === undefined ? {} : { since: from })) {
46
46
  if ((profile !== undefined && run.profile !== profile) ||
47
47
  (status !== undefined && run.status !== status) ||
48
- (from !== undefined && Date.parse(run.startedAt) < from))
48
+ (from !== undefined && Date.parse(run.startedAt) < from) ||
49
+ (window.until !== undefined && Date.parse(run.startedAt) > window.until))
49
50
  continue;
50
51
  const metadataMatch = (!errorCode ||
51
52
  run.errorCode === errorCode ||
@@ -140,6 +140,8 @@ export interface ResolveOptions {
140
140
  needsProfile?: boolean;
141
141
  /** Read the config file without writing it: no default file. For a dry run. */
142
142
  readOnly?: boolean;
143
+ /** Skip moved permission keys instead of refusing them, so `config set` and `unset` can fix one. */
144
+ skipMovedPermissions?: boolean;
143
145
  }
144
146
  /** Where `profile` came from when none was named and the command needs none. */
145
147
  export declare const NONE_NAMED = "none named";
@@ -4,6 +4,7 @@ import * as v from "valibot";
4
4
  import { AI_ENTRIES, resolveAISettings } from "../analysis/settings.js";
5
5
  import { parseDuration } from "../domain/duration.js";
6
6
  import { envName, readOnlyLockOf } from "../ports/app.js";
7
+ import { canonicalPermissionKey } from "../sends/permission-aliases.js";
7
8
  import { assertOverridesTighten, CEILING_KEY, LEVELS, layerPermissions, permissionOverrides, RESOURCES, } from "../sends/permissions.js";
8
9
  import { storePath } from "../store/path.js";
9
10
  import { sharedConfigPath } from "../store/shared-config.js";
@@ -77,6 +78,7 @@ const SHARED_DEFAULTS_ONLY = {
77
78
  update_check: v.optional(flag),
78
79
  skill_hint: v.optional(flag),
79
80
  };
81
+ const withoutMoved = (levels) => levels && Object.fromEntries(Object.entries(levels).filter(([key]) => canonicalPermissionKey(key) === key));
80
82
  /** Where `profile` came from when none was named and the command needs none. */
81
83
  export const NONE_NAMED = "none named";
82
84
  /** A name for a command that speaks for no account; never chosen for one that does. */
@@ -230,7 +232,9 @@ export const settingsFor = (app, extension = {}) => {
230
232
  : { value: false, from: "default" };
231
233
  const fileLayers = layers.map(([from, scope]) => [
232
234
  from,
233
- scope?.permissions,
235
+ options.skipMovedPermissions
236
+ ? withoutMoved(scope?.permissions)
237
+ : scope?.permissions,
234
238
  ]);
235
239
  const overrides = permissionOverrides(flags.permission);
236
240
  assertOverridesTighten(overrides, layerPermissions(fileLayers).levels);