@fml-inc/fml 0.7.0 → 0.8.0-rc.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 (45) hide show
  1. package/.claude-plugin/plugin.json +2 -4
  2. package/README.md +323 -79
  3. package/agent-assets/fml/SKILL.md +180 -0
  4. package/bin/fml +4 -18
  5. package/bin/hook-handler +7 -0
  6. package/bin/mcp-server +4 -18
  7. package/bin/observer +6 -0
  8. package/dist/chunk-3KISRT57.js +140 -0
  9. package/dist/chunk-56TPYMNK.js +4657 -0
  10. package/dist/chunk-7V7G7NVF.js +142 -0
  11. package/dist/chunk-A6HAEVJX.js +1606 -0
  12. package/dist/chunk-DZKYW327.js +1037 -0
  13. package/dist/chunk-ENW2GJNO.js +109 -0
  14. package/dist/{chunk-PZ5AY32C.js → chunk-MLKGABMK.js} +0 -1
  15. package/dist/{chunk-PTUZMKSN.js → chunk-R45CWWZO.js} +34 -23
  16. package/dist/chunk-WZLLO563.js +953 -0
  17. package/dist/chunk-YSU5CS2V.js +3331 -0
  18. package/dist/cli.js +7742 -1072
  19. package/dist/{esm-2EUDFZWP.js → esm-4YKLKFRX.js} +546 -741
  20. package/dist/hook-handler.js +440 -0
  21. package/dist/mcp/server.js +112 -98
  22. package/dist/observer-server.js +1566 -0
  23. package/dist/sync-cycle.js +31 -0
  24. package/dist/{token-store-3IQSLOTQ.js → token-store-BT5THIAJ.js} +10 -3
  25. package/hooks/hooks.json +290 -0
  26. package/package.json +24 -27
  27. package/dist/chunk-PTUZMKSN.js.map +0 -1
  28. package/dist/chunk-PZ5AY32C.js.map +0 -1
  29. package/dist/chunk-S4TJNLEN.js +0 -61
  30. package/dist/chunk-S4TJNLEN.js.map +0 -1
  31. package/dist/chunk-VV4JHH4H.js +0 -437
  32. package/dist/chunk-VV4JHH4H.js.map +0 -1
  33. package/dist/chunk-YH5ROR7G.js +0 -69
  34. package/dist/chunk-YH5ROR7G.js.map +0 -1
  35. package/dist/cli.js.map +0 -1
  36. package/dist/daemon-MSLDHLMH.js +0 -21
  37. package/dist/daemon-MSLDHLMH.js.map +0 -1
  38. package/dist/daemon-utils-OODBIYB7.js +0 -10
  39. package/dist/daemon-utils-OODBIYB7.js.map +0 -1
  40. package/dist/esm-2EUDFZWP.js.map +0 -1
  41. package/dist/mcp/server.js.map +0 -1
  42. package/dist/postinstall.js +0 -16
  43. package/dist/postinstall.js.map +0 -1
  44. package/dist/token-store-3IQSLOTQ.js.map +0 -1
  45. package/scripts/postinstall.cjs +0 -25
