@fml-inc/fml 0.8.13-rc.1 → 0.8.13-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.
@@ -53,7 +53,7 @@ var PACKAGE_NAME = "@fml-inc/fml";
53
53
  var UPDATE_TIMEOUT_MS = 12e4;
54
54
  var SETUP_TIMEOUT_MS = 3e5;
55
55
  function getCurrentVersion() {
56
- return true ? "0.8.13-rc.1+cdaf24a5" : "unknown";
56
+ return true ? "0.8.13-rc.2+c00749ec" : "unknown";
57
57
  }
58
58
  function parseVersion(version) {
59
59
  const match = SEMVER_PATTERN.exec(version);
package/dist/cli.js CHANGED
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  createFmlClient,
4
4
  getAuthenticatedClient
5
- } from "./chunk-IUFDFBU7.js";
5
+ } from "./chunk-C4Z6RMQ5.js";
6
6
  import {
7
7
  execBinSync,
8
8
  handleUpdate,
9
9
  resolveBin
10
- } from "./chunk-3VN2SQTP.js";
10
+ } from "./chunk-PVOZYFMP.js";
11
11
  import {
12
12
  openObserverLog,
13
13
  readJsonFile,
@@ -29,8 +29,8 @@ import {
29
29
  readObserverAuthToken,
30
30
  readObserverStateStatus,
31
31
  removeObserverStateIfOwned
32
- } from "./chunk-5VP4C72Z.js";
33
- import "./chunk-EX5J3MPG.js";
32
+ } from "./chunk-K2ANDHRQ.js";
33
+ import "./chunk-3RKICLMI.js";
34
34
  import {
35
35
  claudeConfigDirectory,
36
36
  createCliRawSync,
@@ -39,10 +39,11 @@ import {
39
39
  initializeSyncSettings,
40
40
  resolvePiAgentDir,
41
41
  runRawSyncOnce
42
- } from "./chunk-U7SITLCL.js";
42
+ } from "./chunk-LYKMU7QR.js";
43
43
  import {
44
44
  resolvePackageRoot
45
- } from "./chunk-CSOFP7MT.js";
45
+ } from "./chunk-F57IFY3K.js";
46
+ import "./chunk-74KOMQZO.js";
46
47
  import {
47
48
  DEFAULT_PROD_URL,
48
49
  DEFAULT_TARGET_NAME,
@@ -133,7 +134,7 @@ var STOP_TIMEOUT_MS = 5e3;
133
134
  var FORCE_STOP_TIMEOUT_MS = 2e3;
134
135
  var POLL_INTERVAL_MS = 50;
135
136
  function expectedObserverVersion() {
136
- return true ? "0.8.13-rc.1+cdaf24a5" : "dev";
137
+ return true ? "0.8.13-rc.2+c00749ec" : "dev";
137
138
  }
138
139
  function delay(ms) {
139
140
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -9726,7 +9727,7 @@ async function handleConfigDetail(opts) {
9726
9727
  // src/commands/tools.ts
9727
9728
  import { readFileSync } from "fs";
9728
9729
  import path31 from "path";
9729
- var pluginVersion = true ? "0.8.13-rc.1+cdaf24a5" : void 0;
9730
+ var pluginVersion = true ? "0.8.13-rc.2+c00749ec" : void 0;
9730
9731
  async function getApi() {
9731
9732
  const api = await getAuthenticatedClient();
9732
9733
  if (!api) {
@@ -9883,7 +9884,7 @@ if (process.argv.length <= 2 || process.argv.includes("--help") || process.argv.
9883
9884
  printBanner();
9884
9885
  }
9885
9886
  var program = new Command().name("fml").description("FML CLI and agent tools").version(
9886
- true ? "0.8.13-rc.1+cdaf24a5" : "dev"
9887
+ true ? "0.8.13-rc.2+c00749ec" : "dev"
9887
9888
  );
9888
9889
  function formatCommandInventory(cmd, prefix = "") {
9889
9890
  const name = prefix ? `${prefix} ${cmd.name()}` : cmd.name();
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-2ZCXGYI5.js";
6
6
  import {
7
7
  getActiveHookDestinationBinding
8
- } from "./chunk-4YLCUJ6C.js";
8
+ } from "./chunk-AZSAAPRC.js";
9
9
  import {
10
10
  HookInboxCapacityError,
11
11
  OBSERVER_HEARTBEAT_STALE_MS,
@@ -19,14 +19,18 @@ import {
19
19
  readObserverAuthToken,
20
20
  readObserverState,
21
21
  recordHookInboxLoss
22
- } from "./chunk-5VP4C72Z.js";
22
+ } from "./chunk-K2ANDHRQ.js";
23
23
  import {
24
- resolveRepositoryRootFromCwd,
25
- resolveRepositorySlugFromCwd
26
- } from "./chunk-EX5J3MPG.js";
24
+ resolveGitStateFromCwd,
25
+ resolveRepositoryRootFromCwd
26
+ } from "./chunk-3RKICLMI.js";
27
27
  import {
28
28
  resolvePackageRoot
29
- } from "./chunk-CSOFP7MT.js";
29
+ } from "./chunk-F57IFY3K.js";
30
+ import {
31
+ GIT_STATE_PAYLOAD_KEY,
32
+ capturedGitState
33
+ } from "./chunk-74KOMQZO.js";
30
34
  import {
31
35
  FML_HOOK_CONTEXT_STATE_DIR,
32
36
  FML_HOOK_INBOX_DIR,
@@ -656,7 +660,8 @@ function hookOutput(request, injection) {
656
660
  async function requestServerHookContext(target2, event, destination, opts = {}) {
657
661
  const stateDir = opts.stateDir ?? FML_HOOK_CONTEXT_STATE_DIR;
658
662
  pruneOldMarkers(stateDir, Date.now());
659
- const repositoryRoot = event.eventType === "PreToolUse" && event.cwd ? (opts.resolveRepositoryRoot ?? ((cwd) => resolveRepositoryRootFromCwd(cwd, 250)))(event.cwd) : null;
663
+ const snapshot = capturedGitState(event.payload);
664
+ const repositoryRoot = snapshot !== void 0 ? snapshot?.worktreeRoot ?? null : event.eventType === "PreToolUse" && event.cwd ? (opts.resolveRepositoryRoot ?? ((cwd) => resolveRepositoryRootFromCwd(cwd, 250)))(event.cwd) : null;
660
665
  const request = buildServerHookContextRequest(
661
666
  target2,
662
667
  event,
@@ -799,7 +804,7 @@ async function processHookHandler(target2, opts, includeContext) {
799
804
  return { captured: false, output: {} };
800
805
  }
801
806
  const cwd = opts.cwd ?? process.cwd();
802
- const hookRequest = {
807
+ let hookRequest = {
803
808
  target: target2,
804
809
  payload,
805
810
  cwd
@@ -807,11 +812,25 @@ async function processHookHandler(target2, opts, includeContext) {
807
812
  let event = normalizeObserverHookCapture(hookRequest);
808
813
  if (event?.cwd) {
809
814
  try {
810
- const repository = (opts.resolveRepository ?? ((directory) => resolveRepositorySlugFromCwd(
811
- directory,
812
- HOOK_REPO_RESOLUTION_TIMEOUT_MS
813
- )))(event.cwd);
814
- if (repository) event = { ...event, repository };
815
+ if (opts.resolveRepository) {
816
+ const repository = opts.resolveRepository(event.cwd);
817
+ if (repository) event = { ...event, repository };
818
+ } else {
819
+ const gitState = resolveGitStateFromCwd(
820
+ event.cwd,
821
+ HOOK_REPO_RESOLUTION_TIMEOUT_MS
822
+ );
823
+ const enrichedPayload = {
824
+ ...hookRequest.payload,
825
+ [GIT_STATE_PAYLOAD_KEY]: gitState
826
+ };
827
+ hookRequest = { ...hookRequest, payload: enrichedPayload };
828
+ event = {
829
+ ...event,
830
+ payload: enrichedPayload,
831
+ ...gitState?.repository ? { repository: gitState.repository } : {}
832
+ };
833
+ }
815
834
  } catch {
816
835
  }
817
836
  }
@@ -2,10 +2,11 @@
2
2
  import {
3
3
  createFmlClient,
4
4
  getAuthenticatedClient
5
- } from "../chunk-IUFDFBU7.js";
5
+ } from "../chunk-C4Z6RMQ5.js";
6
6
  import {
7
7
  resolveRepoFromCwd
8
- } from "../chunk-EX5J3MPG.js";
8
+ } from "../chunk-3RKICLMI.js";
9
+ import "../chunk-74KOMQZO.js";
9
10
  import {
10
11
  FML_DATA_DIR,
11
12
  FML_LOG_DIR,
@@ -95,6 +96,64 @@ function registerTools(server2, environment = getActiveEnv()) {
95
96
  registerSessionTimelineTool();
96
97
  return;
97
98
  }
99
+ server2.tool(
100
+ "fml_get_attachment",
101
+ "Fetch an fml-ref attachment in chunks of up to 4 MiB decoded. Complete small images render natively; partial images and other files return base64 plus offset, totalBytes, nextOffset and SHA-256. Continue with offset=nextOffset until null. Decode each chunk separately before concatenating bytes in order.",
102
+ {
103
+ ref: z.string().max(512),
104
+ offset: z.number().int().nonnegative().optional().describe(
105
+ "Decoded byte offset; defaults to 0. Use nextOffset to continue."
106
+ ),
107
+ maxBytes: z.number().int().positive().optional().describe(
108
+ "Maximum decoded bytes per chunk, up to 4 MiB; defaults to 4 MiB."
109
+ )
110
+ },
111
+ async ({ ref, offset, maxBytes }) => {
112
+ try {
113
+ const api = await getAuthenticatedClient(environment);
114
+ if (!api) return errorResult("Not authenticated. Run fml login.");
115
+ const response = await api.callBackend("get-attachment", {
116
+ ref,
117
+ ...offset === void 0 ? {} : { offset },
118
+ ...maxBytes === void 0 ? {} : { maxBytes }
119
+ });
120
+ if (!response.ok)
121
+ return errorResult(response.error ?? "Attachment unavailable");
122
+ const parsed = z.object({
123
+ success: z.literal(true),
124
+ data: z.object({
125
+ mediaType: z.string(),
126
+ data: z.string(),
127
+ // Optional for compatibility with backends predating chunking.
128
+ offset: z.number().optional(),
129
+ totalBytes: z.number().optional(),
130
+ nextOffset: z.number().nullable().optional(),
131
+ sha256: z.string().optional()
132
+ })
133
+ }).safeParse(response.result);
134
+ if (!parsed.success) return textResult(response.result);
135
+ const attachment = parsed.data.data;
136
+ if ((attachment.offset ?? 0) === 0 && attachment.nextOffset == null && ["image/png", "image/jpeg", "image/gif", "image/webp"].includes(
137
+ attachment.mediaType
138
+ )) {
139
+ return {
140
+ content: [
141
+ {
142
+ type: "image",
143
+ mimeType: attachment.mediaType,
144
+ data: attachment.data
145
+ }
146
+ ]
147
+ };
148
+ }
149
+ return textResult(attachment);
150
+ } catch (error) {
151
+ return errorResult(
152
+ error instanceof Error ? error.message : "Attachment unavailable"
153
+ );
154
+ }
155
+ }
156
+ );
98
157
  server2.tool(
99
158
  "whoami",
100
159
  "Show current authenticated user and available organizations",
@@ -5,11 +5,11 @@ import {
5
5
  isWinShim,
6
6
  quoteWinArg,
7
7
  resolveBin
8
- } from "./chunk-3VN2SQTP.js";
8
+ } from "./chunk-PVOZYFMP.js";
9
9
  import {
10
10
  createHookSyncLoop,
11
11
  getActiveHookDestinationBinding
12
- } from "./chunk-4YLCUJ6C.js";
12
+ } from "./chunk-AZSAAPRC.js";
13
13
  import {
14
14
  OBSERVER_PROTOCOL_VERSION,
15
15
  OBSERVER_SERVICE_NAME,
@@ -30,17 +30,18 @@ import {
30
30
  removeObserverStateIfOwned,
31
31
  retireHookInboxEntry,
32
32
  updateObserverState
33
- } from "./chunk-5VP4C72Z.js";
34
- import "./chunk-EX5J3MPG.js";
33
+ } from "./chunk-K2ANDHRQ.js";
34
+ import "./chunk-3RKICLMI.js";
35
35
  import {
36
36
  ObserverSyncCycleAbortedError,
37
37
  runObserverSyncCycleSubprocess
38
- } from "./chunk-HVD2GMN3.js";
38
+ } from "./chunk-56ABBKUE.js";
39
39
  import {
40
40
  createCliRawSync,
41
41
  invalidateCliRawSyncDiscoveryCache
42
- } from "./chunk-U7SITLCL.js";
43
- import "./chunk-CSOFP7MT.js";
42
+ } from "./chunk-LYKMU7QR.js";
43
+ import "./chunk-F57IFY3K.js";
44
+ import "./chunk-74KOMQZO.js";
44
45
  import {
45
46
  FML_OBSERVER_AUTH_TOKEN_FILE,
46
47
  FML_OBSERVER_ENDPOINT_FILE,
@@ -1563,7 +1564,7 @@ var hookRejectionStatus = () => ({
1563
1564
  ...lastRejectedReason !== void 0 ? { lastRejectedReason } : {},
1564
1565
  ...lastRejectedTarget !== void 0 ? { lastRejectedTarget } : {}
1565
1566
  });
1566
- var packageVersion = true ? "0.8.13-rc.1+cdaf24a5" : "dev";
1567
+ var packageVersion = true ? "0.8.13-rc.2+c00749ec" : "dev";
1567
1568
  var health = () => ({
1568
1569
  status: "ok",
1569
1570
  service: OBSERVER_SERVICE_NAME,