@ouro.bot/cli 0.1.0-alpha.430 → 0.1.0-alpha.432

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.
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyPerplexityCapability = verifyPerplexityCapability;
4
+ exports.verifyEmbeddingsCapability = verifyEmbeddingsCapability;
5
+ const runtime_1 = require("../nerves/runtime");
6
+ function sanitizeCapabilityError(message) {
7
+ const statusMatch = message.match(/^(\d{3})\s/);
8
+ if (!statusMatch)
9
+ return message;
10
+ const status = statusMatch[1];
11
+ const body = message.slice(status.length).trim();
12
+ if (body.startsWith("<") || body.includes("<!DOCTYPE") || body.includes("<html")) {
13
+ return `HTTP ${status}`;
14
+ }
15
+ if (body.startsWith("{")) {
16
+ try {
17
+ const json = JSON.parse(body);
18
+ const inner = json?.error?.message;
19
+ if (typeof inner === "string" && inner && inner !== "Error") {
20
+ return `${status} ${inner}`;
21
+ }
22
+ }
23
+ catch {
24
+ // Keep the HTTP status fallback below.
25
+ }
26
+ return `HTTP ${status}`;
27
+ }
28
+ return message;
29
+ }
30
+ async function readHttpFailureSummary(response) {
31
+ let detail = `${response.status} ${response.statusText}`.trim();
32
+ try {
33
+ const json = await response.json();
34
+ if (typeof json.error === "string" && json.error.trim()) {
35
+ detail = `${response.status} ${json.error}`;
36
+ }
37
+ else if (typeof json.error === "object" && json.error !== null) {
38
+ const errObj = json.error;
39
+ if (typeof errObj.message === "string" && errObj.message.trim()) {
40
+ detail = `${response.status} ${errObj.message}`;
41
+ }
42
+ }
43
+ else if (typeof json.message === "string" && json.message.trim()) {
44
+ detail = `${response.status} ${json.message}`;
45
+ }
46
+ }
47
+ catch {
48
+ // Keep the HTTP status summary if the body is not JSON.
49
+ }
50
+ return sanitizeCapabilityError(detail);
51
+ }
52
+ function reportRuntimeCapabilityCheckStart(capability, url) {
53
+ (0, runtime_1.emitNervesEvent)({
54
+ component: "daemon",
55
+ event: "daemon.runtime_capability_check_start",
56
+ message: "starting runtime capability check",
57
+ meta: { capability, url },
58
+ });
59
+ }
60
+ function reportRuntimeCapabilityCheckEnd(capability, url) {
61
+ (0, runtime_1.emitNervesEvent)({
62
+ component: "daemon",
63
+ event: "daemon.runtime_capability_check_end",
64
+ message: "runtime capability check passed",
65
+ meta: { capability, url },
66
+ });
67
+ }
68
+ function reportRuntimeCapabilityCheckError(capability, url, summary) {
69
+ (0, runtime_1.emitNervesEvent)({
70
+ level: "warn",
71
+ component: "daemon",
72
+ event: "daemon.runtime_capability_check_error",
73
+ message: "runtime capability check failed",
74
+ meta: { capability, url, summary },
75
+ });
76
+ }
77
+ async function verifyPerplexityCapability(apiKey, fetchImpl = fetch) {
78
+ const url = "https://api.perplexity.ai/search";
79
+ reportRuntimeCapabilityCheckStart("perplexity-search", url);
80
+ try {
81
+ const response = await fetchImpl(url, {
82
+ method: "POST",
83
+ headers: {
84
+ Authorization: `Bearer ${apiKey}`,
85
+ "Content-Type": "application/json",
86
+ },
87
+ body: JSON.stringify({
88
+ query: "ping",
89
+ max_results: 1,
90
+ }),
91
+ });
92
+ if (!response.ok) {
93
+ const summary = await readHttpFailureSummary(response);
94
+ reportRuntimeCapabilityCheckError("perplexity-search", url, summary);
95
+ return {
96
+ ok: false,
97
+ summary,
98
+ };
99
+ }
100
+ const payload = await response.json();
101
+ if (!Array.isArray(payload.results) || payload.results.length === 0) {
102
+ const summary = "Perplexity returned no search results";
103
+ reportRuntimeCapabilityCheckError("perplexity-search", url, summary);
104
+ return {
105
+ ok: false,
106
+ summary,
107
+ };
108
+ }
109
+ reportRuntimeCapabilityCheckEnd("perplexity-search", url);
110
+ return {
111
+ ok: true,
112
+ summary: "live check passed",
113
+ };
114
+ }
115
+ catch (error) {
116
+ const summary = sanitizeCapabilityError(error instanceof Error ? error.message : String(error));
117
+ reportRuntimeCapabilityCheckError("perplexity-search", url, summary);
118
+ return {
119
+ ok: false,
120
+ summary,
121
+ };
122
+ }
123
+ }
124
+ async function verifyEmbeddingsCapability(apiKey, fetchImpl = fetch) {
125
+ const url = "https://api.openai.com/v1/embeddings";
126
+ reportRuntimeCapabilityCheckStart("memory-embeddings", url);
127
+ try {
128
+ const response = await fetchImpl(url, {
129
+ method: "POST",
130
+ headers: {
131
+ Authorization: `Bearer ${apiKey}`,
132
+ "Content-Type": "application/json",
133
+ },
134
+ body: JSON.stringify({
135
+ model: "text-embedding-3-small",
136
+ input: ["ping"],
137
+ }),
138
+ });
139
+ if (!response.ok) {
140
+ const summary = await readHttpFailureSummary(response);
141
+ reportRuntimeCapabilityCheckError("memory-embeddings", url, summary);
142
+ return {
143
+ ok: false,
144
+ summary,
145
+ };
146
+ }
147
+ const payload = await response.json();
148
+ if (!Array.isArray(payload.data) || payload.data.length !== 1 || !Array.isArray(payload.data[0]?.embedding) || payload.data[0].embedding.length === 0) {
149
+ const summary = "embeddings response missing expected vectors";
150
+ reportRuntimeCapabilityCheckError("memory-embeddings", url, summary);
151
+ return {
152
+ ok: false,
153
+ summary,
154
+ };
155
+ }
156
+ reportRuntimeCapabilityCheckEnd("memory-embeddings", url);
157
+ return {
158
+ ok: true,
159
+ summary: "live check passed",
160
+ };
161
+ }
162
+ catch (error) {
163
+ const summary = sanitizeCapabilityError(error instanceof Error ? error.message : String(error));
164
+ reportRuntimeCapabilityCheckError("memory-embeddings", url, summary);
165
+ return {
166
+ ok: false,
167
+ summary,
168
+ };
169
+ }
170
+ }
@@ -33,12 +33,14 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.CLI_UPDATE_CHECK_TIMEOUT_MS = void 0;
36
37
  exports.checkForUpdate = checkForUpdate;