package/bin/fml CHANGED
@@ -1,20 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // Suppress Node's experimental SQLite warning (emitted by node:sqlite, pulled in
4
- // transitively via @fml-inc/panopticon) before the dynamic import below loads it.
5
- // Scoped to the SQLite warning so other ExperimentalWarnings still surface.
6
- const originalEmit = process.emit;
7
- process.emit = function (name, data, ...args) {
8
- if (
9
- name === "warning" &&
10
- data &&
11
- data.name === "ExperimentalWarning" &&
12
- typeof data.message === "string" &&
13
- data.message.includes("SQLite")
14
- ) {
15
- return false;
16
- }
17
- return originalEmit.call(this, name, data, ...args);
18
- };
19
-
20
- import("../dist/cli.js");
3
+ import("../dist/cli.js").catch((error) => {
4
+ console.error(error);
5
+ process.exitCode = 1;
6
+ });
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ import("../dist/hook-handler.js").catch(() => {
4
+ // Hook capture is strictly fail-open, including a broken package install.
5
+ process.exitCode = 0;
6
+ process.stdout.write("{}");
7
+ });
package/bin/mcp-server CHANGED
@@ -1,20 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // Suppress Node's experimental SQLite warning (emitted by node:sqlite, pulled in
4
- // transitively via @fml-inc/panopticon) before the dynamic import below loads it.
5
- // Scoped to the SQLite warning so other ExperimentalWarnings still surface.
6
- const originalEmit = process.emit;
7
- process.emit = function (name, data, ...args) {
8
- if (
9
- name === "warning" &&
10
- data &&
11
- data.name === "ExperimentalWarning" &&
12
- typeof data.message === "string" &&
13
- data.message.includes("SQLite")
14
- ) {
15
- return false;
16
- }
17
- return originalEmit.call(this, name, data, ...args);
18
- };
19
-
20
- import("../dist/mcp/server.js");
3
+ import("../dist/mcp/server.js").catch((error) => {
4
+ console.error(error);
5
+ process.exitCode = 1;
6
+ });
package/bin/observer ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+
3
+ import("../dist/observer-server.js").catch((error) => {
4
+ console.error(error);
5
+ process.exitCode = 1;
6
+ });
@@ -0,0 +1,140 @@
1
+ import {
2
+ resolvePackageRoot,
3
+ runRawSyncOnce
4
+ } from "./chunk-YSU5CS2V.js";
5
+
6
+ // src/observer/sync-cycle.ts
7
+ import { fork } from "child_process";
8
+ import path from "path";
9
+ var ObserverSyncCycleAbortedError = class extends Error {
10
+ constructor() {
11
+ super("observer sync cycle aborted");
12
+ }
13
+ };
14
+ function abortableFetch(signal) {
15
+ return (input, init) => {
16
+ const requestSignal = init?.signal;
17
+ return fetch(input, {
18
+ ...init,
19
+ signal: requestSignal ? AbortSignal.any([signal, requestSignal]) : signal
20
+ });
21
+ };
22
+ }
23
+ async function runObserverSyncCycle(signal) {
24
+ const attempt = await runRawSyncOnce({
25
+ continuous: true,
26
+ ...signal ? { fetch: abortableFetch(signal) } : {}
27
+ });
28
+ if (attempt.kind === "disabled") return { kind: "disabled" };
29
+ if (attempt.kind === "unauthenticated") {
30
+ return {
31
+ kind: "unauthenticated",
32
+ environment: attempt.environment
33
+ };
34
+ }
35
+ return {
36
+ kind: "completed",
37
+ environment: attempt.environment,
38
+ outcome: attempt.result.outcome,
39
+ uploadedBytes: attempt.result.upload.uploadedBytes,
40
+ failed: attempt.result.upload.failed,
41
+ exhausted: attempt.result.upload.exhausted,
42
+ retryAtMs: attempt.result.upload.retryAtMs,
43
+ nextRetryAtMs: attempt.result.upload.nextRetryAtMs
44
+ };
45
+ }
46
+ function isSyncOutcome(value) {
47
+ return value === "drained" || value === "pending" || value === "backing_off" || value === "busy" || value === "throttled" || value === "failed" || value === "exhausted";
48
+ }
49
+ function parseObserverSyncCycleResult(value) {
50
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
51
+ const record = value;
52
+ if (record.kind === "disabled") return { kind: "disabled" };
53
+ if (record.kind === "unauthenticated" && typeof record.environment === "string") {
54
+ return { kind: "unauthenticated", environment: record.environment };
55
+ }
56
+ if (record.kind !== "completed" || typeof record.environment !== "string" || !isSyncOutcome(record.outcome) || typeof record.uploadedBytes !== "number" || typeof record.failed !== "number" || typeof record.exhausted !== "number" || record.retryAtMs !== void 0 && typeof record.retryAtMs !== "number" || record.nextRetryAtMs !== void 0 && typeof record.nextRetryAtMs !== "number") {
57
+ return null;
58
+ }
59
+ return {
60
+ kind: "completed",
61
+ environment: record.environment,
62
+ outcome: record.outcome,
63
+ uploadedBytes: record.uploadedBytes,
64
+ failed: record.failed,
65
+ exhausted: record.exhausted,
66
+ ...typeof record.retryAtMs === "number" ? { retryAtMs: record.retryAtMs } : {},
67
+ ...typeof record.nextRetryAtMs === "number" ? { nextRetryAtMs: record.nextRetryAtMs } : {}
68
+ };
69
+ }
70
+ function runObserverSyncCycleSubprocess(opts = {}) {
71
+ if (opts.signal?.aborted) {
72
+ return Promise.reject(new ObserverSyncCycleAbortedError());
73
+ }
74
+ const scriptPath = opts.scriptPath ?? path.join(resolvePackageRoot(), "dist", "sync-cycle.js");
75
+ return new Promise((resolve, reject) => {
76
+ const child = fork(scriptPath, [], {
77
+ detached: false,
78
+ env: process.env,
79
+ execPath: process.execPath,
80
+ silent: false,
81
+ stdio: ["ignore", "inherit", "inherit", "ipc"]
82
+ });
83
+ let result = null;
84
+ let settled = false;
85
+ let forceKillTimer = null;
86
+ const cleanup = () => {
87
+ opts.signal?.removeEventListener("abort", abort);
88
+ if (forceKillTimer) clearTimeout(forceKillTimer);
89
+ };
90
+ const finishReject = (error) => {
91
+ if (settled) return;
92
+ settled = true;
93
+ cleanup();
94
+ reject(error);
95
+ };
96
+ const abort = () => {
97
+ try {
98
+ child.kill("SIGTERM");
99
+ forceKillTimer = setTimeout(() => {
100
+ try {
101
+ child.kill("SIGKILL");
102
+ } catch {
103
+ }
104
+ }, 2e3);
105
+ forceKillTimer.unref();
106
+ } catch {
107
+ }
108
+ };
109
+ opts.signal?.addEventListener("abort", abort, { once: true });
110
+ child.once("error", finishReject);
111
+ child.on("message", (message) => {
112
+ const parsed = parseObserverSyncCycleResult(message);
113
+ if (parsed) result = parsed;
114
+ });
115
+ child.once("exit", (code, signal) => {
116
+ if (settled) return;
117
+ settled = true;
118
+ cleanup();
119
+ if (opts.signal?.aborted) {
120
+ reject(new ObserverSyncCycleAbortedError());
121
+ return;
122
+ }
123
+ if (code !== 0 || !result) {
124
+ reject(
125
+ new Error(
126
+ `observer sync cycle exited code=${code ?? "null"} signal=${signal ?? "null"}`
127
+ )
128
+ );
129
+ return;
130
+ }
131
+ resolve(result);
132
+ });
133
+ });
134
+ }
135
+
136
+ export {
137
+ ObserverSyncCycleAbortedError,
138
+ runObserverSyncCycle,
139
+ runObserverSyncCycleSubprocess
140
+ };