@dreamlake/dreamlake-cli 0.104.4 → 0.104.6

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 (47) hide show
  1. package/dist/api/http.d.ts +3 -3
  2. package/dist/api/http.js +22 -7
  3. package/dist/api/note-events.js +7 -7
  4. package/dist/api/note-facade.js +8 -8
  5. package/dist/api/note-linger.js +4 -4
  6. package/dist/api/note-presence.js +1 -1
  7. package/dist/api/note-reading.js +3 -3
  8. package/dist/api/note-write.js +6 -6
  9. package/dist/api/notes.js +3 -3
  10. package/dist/cli/agents/index.js +4 -4
  11. package/dist/cli/client.js +7 -3
  12. package/dist/cli/compat/http.js +4 -0
  13. package/dist/cli/failure-report.d.ts +6 -0
  14. package/dist/cli/failure-report.js +34 -0
  15. package/dist/cli/help-examples.generated.js +37 -37
  16. package/dist/cli/index.js +2 -2
  17. package/dist/cli/notes/api-transport.js +3 -3
  18. package/dist/cli/notes/archive-command.js +8 -8
  19. package/dist/cli/notes/document.js +12 -12
  20. package/dist/cli/notes/edit-commands.js +7 -7
  21. package/dist/cli/notes/files-commands.js +6 -6
  22. package/dist/cli/notes/html-read.js +3 -3
  23. package/dist/cli/notes/index.js +126 -126
  24. package/dist/cli/notes/linger.js +2 -2
  25. package/dist/cli/notes/move-command.js +30 -21
  26. package/dist/cli/notes/rm-command.js +10 -10
  27. package/dist/cli/notes/select-command.js +3 -3
  28. package/dist/cli/notes/suggest-diff.js +2 -2
  29. package/dist/cli/notes/transfer-command.js +1 -1
  30. package/dist/cli/notes/version-commands.js +8 -8
  31. package/dist/cli/ownership/metadata-transfer.js +7 -3
  32. package/dist/cli/project/index.js +4 -4
  33. package/dist/cli/project/move.js +2 -2
  34. package/dist/cli/project/stream.js +1 -1
  35. package/dist/cli/session-affiliation.js +1 -1
  36. package/dist/cli/sessions/affiliation.js +4 -4
  37. package/dist/cli/sessions/api.js +1 -1
  38. package/dist/cli/sessions/control.js +1 -1
  39. package/dist/cli/sessions/index.js +2 -2
  40. package/dist/cli/share.js +3 -3
  41. package/dist/cli/tasks/index.js +4 -4
  42. package/dist/cli/telemetry.d.ts +12 -0
  43. package/dist/cli/telemetry.js +34 -2
  44. package/dist/cli/update/index.js +3 -3
  45. package/dist/cli/version.d.ts +1 -1
  46. package/dist/cli/version.js +1 -1
  47. package/package.json +9 -9
@@ -15,9 +15,21 @@ export interface Completion {
15
15
  platform: string;
16
16
  exit_code: number;
17
17
  duration_ms: number;
18
+ last_http_status?: number;
19
+ last_http_error_code?: string;
20
+ operation_error_code?: string;
21
+ operation_outcome?: string;
18
22
  }
23
+ declare let operationFailure: Pick<Completion, 'operation_error_code' | 'operation_outcome'>;
24
+ export declare function operationFailureFields(code: unknown, outcome: unknown): typeof operationFailure;
25
+ export declare function recordOperationFailure(code: string, outcome: 'failed' | 'blocked' | 'partial' | 'uncertain'): void;
26
+ export declare function httpFailureFields(status: unknown, code: unknown): Pick<Completion, 'last_http_status' | 'last_http_error_code'>;
27
+ /** A handled HTTP failure is context, not necessarily the command's final cause.
28
+ * Never collect response bodies, error messages, URLs, arguments or credentials. */
29
+ export declare function recordHttpFailure(status: number, code?: string): void;
19
30
  /** Bind queued records to their original API and account, without storing a credential. */
