@indigoai-us/hq-cli 5.108.1 → 5.108.2

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 (106) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/assets/mesh-daemon/README.md +23 -0
  3. package/assets/mesh-daemon/launchd.plist.template +33 -0
  4. package/assets/mesh-daemon/systemd.system.service.template +27 -0
  5. package/assets/mesh-daemon/systemd.user.service.template +18 -0
  6. package/assets/scaffold/core/scripts/lib/work-mesh-enqueue.sh +267 -0
  7. package/dist/commands/core.js +5 -4
  8. package/dist/commands/mesh.d.ts +15 -0
  9. package/dist/commands/mesh.js +732 -4
  10. package/dist/commands/search.d.ts +23 -0
  11. package/dist/commands/search.js +42 -1
  12. package/dist/lib/doctor/checks/work-context.d.ts +23 -0
  13. package/dist/lib/doctor/checks/work-context.js +195 -0
  14. package/dist/lib/doctor/registry.js +4 -0
  15. package/dist/lib/mesh/api.d.ts +18 -0
  16. package/dist/lib/mesh/api.js +55 -0
  17. package/dist/lib/mesh/cache.js +35 -4
  18. package/dist/lib/mesh/client.d.ts +118 -0
  19. package/dist/lib/mesh/client.js +268 -0
  20. package/dist/lib/mesh/live/backoff.d.ts +16 -0
  21. package/dist/lib/mesh/live/backoff.js +20 -0
  22. package/dist/lib/mesh/live/daemon/board-refresh.d.ts +49 -0
  23. package/dist/lib/mesh/live/daemon/board-refresh.js +185 -0
  24. package/dist/lib/mesh/live/daemon/credentials.d.ts +71 -0
  25. package/dist/lib/mesh/live/daemon/credentials.js +227 -0
  26. package/dist/lib/mesh/live/daemon/doctor.d.ts +37 -0
  27. package/dist/lib/mesh/live/daemon/doctor.js +139 -0
  28. package/dist/lib/mesh/live/daemon/index.d.ts +24 -0
  29. package/dist/lib/mesh/live/daemon/index.js +14 -0
  30. package/dist/lib/mesh/live/daemon/install.d.ts +83 -0
  31. package/dist/lib/mesh/live/daemon/install.js +330 -0
  32. package/dist/lib/mesh/live/daemon/log.d.ts +11 -0
  33. package/dist/lib/mesh/live/daemon/log.js +79 -0
  34. package/dist/lib/mesh/live/daemon/paths.d.ts +18 -0
  35. package/dist/lib/mesh/live/daemon/paths.js +31 -0
  36. package/dist/lib/mesh/live/daemon/pid-lock.d.ts +48 -0
  37. package/dist/lib/mesh/live/daemon/pid-lock.js +134 -0
  38. package/dist/lib/mesh/live/daemon/presence.d.ts +101 -0
  39. package/dist/lib/mesh/live/daemon/presence.js +250 -0
  40. package/dist/lib/mesh/live/daemon/presign.d.ts +18 -0
  41. package/dist/lib/mesh/live/daemon/presign.js +65 -0
  42. package/dist/lib/mesh/live/daemon/run.d.ts +74 -0
  43. package/dist/lib/mesh/live/daemon/run.js +400 -0
  44. package/dist/lib/mesh/live/daemon/state.d.ts +24 -0
  45. package/dist/lib/mesh/live/daemon/state.js +57 -0
  46. package/dist/lib/mesh/live/daemon/transcript-watch.d.ts +170 -0
  47. package/dist/lib/mesh/live/daemon/transcript-watch.js +520 -0
  48. package/dist/lib/mesh/live/enqueue.d.ts +48 -0
  49. package/dist/lib/mesh/live/enqueue.js +100 -0
  50. package/dist/lib/mesh/live/flush.d.ts +56 -0
  51. package/dist/lib/mesh/live/flush.js +360 -0
  52. package/dist/lib/mesh/live/format-spool-line.d.ts +42 -0
  53. package/dist/lib/mesh/live/format-spool-line.js +106 -0
  54. package/dist/lib/mesh/live/index.d.ts +22 -0
  55. package/dist/lib/mesh/live/index.js +16 -0
  56. package/dist/lib/mesh/live/paths.d.ts +13 -0
  57. package/dist/lib/mesh/live/paths.js +30 -0
  58. package/dist/lib/mesh/live/session-events-client.d.ts +58 -0
  59. package/dist/lib/mesh/live/session-events-client.js +120 -0
  60. package/dist/lib/mesh/live/session-identity.d.ts +39 -0
  61. package/dist/lib/mesh/live/session-identity.js +91 -0
  62. package/dist/lib/mesh/live/spool.d.ts +52 -0
  63. package/dist/lib/mesh/live/spool.js +193 -0
  64. package/dist/lib/mesh/live/ulid.d.ts +12 -0
  65. package/dist/lib/mesh/live/ulid.js +39 -0
  66. package/dist/lib/mesh/live/validate-session-event.d.ts +39 -0
  67. package/dist/lib/mesh/live/validate-session-event.js +128 -0
  68. package/dist/lib/search-index/index.d.ts +45 -0
  69. package/dist/lib/search-index/index.js +76 -0
  70. package/dist/lib/work-context/atomic.d.ts +18 -0
  71. package/dist/lib/work-context/atomic.js +132 -0
  72. package/dist/lib/work-context/company.d.ts +103 -0
  73. package/dist/lib/work-context/company.js +274 -0
  74. package/dist/lib/work-context/config.d.ts +59 -0
  75. package/dist/lib/work-context/config.js +172 -0
  76. package/dist/lib/work-context/contract.d.ts +81 -0
  77. package/dist/lib/work-context/contract.js +65 -0
  78. package/dist/lib/work-context/errors.d.ts +27 -0
  79. package/dist/lib/work-context/errors.js +46 -0
  80. package/dist/lib/work-context/index.d.ts +23 -0
  81. package/dist/lib/work-context/index.js +20 -0
  82. package/dist/lib/work-context/migrate.d.ts +84 -0
  83. package/dist/lib/work-context/migrate.js +287 -0
  84. package/dist/lib/work-context/organize.d.ts +130 -0
  85. package/dist/lib/work-context/organize.js +471 -0
  86. package/dist/lib/work-context/outbox.d.ts +97 -0
  87. package/dist/lib/work-context/outbox.js +357 -0
  88. package/dist/lib/work-context/paths.d.ts +14 -0
  89. package/dist/lib/work-context/paths.js +39 -0
  90. package/dist/lib/work-context/project.d.ts +78 -0
  91. package/dist/lib/work-context/project.js +247 -0
  92. package/dist/lib/work-context/reconcile.d.ts +85 -0
  93. package/dist/lib/work-context/reconcile.js +651 -0
  94. package/dist/lib/work-context/repo-remote.d.ts +43 -0
  95. package/dist/lib/work-context/repo-remote.js +200 -0
  96. package/dist/lib/work-context/state.d.ts +112 -0
  97. package/dist/lib/work-context/state.js +162 -0
  98. package/dist/main.js +40 -3
  99. package/dist/utils/cognito-session.d.ts +85 -9
  100. package/dist/utils/cognito-session.js +216 -9
  101. package/dist/utils/qmd-model-download-error.d.ts +27 -0
  102. package/dist/utils/qmd-model-download-error.js +114 -0
  103. package/dist/utils/qmd-query-document-error.d.ts +23 -0
  104. package/dist/utils/qmd-query-document-error.js +117 -0
  105. package/dist/utils/sentry-fingerprint.js +2 -0
  106. package/package.json +5 -1