37
38
  exports.startUpdateChecker = startUpdateChecker;
38
39
  exports.stopUpdateChecker = stopUpdateChecker;
39
40
  const semver = __importStar(require("semver"));
40
41
  const runtime_1 = require("../../nerves/runtime");
41
42
  const DEFAULT_INTERVAL_MS = 30 * 60 * 1000; // 30 minutes
43
+ exports.CLI_UPDATE_CHECK_TIMEOUT_MS = 3_000;
42
44
  async function checkForUpdate(currentVersion, deps) {
43
45
  (0, runtime_1.emitNervesEvent)({
44
46
  component: "daemon",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.430",
3
+ "version": "0.1.0-alpha.432",
4
4
  "main": "dist/heart/daemon/ouro-entry.js",
5
5
  "bin": {
6
6
  "cli": "dist/heart/daemon/ouro-bot-entry.js",
@@ -26,6 +26,9 @@
26
26
  "teams": "tsc && node dist/senses/teams-entry.js --agent ouroboros",
27
27
  "bluebubbles": "tsc && node dist/senses/bluebubbles/entry.js --agent ouroboros",
28
28
  "test": "vitest run",
29
+ "test:integration": "npm run build && vitest run --config vitest.integration.config.ts",
30
+ "test:e2e:package": "npm run build && node scripts/package-e2e.cjs",
31
+ "test:e2e:real-smoke": "npm run build && node scripts/nightly-real-smoke.cjs",
29
32
  "typecheck:outlook-ui": "tsc --noEmit -p packages/outlook-ui/tsconfig.json",
30
33
  "test:outlook-ui": "npm test --prefix packages/outlook-ui",
31
34
  "test:coverage:vitest": "vitest run --coverage",