20
31
  export declare function telemetryScope(remote: string, token: string): string;
21
32
  export declare function startCommandTelemetry(command: string): void;
22
33
  /** Retry in a detached process with a bounded lifetime. Each event triggers an attempt. */
23
34
  export declare function deliverTelemetry(scope: string): Promise<void>;
35
+ export {};
@@ -105,6 +105,34 @@ export function commandPath(command) {
105
105
  parts.unshift(current.name());
106
106
  return parts.join(' ');
107
107
  }
108
+ let operationFailure = {};
109
+ export function operationFailureFields(code, outcome) {
110
+ const machineCode = httpFailureFields(400, code).last_http_error_code;
111
+ return machineCode && typeof outcome === 'string' && ['failed', 'blocked', 'partial', 'uncertain'].includes(outcome) ? { operation_error_code: machineCode, operation_outcome: outcome } : {};
112
+ }
113
+ export function recordOperationFailure(code, outcome) {
114
+ try {
115
+ if (telemetryEnabled())
116
+ operationFailure = operationFailureFields(code, outcome);
117
+ }
118
+ catch { }
119
+ }
120
+ let lastHttpFailure = {};
121
+ export function httpFailureFields(status, code) {
122
+ if (typeof status !== 'number' || !Number.isInteger(status) || status < 400 || status > 599)
123
+ return {};
124
+ return { last_http_status: status,
125
+ ...(typeof code === 'string' && code.length <= 100 && /^[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)+$/.test(code) ? { last_http_error_code: code } : {}) };
126
+ }
127
+ /** A handled HTTP failure is context, not necessarily the command's final cause.
128
+ * Never collect response bodies, error messages, URLs, arguments or credentials. */
129
+ export function recordHttpFailure(status, code) {
130
+ try {
131
+ if (telemetryEnabled())
132
+ lastHttpFailure = httpFailureFields(status, code);
133
+ }
134
+ catch { /* Reporting must not replace the original command failure. */ }
135
+ }
108
136
  function journal() { return new TelemetryJournal(path.join(dreamlakeDir(), 'telemetry-events')); }
109
137
  /** Bind queued records to their original API and account, without storing a credential. */