@@ -0,0 +1,117 @@
1
+ // src/utils/qmd-query-document-error.ts
2
+ //
3
+ // Classify a qmd failure caused by a MALFORMED QUERY DOCUMENT — qmd's `query`
4
+ // subcommand rejected the caller's positional because, read as a multi-line
5
+ // query document, its lines lack the required lex:/vec:/hyde:/intent:/expand:
6
+ // prefix — rather than an hq-cli code defect. This is the caller's INPUT SHAPE,
7
+ // not a bug HQ can fix in code, so the CLI surfaces an actionable, query-free
8
+ // remedy and SKIPS Sentry capture. Sibling of qmd-llm-disabled-error.ts (HQ-CLI
9
+ // 7688850003), qmd-module-missing-error.ts (HQ-CLI-Y) and
10
+ // qmd-store-missing-error.ts (HQ-CLI-16): a failure that is NOT an hq-cli defect
11
+ // is printed with an actionable message and never filed as a crash.
12
+ //
13
+ // HQ-CLI-1B (Sentry indigo-d0/hq-cli 7705711476): `hq search --mode hybrid`
14
+ // maps to `qmd query`, which passes the caller's query byte-for-byte. Fleet
15
+ // agents forward a whole Slack message (prose, a blank line, a Block Kit payload,
16
+ // a fenced json block) as the query, so qmd received a MULTI-LINE positional and
17
+ // parsed it as a query document; qmd 2.5.3 requires every line of a multi-line
18
+ // document to carry a prefix (dist/cli/qmd.js:2210) and exited 1 with `Line 1 is
19
+ // missing a lex:/vec:/hyde:/intent: prefix. Each line in a query document must
20
+ // start with one.`. hq-cli had no classifier for that wording, so finishRunQmd
21
+ // raised a plain QmdExitError that reached the boundary's final else and was
22
+ // captured — 28 of the issue's 29 events. buildSearchArgs now normalises free
23
+ // text to one line so the common case never reaches qmd multi-line; this
24
+ // classifier is the backstop for a genuinely malformed structured document.
25
+ //
26
+ // The gate is deliberately narrow on TWO axes so it can neither be tripped by
27
+ // user input nor silence a real bug, exactly as qmd-llm-disabled-error.ts
28
+ // documents:
29
+ // 1. CLASS: only a QmdQueryDocumentError (the typed subclass finishRunQmd
30
+ // raises for the query-document wording) qualifies — never a plain
31
+ // QmdExitError, even one whose message carries the same words.
32
+ // 2. INVOCATION: only the `query` subcommand, the sole caller-driven read that
33
+ // parses a query document. Any other subcommand returns null and stays on
34
+ // the captured-error path.
35
+ // The predicate reads qmd's OWN captured streams, never the synthesized message
36
+ // (which embeds the caller's argv), so free text can never classify.
37
+ /**
38
+ * qmd 2.5.3's query-DOCUMENT syntax diagnostics (dist/cli/qmd.js:2157-2217,
39
+ * parseStructuredQuery). The reported crash is the ":2210" wording; the whole
40
+ * FAMILY is matched — not one sentence — so a mixed-expand, duplicate-intent,
41
+ * empty-prefixed-line, intent-alone or embedded-newline document is classified
42
+ * too. Every phrase is unique to qmd's query-document parser, and only the
43
+ * `query` subcommand reaches it, so no other qmd failure emits any of them. Read
44
+ * from the exact pinned version (`@tobilu/qmd` 2.5.3, not a range).
45
+ */
46
+ const QUERY_DOCUMENT_SYNTAX = new RegExp([
47
+ "is missing a lex:/vec:/hyde:/intent: prefix",
48
+ "Each line in a query document must start with one",
49
+ "query documents cannot mix expand with typed lines",
50
+ "only one intent: line is allowed per query document",
51
+ "intent: must include text",
52
+ "intent: cannot appear alone",
53
+ "contains a newline\\. Keep each query on a single line",
54
+ "\\((?:lex|vec|hyde):\\) must include text",
55
+ "expand: query must include text",
56
+ ].join("|"), "i");
57
+ /** The caller-driven read whose positional qmd parses as a query DOCUMENT. */
58
+ const QUERY_DOCUMENT_READS = new Set(["query"]);
59
+ /**
60
+ * The actionable remedy shown to the caller. Input-free: nothing is interpolated
61
+ * from the error, the argv, or qmd's output, so there is no injection surface —
62
+ * matching the bounded-fingerprint discipline of its siblings.
63
+ */
64
+ export const QMD_QUERY_DOCUMENT_REMEDY = "Hybrid search was given a multi-line query, and qmd read it as a structured " +
65
+ "query document whose lines must each begin with a lex:, vec:, hyde:, or " +
66
+ "intent: prefix. Put your search terms on a single line, or prefix every line, " +
67
+ "then run the command again.";
68
+ /**
69
+ * qmd's OWN captured streams (stderr then stdout), joined. The synthesized
70
+ * `message` is deliberately NOT consulted: it embeds the caller's qmd arguments,
71
+ * so reading it would let a user query for one of these phrases trip the
72
+ * classifier. A bare string is treated as captured text directly (test
73
+ * convenience). A value with no captured streams yields "".
74
+ */
75
+ function capturedStreams(err) {
76
+ if (typeof err === "string")
77
+ return err;
78
+ if (err === null || typeof err !== "object")
79
+ return "";
80
+ const record = err;
81
+ const stderr = typeof record.stderr === "string" ? record.stderr : "";
82
+ const stdout = typeof record.stdout === "string" ? record.stdout : "";
83
+ return stderr || stdout ? `${stderr}\n${stdout}` : "";
84
+ }
85
+ /**
86
+ * True when `err` carries, in qmd's OWN captured streams, a query-document
87
+ * syntax diagnostic — i.e. qmd's `query` parser rejected the positional as a
88
+ * malformed document. finishRunQmd calls this on the raw streams to type the
89
+ * condition {@link import('../lib/search-index/index.js').QmdQueryDocumentError}.
90
+ */
91
+ export function isQmdQueryDocumentError(err) {
92
+ const text = capturedStreams(err);
93
+ if (!text)
94
+ return false;
95
+ return QUERY_DOCUMENT_SYNTAX.test(text);
96
+ }
97
+ /**
98
+ * If `err` is a caller-driven qmd query-document failure (a QmdQueryDocumentError
99
+ * from `hq search --mode hybrid`, i.e. the `query` read), return the actionable,
100
+ * input-free remedy; otherwise return `null`. Mirrors qmdLlmDisabledMessage /
101
+ * qmdModuleMissingMessage so the top-level handler branches the same way: a
102
+ * non-null result means print-and-skip-Sentry, null means "handle as usual
103
+ * (capture to Sentry)".
104
+ */
105
+ export function qmdQueryDocumentMessage(err) {
106
+ if (err === null || typeof err !== "object")
107
+ return null;
108
+ const record = err;
109
+ if (record.name !== "QmdQueryDocumentError")
110
+ return null;
111
+ const args = Array.isArray(record.args) ? record.args : [];
112
+ const subcommand = args[0];
113
+ if (typeof subcommand !== "string" || !QUERY_DOCUMENT_READS.has(subcommand))
114
+ return null;
115
+ return QMD_QUERY_DOCUMENT_REMEDY;
116
+ }
117
+ //# sourceMappingURL=qmd-query-document-error.js.map
@@ -84,6 +84,8 @@ const KNOWN_ERROR_NAMES = new Set([
84
84
  "QmdModuleMissingError",
85
85
  "QmdStoreMissingError",
86
86
  "QmdStoreUnopenableError",
87
+ "QmdQueryDocumentError",
88
+ "QmdModelDownloadError",
87
89
  ]);