110
138
  export function telemetryScope(remote, token) {
@@ -140,6 +168,8 @@ function launchUpload(scope) {
140
168
  child.unref();
141
169
  }
142
170
  export function startCommandTelemetry(command) {
171
+ lastHttpFailure = {};
172
+ operationFailure = {};
143
173
  if (!telemetryEnabled()) {
144
174
  try {
145
175
  journal().clear();
@@ -172,7 +202,8 @@ export function startCommandTelemetry(command) {
172
202
  const event = { uuid: randomUUID(), timestamp: new Date().toISOString(), command, version: VERSION,
173
203
  platform: ['linux', 'darwin', 'win32'].includes(process.platform) ? process.platform : 'other',
174
204
  exit_code: Math.max(0, Math.min(255, code)),
175
- duration_ms: Math.min(604800000, Math.max(0, Math.round(performance.now() - start))) };
205
+ duration_ms: Math.min(604800000, Math.max(0, Math.round(performance.now() - start))),
206
+ ...(code === 0 ? {} : { ...lastHttpFailure, ...operationFailure }) };
176
207
  // Synchronous local commit is required here: Node cannot await exit handlers.
177
208
  journal().append(scope, event);
178
209
  launchUpload(scope);
@@ -239,7 +270,8 @@ export async function deliverTelemetry(scope) {
239
270
  const response = await fetch(`${target.remote}/telemetry/events`, {
240
271
  method: 'POST', redirect: 'error', signal: AbortSignal.timeout(Math.min(1500, Math.max(1, deadline - Date.now()))),
241
272
  headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${target.token}` },
242
- body: JSON.stringify({ uuid, timestamp, command, version, platform, exit_code, duration_ms }),
273
+ body: JSON.stringify({ uuid, timestamp, command, version, platform, exit_code, duration_ms,
274
+ ...(exit_code === 0 ? {} : { ...httpFailureFields(parsed.last_http_status, parsed.last_http_error_code), ...operationFailureFields(parsed.operation_error_code, parsed.operation_outcome) }) }),
243
275
  });
244
276
  await response.body?.cancel();
245
277
  if (response.status !== 204)
@@ -69,7 +69,7 @@ export async function runUpdateBindr(name, opts) {
69
69
  token,
70
70
  json: { nodeId: node.id },
71
71
  });
72
- ok(`Tagged note '${node.name}' with bindr ${name} → ${res.memberCount ?? "?"} total members`);
72
+ ok(`Tagged memo '${node.name}' with bindr ${name} → ${res.memberCount ?? "?"} total members`);
73
73
  }
74
74
  catch (err) {
75
75
  fail(err.message);
@@ -258,12 +258,12 @@ export function registerUpdateCommand(program) {
258
258
  });
259
259
  update
260
260
  .command("bindr")
261
- .description("add/remove episodes (by glob), tag a note, or update metadata")
261
+ .description("add/remove episodes (by glob), tag a memo, or update metadata")
262
262
  .argument("<name>", "bindr name")
263
263
  .requiredOption("--project <target>", "project scope: space[@namespace]")
264
264
  .option("--add <glob>", "glob to add matching episodes")
265
265
  .option("--remove <glob>", "glob to remove matching episodes")
266
- .option("--add-note <note>", "tag a note filed in this project (ID, slug or title)")
266
+ .option("--add-note <note>", "tag a memo filed in this project (ID, slug or title)")
267
267
  .option("--description <text>", "update description")
268
268
  .option("--tags <list>", "replace tags (comma-separated)")
269
269
  .action(async (name, opts) => {
@@ -1 +1 @@
1
- export declare const VERSION = "0.104.4";
1
+ export declare const VERSION = "0.104.6";
@@ -6,4 +6,4 @@
6
6
  // value means a binary that re-installs the same version forever.
7
7
  //
8
8
  // Editing this by hand does nothing for a release; bump package.json.
9
- export const VERSION = "0.104.4";
9
+ export const VERSION = "0.104.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dreamlake-cli",
3
- "version": "0.104.4",
3
+ "version": "0.104.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
@@ -36,13 +36,13 @@
36
36
  "node": ">=18"
37
37
  },
38
38
  "optionalDependencies": {
39
- "@dreamlake/dreamlake-cli-darwin-arm64": "0.104.4",
40
- "@dreamlake/dreamlake-cli-darwin-x64": "0.104.4",
41
- "@dreamlake/dreamlake-cli-linux-x64": "0.104.4",
42
- "@dreamlake/dreamlake-cli-linux-arm64": "0.104.4",
43
- "@dreamlake/dreamlake-cli-linux-x64-musl": "0.104.4",
44
- "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.104.4",
45
- "@dreamlake/dreamlake-cli-win32-x64": "0.104.4",
46
- "@dreamlake/dreamlake-cli-win32-arm64": "0.104.4"
39
+ "@dreamlake/dreamlake-cli-darwin-arm64": "0.104.6",
40
+ "@dreamlake/dreamlake-cli-darwin-x64": "0.104.6",
41
+ "@dreamlake/dreamlake-cli-linux-x64": "0.104.6",
42
+ "@dreamlake/dreamlake-cli-linux-arm64": "0.104.6",
43
+ "@dreamlake/dreamlake-cli-linux-x64-musl": "0.104.6",
44
+ "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.104.6",
45
+ "@dreamlake/dreamlake-cli-win32-x64": "0.104.6",
46
+ "@dreamlake/dreamlake-cli-win32-arm64": "0.104.6"
47
47
  }
48
48
  }