88
90
  /** Fixed bucket for any error name outside the closed allowlist. */
89
91
  const FALLBACK_ERROR_NAME = "other";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigoai-us/hq-cli",
3
- "version": "5.108.1",
3
+ "version": "5.108.2",
4
4
  "description": "HQ by Indigo management CLI — modules and cloud sync",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -11,6 +11,7 @@
11
11
  "dist",
12
12
  "!dist/**/*.map",
13
13
  "assets/scaffold",
14
+ "assets/mesh-daemon",
14
15
  "CHANGELOG.md"
15
16
  ],
16
17
  "scripts": {
@@ -35,10 +36,12 @@
35
36
  "@indigoai-us/hq-onboarding": "^0.1.0",
36
37
  "@sentry/node": "^10.49.0",
37
38
  "@tobilu/qmd": "2.5.3",
39
+ "ajv": "^8.20.0",
38
40
  "better-sqlite3": "^12.11.1",
39
41
  "chalk": "^5.3.0",
40
42
  "commander": "^12.1.0",
41
43
  "js-yaml": "^4.1.0",
44
+ "mqtt": "5.15.2",
42
45
  "open": "^10.1.0",
43
46
  "semver": "^7.6.3",
44
47
  "simple-git": "^3.27.0",
@@ -52,6 +55,7 @@
52
55
  "@types/node": "^22.0.0",
53
56
  "@types/semver": "^7.5.8",
54
57
  "@vitest/coverage-v8": "4.1.6",
58
+ "aedes": "1.1.2",
55
59
  "aws-sdk-client-mock": "^4.1.0",
56
60
  "eslint": "^10.5.0",
57
61
  "husky": "^9.1.7",