omp-fabric 1.28.0 → 1.28.1

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 (58) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +1 -1
  3. package/dist/capture/interceptor.d.ts.map +1 -1
  4. package/dist/chunks/{chunk-DKXNUCM2.js → chunk-4PPAWZM6.js} +9 -9
  5. package/dist/chunks/chunk-4PPAWZM6.js.map +7 -0
  6. package/dist/chunks/{chunk-O337ZL5J.js → chunk-CHXPTZUF.js} +4 -4
  7. package/dist/chunks/chunk-CHXPTZUF.js.map +7 -0
  8. package/dist/chunks/{chunk-MIGBZN2K.js → chunk-CYNNPPN4.js} +23 -11
  9. package/dist/chunks/chunk-CYNNPPN4.js.map +7 -0
  10. package/dist/chunks/{chunk-ANHZ3SWB.js → chunk-DGKGPZET.js} +9 -4
  11. package/dist/chunks/{chunk-ANHZ3SWB.js.map → chunk-DGKGPZET.js.map} +2 -2
  12. package/dist/chunks/{chunk-LK66YHVL.js → chunk-FVNEGH4J.js} +2 -2
  13. package/dist/chunks/{chunk-CNCRWY4Q.js → chunk-GS6IWGXQ.js} +9 -1
  14. package/dist/chunks/chunk-GS6IWGXQ.js.map +7 -0
  15. package/dist/chunks/{chunk-7QKSPNXQ.js → chunk-V5FB7D4C.js} +3 -3
  16. package/dist/chunks/{chunk-K3OSK6AX.js → chunk-VDYGBL4Z.js} +10 -10
  17. package/dist/chunks/chunk-VDYGBL4Z.js.map +7 -0
  18. package/dist/chunks/chunk-XVA63H6I.js +151 -0
  19. package/dist/chunks/chunk-XVA63H6I.js.map +7 -0
  20. package/dist/config.d.ts +2 -0
  21. package/dist/config.d.ts.map +1 -1
  22. package/dist/fabric-exec-tool.d.ts.map +1 -1
  23. package/dist/fabric-runtime-state.js +5 -5
  24. package/dist/host-compatibility.d.ts +1 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +16 -11
  27. package/dist/index.js.map +2 -2
  28. package/dist/residency/host.js +3 -3
  29. package/dist/residency/omp-entry.js +3 -3
  30. package/dist/topology/participant-directory.d.ts.map +1 -1
  31. package/dist/ui/conversation.js +3 -3
  32. package/dist/ui/dashboard.js +13 -14
  33. package/dist/ui/dashboard.js.map +3 -3
  34. package/dist/ui/fabric-actor-tool-selector.d.ts.map +1 -1
  35. package/dist/ui/fabric-host-event-selector.d.ts.map +1 -1
  36. package/dist/ui/fabric-model-selector.d.ts.map +1 -1
  37. package/dist/ui/settings.d.ts.map +1 -1
  38. package/dist/ui/settings.js +17 -13
  39. package/dist/ui/settings.js.map +2 -2
  40. package/dist/ui/tui/host-term.d.ts +16 -0
  41. package/dist/ui/tui/host-term.d.ts.map +1 -0
  42. package/dist/ui/tui/input.d.ts +4 -1
  43. package/dist/ui/tui/input.d.ts.map +1 -1
  44. package/dist/ui/tui/select-list.d.ts.map +1 -1
  45. package/dist/ui/tui/settings-list.d.ts.map +1 -1
  46. package/dist/ui/tui/view.d.ts.map +1 -1
  47. package/docs/configuration.md +2 -0
  48. package/docs/interface.md +13 -0
  49. package/package.json +6 -5
  50. package/dist/chunks/chunk-CNCRWY4Q.js.map +0 -7
  51. package/dist/chunks/chunk-DKXNUCM2.js.map +0 -7
  52. package/dist/chunks/chunk-K3OSK6AX.js.map +0 -7
  53. package/dist/chunks/chunk-MIGBZN2K.js.map +0 -7
  54. package/dist/chunks/chunk-O337ZL5J.js.map +0 -7
  55. package/dist/chunks/chunk-T76MXSP4.js +0 -32
  56. package/dist/chunks/chunk-T76MXSP4.js.map +0 -7
  57. /package/dist/chunks/{chunk-LK66YHVL.js.map → chunk-FVNEGH4J.js.map} +0 -0
  58. /package/dist/chunks/{chunk-7QKSPNXQ.js.map → chunk-V5FB7D4C.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.28.1
4
+
5
+ ### Changed
6
+
7
+ - OMP 19.2.1 is the minimum host. The peer floor of pi-coding-agent, pi-natives and pi-tui and `MINIMUM_OMP_HOST_VERSION` move from 19.2.0 to 19.2.1, the only host 1.28.0 ran on.
8
+ - Captured tools that declare `loadMode: "essential"` stay in the model-facing set in full code mode (#25, reported by @blyzer). `capture.keepEssentialVisible: false` hides them again; Schema enforce mode still keeps `fabric_exec` as the only model-facing tool.
9
+ - `fabric_exec` declares `loadMode: "essential"`, so the host never defers it out of the model-facing set (#21, by @UnderCooled).
10
+
11
+ ### Fixed
12
+
13
+ - A pi-tui module or export missing from the host no longer stops omp-fabric from loading. `term/paint`, `term/widgets`, `term/render`, `term/keymap` and `driver/input/decoder` load through dynamic imports, and each export Fabric calls is checked. When one is missing, Fabric warns once at startup and its views degrade: no mouse wheel scrolling, the default widget keys, keys taken from the host key event, and one notice row in place of a host-drawn preview. 19.2.1 itself dropped an internal pi-tui export (`oneLine` in `term/painters/picker`).
14
+ - `ParticipantDirectory.refresh()` no longer hands a caller the refresh that was already running. A caller that had just changed the mesh received a result read before its change; the heartbeat tick raced `tests/participant-directory.test.ts` this way on ubuntu (run 45939865443). A caller now waits for the running refresh and runs one more; the heartbeat still joins the running one.
15
+
16
+ ### Added
17
+
18
+ - `bun run check:host-imports` (`scripts/check-host-imports.mjs`) lists every `@oh-my-pi/*` specifier and named import in `dist/` and imports each one from the host packages; `--binary <omp>` also checks the module map compiled into an OMP binary. CI shard 1 runs it after the build.
19
+
20
+ ### Notes
21
+
22
+ - Prompt cost of the #25 change, `omp -p` on 19.2.1 with default full code mode: without an essential extension tool, 24 tools and 96,543 schema bytes before and after; one essential probe tool adds 1 tool and 324 schema bytes, and `capture.keepEssentialVisible: false` brings it back to 24.
23
+ - `tests/host-term-fallback.test.ts` fails 3 of its 4 tests with the static imports restored. `omp -p` on 19.2.1 with this build loads without the fallback warning.
24
+ - `check:host-imports` on 19.2.1: 83 files, 34 specifiers, 47 names in about 1.2 s, also clean with `--binary` against the installed omp 19.2.1.
25
+ - CI: Test run 45940500961 at the code commit ee4e5991 (#27) and run 45938061070 at bb9e8d9a (#21), green on ubuntu and windows.
26
+
3
27
  ## 1.28.0
4
28
 
5
29
  ### Changed (breaking)
package/README.md CHANGED
@@ -62,7 +62,7 @@ Independent calls run in parallel, and the returned object enters the model cont
62
62
 
63
63
  ## Install
64
64
 
65
- Requires Node.js 24+ and OMP 19.2.0+. OMP 19.2 replaced the pi-tui component library, so hosts from 18.4.4 to 19.1.x stay on omp-fabric 1.27.x. Fabric also checks a detectable OMP host version at startup and warns when an older host does not match the tool shapes Fabric types against.
65
+ Requires Node.js 24+ and OMP 19.2.1+. OMP 19.2 replaced the pi-tui component library, so hosts from 18.4.4 to 19.1.x stay on omp-fabric 1.27.x. Fabric also checks a detectable OMP host version at startup and warns when an older host does not match the tool shapes Fabric types against.
66
66
 
67
67
  ```bash
68
68
  omp install npm:omp-fabric
@@ -1 +1 @@
1
- {"version":3,"file":"interceptor.d.ts","sourceRoot":"","sources":["../../src/capture/interceptor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EAEf,cAAc,EACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAyB,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAQnD,MAAM,WAAW,+BAA+B;IAC9C,SAAS,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACjD,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,4BAA4B;IAC3C,gBAAgB,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC3C,OAAO,EAAE,mBAAmB,CAAC;IAC7B,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,SAAS,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;CAC1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1,6 @@
1
1
  import {
2
2
  TextField
3
- } from "./chunk-O337ZL5J.js";
3
+ } from "./chunk-CHXPTZUF.js";
4
4
  import {
5
5
  INHERIT_VALUE,
6
6
  modelKey,
@@ -10,13 +10,13 @@ import {
10
10
  BlankRows,
11
11
  Stack,
12
12
  TextBlock
13
- } from "./chunk-K3OSK6AX.js";
13
+ } from "./chunk-VDYGBL4Z.js";
14
14
  import {
15
+ keyMatches,
15
16
  keyOf
16
- } from "./chunk-T76MXSP4.js";
17
+ } from "./chunk-XVA63H6I.js";
17
18
 
18
19
  // src/ui/fabric-model-selector.ts
19
- import { widgetKeyMatches } from "@oh-my-pi/pi-tui/term/keymap";
20
20
  import { fuzzyFilter } from "@oh-my-pi/pi-coding-agent/utils/fuzzy";
21
21
  var FabricModelSelector = class extends Stack {
22
22
  theme;
@@ -63,18 +63,18 @@ var FabricModelSelector = class extends Stack {
63
63
  }
64
64
  handleInput(keyData) {
65
65
  const key = keyOf(keyData);
66
- if (key && widgetKeyMatches(key, "select.up")) {
66
+ if (key && keyMatches(key, "select.up")) {
67
67
  if (this.filteredEntries.length === 0) return;
68
68
  this.selectedIndex = this.selectedIndex === 0 ? this.filteredEntries.length - 1 : this.selectedIndex - 1;
69
69
  this.updateList();
70
- } else if (key && widgetKeyMatches(key, "select.down")) {
70
+ } else if (key && keyMatches(key, "select.down")) {
71
71
  if (this.filteredEntries.length === 0) return;
72
72
  this.selectedIndex = this.selectedIndex === this.filteredEntries.length - 1 ? 0 : this.selectedIndex + 1;
73
73
  this.updateList();
74
- } else if (key && widgetKeyMatches(key, "select.confirm")) {
74
+ } else if (key && keyMatches(key, "select.confirm")) {
75
75
  const entry = this.filteredEntries[this.selectedIndex];
76
76
  if (entry) this.handleSelect(entry);
77
- } else if (key && widgetKeyMatches(key, "select.cancel")) {
77
+ } else if (key && keyMatches(key, "select.cancel")) {
78
78
  this.onCancelCallback();
79
79
  } else {
80
80
  this.searchInput.handleInput(keyData);
@@ -178,4 +178,4 @@ var FabricModelSelector = class extends Stack {
178
178
  export {
179
179
  FabricModelSelector
180
180
  };
181
- //# sourceMappingURL=chunk-DKXNUCM2.js.map
181
+ //# sourceMappingURL=chunk-4PPAWZM6.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ui/fabric-model-selector.ts"],
4
+ "sourcesContent": ["import type { Theme } from \"@oh-my-pi/pi-tui/theme/contract\";\nimport { fuzzyFilter } from \"@oh-my-pi/pi-coding-agent/utils/fuzzy\";\nimport { keyMatches, keyOf } from \"./tui/input.js\";\nimport { BlankRows, Stack, TextBlock } from \"./tui/rows.js\";\nimport { TextField } from \"./tui/text-field.js\";\nimport type { FabricView } from \"./tui/view.js\";\nimport { INHERIT_VALUE, modelKey, sortByLastUsed, type ModelLike, type ModelSource } from \"./model-picker.js\";\n\n/** A single pickable row in the Fabric model selector. */\ninterface ModelEntry {\n /** Value persisted to fabric.json: \"Inherit\" or `provider/id`. */\n value: string;\n /** Main text shown for the row (the model id, or \"Inherit\"). */\n id: string;\n /** Provider badge shown after the id; empty for the Inherit row. */\n provider: string;\n /** Human-readable name shown in the footer line. */\n name: string;\n /** Whether this is a real model (vs. the Inherit sentinel). */\n isModel: boolean;\n}\n\nexport interface FabricModelSelectorChoice {\n value: string;\n label: string;\n description: string;\n current: boolean;\n}\n\nexport interface FabricModelSelectorOptions {\n theme: Theme;\n source: ModelSource;\n /** The currently configured canonical model key or \"Inherit\". */\n currentValue: string;\n onSelect: (value: string) => void;\n onCancel: () => void;\n /** Header line above the search input. Defaults to the global-default wording. */\n headerText?: string;\n /** Label shown for the unset/default row. Defaults to Inherit. */\n inheritLabel?: string;\n /** Description shown for the unset/default row's footer name. */\n inheritName?: string;\n}\n\n/**\n * A /model-style searchable model picker adapted for Fabric: same look\n * (search input, list with `[provider]` badges and a \u2713 on\n * the current row, scroll indicator, and a \"Model Name:\" footer) but it writes\n * the Fabric default-model setting instead of the host's default model, and\n * pins an unset/default row on top. Order respects pi-model-sort (most recently\n * used first); search filters by fuzzy match and re-sorts by recency, matching\n * pi-model-sort's patched /model behavior.\n */\nexport class FabricModelSelector extends Stack implements FabricView {\n private readonly theme: Theme;\n private readonly allEntries: ModelEntry[];\n private filteredEntries: ModelEntry[];\n private readonly lastUsed: Record<string, number>;\n private readonly currentKey: string | null;\n private readonly currentValue: string;\n private selectedIndex = 0;\n private readonly searchInput: TextField;\n private readonly listContainer = new Stack();\n private readonly onSelectCallback: (value: string) => void;\n private readonly onCancelCallback: () => void;\n private readonly headerText: string;\n private readonly inheritLabel: string;\n private readonly inheritName: string;\n\n constructor(options: FabricModelSelectorOptions) {\n super();\n this.theme = options.theme;\n this.lastUsed = options.source.lastUsed;\n this.currentValue = options.currentValue;\n this.currentKey = options.currentValue === INHERIT_VALUE ? null : options.currentValue;\n this.onSelectCallback = options.onSelect;\n this.onCancelCallback = options.onCancel;\n this.headerText =\n options.headerText ??\n \"Default model for Fabric agents and actors. Pick Inherit to use the host session's model.\";\n this.inheritLabel = options.inheritLabel ?? INHERIT_VALUE;\n this.inheritName = options.inheritName ?? \"Use the host session's default model\";\n\n this.allEntries = this.buildEntries(options.source.models);\n this.filteredEntries = this.allEntries;\n const current = this.allEntries.findIndex((entry) => entry.value === this.currentValue);\n this.selectedIndex = current >= 0 ? current : 0;\n\n this.add(new TextBlock(this.theme.fg(\"muted\", this.headerText)));\n this.add(new BlankRows(1));\n this.searchInput = new TextField();\n this.searchInput.onSubmit = () => {\n const entry = this.filteredEntries[this.selectedIndex];\n if (entry) this.handleSelect(entry);\n };\n this.add(this.searchInput);\n this.add(new BlankRows(1));\n this.add(this.listContainer);\n this.add(new BlankRows(1));\n this.updateList();\n }\n\n handleInput(keyData: string): void {\n const key = keyOf(keyData);\n if (key && keyMatches(key, \"select.up\")) {\n if (this.filteredEntries.length === 0) return;\n this.selectedIndex =\n this.selectedIndex === 0 ? this.filteredEntries.length - 1 : this.selectedIndex - 1;\n this.updateList();\n } else if (key && keyMatches(key, \"select.down\")) {\n if (this.filteredEntries.length === 0) return;\n this.selectedIndex =\n this.selectedIndex === this.filteredEntries.length - 1 ? 0 : this.selectedIndex + 1;\n this.updateList();\n } else if (key && keyMatches(key, \"select.confirm\")) {\n const entry = this.filteredEntries[this.selectedIndex];\n if (entry) this.handleSelect(entry);\n } else if (key && keyMatches(key, \"select.cancel\")) {\n this.onCancelCallback();\n } else {\n this.searchInput.handleInput(keyData);\n this.filterModels(this.searchInput.getText());\n }\n }\n\n rpcChoices(): FabricModelSelectorChoice[] {\n return this.allEntries.map((entry) => ({\n value: entry.value,\n label: entry.id,\n description: entry.isModel ? `${entry.provider} \u00B7 ${entry.name}` : entry.name,\n current: entry.value === this.currentValue,\n }));\n }\n\n selectRpc(value: string): boolean {\n const entry = this.allEntries.find((candidate) => candidate.value === value);\n if (!entry) return false;\n this.handleSelect(entry);\n return true;\n }\n\n private handleSelect(entry: ModelEntry): void {\n this.onSelectCallback(entry.value);\n }\n\n private buildEntries(models: ModelLike[]): ModelEntry[] {\n const sorted = sortByLastUsed(models, this.lastUsed, this.currentKey);\n const inherit: ModelEntry = {\n value: INHERIT_VALUE,\n id: this.inheritLabel,\n provider: \"\",\n name: this.inheritName,\n isModel: false,\n };\n const modelEntries: ModelEntry[] = sorted.map((model) => ({\n value: modelKey(model.provider, model.id),\n id: model.id,\n provider: model.provider,\n name: model.name ?? model.id,\n isModel: true,\n }));\n return [inherit, ...modelEntries];\n }\n\n /** Filter by fuzzy match, then re-sort by recency (mirrors pi-model-sort). */\n private sortEntries(entries: ModelEntry[]): ModelEntry[] {\n const inherit = entries.find((entry) => !entry.isModel);\n const models = entries.filter((entry) => entry.isModel);\n const sorted = sortByLastUsed(\n models.map((entry) => ({ provider: entry.provider, id: entry.id, entry })),\n this.lastUsed,\n this.currentKey,\n ).map((item) => item.entry);\n return inherit ? [inherit, ...sorted] : sorted;\n }\n\n private filterModels(query: string): void {\n const matches = query.trim()\n ? fuzzyFilter(this.allEntries, query, (entry) => this.searchText(entry))\n : this.allEntries;\n this.filteredEntries = this.sortEntries(matches);\n const current = this.filteredEntries.findIndex((entry) => entry.value === this.currentValue);\n this.selectedIndex =\n current >= 0\n ? current\n : Math.min(this.selectedIndex, Math.max(0, this.filteredEntries.length - 1));\n this.updateList();\n }\n\n /** Mirrors getModelSelectorSearchText from OMP's /model selector. */\n private searchText(entry: ModelEntry): string {\n if (!entry.isModel) return `${entry.id} ${entry.name}`;\n return `${entry.provider} ${entry.provider}/${entry.id} ${entry.provider} ${entry.id} ${entry.name}`;\n }\n\n private updateList(): void {\n this.listContainer.clear();\n const maxVisible = 10;\n const total = this.filteredEntries.length;\n const startIndex = Math.max(\n 0,\n Math.min(this.selectedIndex - Math.floor(maxVisible / 2), total - maxVisible),\n );\n const endIndex = Math.min(startIndex + maxVisible, total);\n for (let i = startIndex; i < endIndex; i++) {\n const entry = this.filteredEntries[i];\n if (!entry) continue;\n const isSelected = i === this.selectedIndex;\n const isCurrent = entry.value === this.currentValue;\n const badge = entry.provider ? ` ${this.theme.fg(\"muted\", `[${entry.provider}]`)}` : \"\";\n const check = isCurrent ? this.theme.fg(\"success\", \" \u2713\") : \"\";\n const line = isSelected\n ? `${this.theme.fg(\"accent\", \"\\u2192 \")}${this.theme.fg(\"accent\", entry.id)}${badge}${check}`\n : ` ${entry.id}${badge}${check}`;\n this.listContainer.add(new TextBlock(line));\n }\n if (startIndex > 0 || endIndex < total) {\n this.listContainer.add(\n new TextBlock(this.theme.fg(\"muted\", ` (${this.selectedIndex + 1}/${total})`)),\n );\n }\n if (total === 0) {\n this.listContainer.add(new TextBlock(this.theme.fg(\"muted\", \" No matching models\")));\n } else {\n const selected = this.filteredEntries[this.selectedIndex];\n this.listContainer.add(new BlankRows(1));\n this.listContainer.add(\n new TextBlock(this.theme.fg(\"muted\", ` Model Name: ${selected ? selected.name : \"\"}`)),\n );\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AACA,SAAS,mBAAmB;AAoDrB,IAAM,sBAAN,cA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QAAI,UAAU,GAAG;AACf,WAAK,cAAc,IAAI,IAAI,UAAU,KAAK,MAAM,GAAG,SAAS,sBAAsB,CAAC,CAAC;AAAA,IACtF,OAAO;AACL,YAAM,WAAW,KAAK,gBAAgB,KAAK,aAAa;AACxD,WAAK,cAAc,IAAI,IAAI,UAAU,CAAC,CAAC;AACvC,WAAK,cAAc;AAAA,QACjB,IAAI,UAAU,KAAK,MAAM,GAAG,SAAS,iBAAiB,WAAW,SAAS,OAAO,EAAE,EAAE,CAAC;AAAA,MACxF;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,10 +1,10 @@
1
1
  import {
2
+ actionOf,
2
3
  decodeTerminalInput,
3
4
  typedText
4
- } from "./chunk-T76MXSP4.js";
5
+ } from "./chunk-XVA63H6I.js";
5
6
 
6
7
  // src/ui/tui/text-field.ts
7
- import { widgetActionOf } from "@oh-my-pi/pi-tui/term/keymap";
8
8
  import { inverse } from "@oh-my-pi/pi-tui/theme/theme";
9
9
  import { visibleWidth } from "@oh-my-pi/pi-tui/text/width";
10
10
  var EDIT_ACTIONS = [
@@ -71,7 +71,7 @@ var TextField = class {
71
71
  this.onSubmit?.(this.text);
72
72
  return true;
73
73
  }
74
- const action = widgetActionOf(key.id, EDIT_ACTIONS);
74
+ const action = actionOf(key.id, EDIT_ACTIONS);
75
75
  if (action) return this.apply(action);
76
76
  const typed = typedText(key);
77
77
  if (typed === void 0) return false;
@@ -274,4 +274,4 @@ var TextField = class {
274
274
  export {
275
275
  TextField
276
276
  };
277
- //# sourceMappingURL=chunk-O337ZL5J.js.map
277
+ //# sourceMappingURL=chunk-CHXPTZUF.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ui/tui/text-field.ts"],
4
+ "sourcesContent": ["import type { KeyEvent } from \"@oh-my-pi/pi-tui\";\nimport type { WidgetAction } from \"@oh-my-pi/pi-tui/term/keymap\";\nimport { inverse } from \"@oh-my-pi/pi-tui/theme/theme\";\nimport { visibleWidth } from \"@oh-my-pi/pi-tui/text/width\";\nimport { actionOf, decodeTerminalInput, typedText } from \"./input.js\";\nimport type { Rows } from \"./view.js\";\n\ninterface TextFieldOptions {\n multiline?: boolean;\n prompt?: string;\n}\n\ninterface Snapshot {\n text: string;\n cursor: number;\n}\n\nconst EDIT_ACTIONS: readonly WidgetAction[] = [\n \"editor.newLine\",\n \"editor.cursorLeft\",\n \"editor.cursorRight\",\n \"editor.cursorWordLeft\",\n \"editor.cursorWordRight\",\n \"editor.cursorLineStart\",\n \"editor.cursorLineEnd\",\n \"editor.cursorUp\",\n \"editor.cursorDown\",\n \"editor.deleteCharBackward\",\n \"editor.deleteCharForward\",\n \"editor.deleteWordBackward\",\n \"editor.deleteWordForward\",\n \"editor.deleteToLineStart\",\n \"editor.deleteToLineEnd\",\n \"editor.yank\",\n \"editor.undo\",\n];\n\nconst UNDO_LIMIT = 100;\nconst segmenter = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\nconst graphemes = (text: string): string[] => Array.from(segmenter.segment(text), (part) => part.segment);\nconst isWordChar = (grapheme: string): boolean => /[\\p{L}\\p{N}_]/u.test(grapheme);\n\nexport class TextField implements Rows {\n onSubmit: ((text: string) => void) | undefined;\n onChange: ((text: string) => void) | undefined;\n focused = true;\n private text = \"\";\n private cursor = 0;\n private killed = \"\";\n private readonly undoStack: Snapshot[] = [];\n private preferredColumn: number | undefined;\n private lastCursorRow = 0;\n private readonly multiline: boolean;\n private readonly prompt: string;\n\n constructor(options: TextFieldOptions = {}) {\n this.multiline = options.multiline ?? false;\n this.prompt = options.prompt ?? (this.multiline ? \"\" : \"> \");\n }\n\n getText(): string {\n return this.text;\n }\n\n setText(text: string): void {\n const next = this.normalize(text);\n if (next === this.text) return;\n this.text = next;\n this.cursor = next.length;\n this.preferredColumn = undefined;\n this.onChange?.(this.text);\n }\n\n get cursorRow(): number {\n return this.lastCursorRow;\n }\n\n handleInput(data: string): void {\n for (const event of decodeTerminalInput(data)) {\n if (event.type === \"paste\") this.insert(event.text);\n else this.handleKey(event.key);\n }\n }\n\n handleKey(key: KeyEvent): boolean {\n if (key.id === \"enter\") {\n this.onSubmit?.(this.text);\n return true;\n }\n const action = actionOf(key.id, EDIT_ACTIONS);\n if (action) return this.apply(action);\n const typed = typedText(key);\n if (typed === undefined) return false;\n this.insert(typed);\n return true;\n }\n\n render(width: number): string[] {\n return this.multiline ? this.renderLines(width) : [this.renderLine(width)];\n }\n\n private apply(action: WidgetAction): boolean {\n const before = this.text.slice(0, this.cursor);\n const after = this.text.slice(this.cursor);\n const lineStart = before.lastIndexOf(\"\\n\") + 1;\n const lineEndOffset = after.indexOf(\"\\n\");\n const lineEnd = lineEndOffset < 0 ? this.text.length : this.cursor + lineEndOffset;\n switch (action) {\n case \"editor.newLine\":\n if (!this.multiline) return false;\n this.insert(\"\\n\");\n return true;\n case \"editor.cursorLeft\":\n return this.moveTo(this.cursor - (graphemes(before).at(-1)?.length ?? 0));\n case \"editor.cursorRight\":\n return this.moveTo(this.cursor + (graphemes(after)[0]?.length ?? 0));\n case \"editor.cursorWordLeft\":\n return this.moveTo(this.wordBoundaryBefore());\n case \"editor.cursorWordRight\":\n return this.moveTo(this.wordBoundaryAfter());\n case \"editor.cursorLineStart\":\n return this.moveTo(lineStart);\n case \"editor.cursorLineEnd\":\n return this.moveTo(lineEnd);\n case \"editor.cursorUp\":\n return this.moveVertical(-1);\n case \"editor.cursorDown\":\n return this.moveVertical(1);\n case \"editor.deleteCharBackward\":\n return this.remove(this.cursor - (graphemes(before).at(-1)?.length ?? 0), this.cursor, false);\n case \"editor.deleteCharForward\":\n return this.remove(this.cursor, this.cursor + (graphemes(after)[0]?.length ?? 0), false);\n case \"editor.deleteWordBackward\":\n return this.remove(this.wordBoundaryBefore(), this.cursor, true);\n case \"editor.deleteWordForward\":\n return this.remove(this.cursor, this.wordBoundaryAfter(), true);\n case \"editor.deleteToLineStart\":\n return this.remove(lineStart === this.cursor && lineStart > 0 ? lineStart - 1 : lineStart, this.cursor, true);\n case \"editor.deleteToLineEnd\":\n return this.remove(this.cursor, lineEnd === this.cursor && lineEnd < this.text.length ? lineEnd + 1 : lineEnd, true);\n case \"editor.yank\":\n if (this.killed === \"\") return false;\n this.insert(this.killed);\n return true;\n case \"editor.undo\": {\n const previous = this.undoStack.pop();\n if (!previous) return false;\n this.text = previous.text;\n this.cursor = previous.cursor;\n this.preferredColumn = undefined;\n this.onChange?.(this.text);\n return true;\n }\n default:\n return false;\n }\n }\n\n private normalize(text: string): string {\n const unified = text.replace(/\\r\\n?/g, \"\\n\");\n return this.multiline ? unified : unified.replace(/\\n/g, \" \");\n }\n\n private remember(): void {\n this.undoStack.push({ text: this.text, cursor: this.cursor });\n if (this.undoStack.length > UNDO_LIMIT) this.undoStack.shift();\n }\n\n private insert(raw: string): void {\n const text = this.normalize(raw);\n if (text === \"\") return;\n this.remember();\n this.text = `${this.text.slice(0, this.cursor)}${text}${this.text.slice(this.cursor)}`;\n this.cursor += text.length;\n this.preferredColumn = undefined;\n this.onChange?.(this.text);\n }\n\n private remove(from: number, to: number, kill: boolean): boolean {\n if (to <= from) return false;\n this.remember();\n if (kill) this.killed = this.text.slice(from, to);\n this.text = `${this.text.slice(0, from)}${this.text.slice(to)}`;\n this.cursor = from;\n this.preferredColumn = undefined;\n this.onChange?.(this.text);\n return true;\n }\n\n private moveTo(offset: number): boolean {\n this.cursor = Math.max(0, Math.min(offset, this.text.length));\n this.preferredColumn = undefined;\n return true;\n }\n\n private moveVertical(direction: -1 | 1): boolean {\n if (!this.multiline) return false;\n const lines = this.text.split(\"\\n\");\n let row = 0;\n let offset = 0;\n while (row < lines.length - 1 && offset + lines[row]!.length < this.cursor) {\n offset += lines[row]!.length + 1;\n row++;\n }\n const target = row + direction;\n if (target < 0 || target >= lines.length) return false;\n const column = this.preferredColumn ?? visibleWidth(this.text.slice(offset, this.cursor));\n const targetStart = direction < 0\n ? offset - lines[target]!.length - 1\n : offset + lines[row]!.length + 1;\n let position = targetStart;\n let width = 0;\n for (const grapheme of graphemes(lines[target]!)) {\n const next = width + visibleWidth(grapheme);\n if (next > column) break;\n width = next;\n position += grapheme.length;\n }\n this.cursor = position;\n this.preferredColumn = column;\n return true;\n }\n\n private wordBoundaryBefore(): number {\n const parts = graphemes(this.text.slice(0, this.cursor));\n let index = parts.length;\n while (index > 0 && !isWordChar(parts[index - 1]!)) index--;\n while (index > 0 && isWordChar(parts[index - 1]!)) index--;\n return parts.slice(0, index).join(\"\").length;\n }\n\n private wordBoundaryAfter(): number {\n const parts = graphemes(this.text.slice(this.cursor));\n let index = 0;\n while (index < parts.length && !isWordChar(parts[index]!)) index++;\n while (index < parts.length && isWordChar(parts[index]!)) index++;\n return this.cursor + parts.slice(0, index).join(\"\").length;\n }\n\n private caret(grapheme: string): string {\n return this.focused ? inverse(grapheme) : grapheme;\n }\n\n private renderLine(width: number): string {\n const room = Math.max(1, width - visibleWidth(this.prompt));\n const before = graphemes(this.text.slice(0, this.cursor));\n const after = graphemes(this.text.slice(this.cursor));\n const atCursor = after.shift() ?? \" \";\n let used = visibleWidth(atCursor);\n const left: string[] = [];\n for (let index = before.length - 1; index >= 0 && used + visibleWidth(before[index]!) <= room; index--) {\n left.unshift(before[index]!);\n used += visibleWidth(before[index]!);\n }\n const right: string[] = [];\n for (const grapheme of after) {\n if (used + visibleWidth(grapheme) > room) break;\n right.push(grapheme);\n used += visibleWidth(grapheme);\n }\n this.lastCursorRow = 0;\n return `${this.prompt}${left.join(\"\")}${this.caret(atCursor)}${right.join(\"\")}`;\n }\n\n private renderLines(width: number): string[] {\n const room = Math.max(1, width - visibleWidth(this.prompt));\n const indent = \" \".repeat(visibleWidth(this.prompt));\n const rows: string[] = [];\n let offset = 0;\n this.lastCursorRow = 0;\n for (const line of this.text.split(\"\\n\")) {\n let row = \"\";\n let used = 0;\n let position = offset;\n const cursorOnLine = this.cursor >= offset && this.cursor <= offset + line.length;\n const flush = (): void => {\n rows.push(`${rows.length === 0 ? this.prompt : indent}${row}`);\n row = \"\";\n used = 0;\n };\n for (const grapheme of graphemes(line)) {\n const cells = visibleWidth(grapheme);\n if (used + cells > room && used > 0) flush();\n if (position === this.cursor) {\n this.lastCursorRow = rows.length;\n row += this.caret(grapheme);\n } else {\n row += grapheme;\n }\n used += cells;\n position += grapheme.length;\n }\n if (cursorOnLine && this.cursor === offset + line.length) {\n if (used + 1 > room && used > 0) flush();\n this.lastCursorRow = rows.length;\n row += this.caret(\" \");\n }\n flush();\n offset += line.length + 1;\n }\n return rows;\n }\n}\n"],
5
+ "mappings": ";;;;;;;AAEA,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAc7B,IAAM,eAAwC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,aAAa;AACnB,IAAM,YAAY,IAAI,KAAK,UAAU,QAAW,EAAE,aAAa,WAAW,CAAC;AAC3E,IAAM,YAAY,CAAC,SAA2B,MAAM,KAAK,UAAU,QAAQ,IAAI,GAAG,CAAC,SAAS,KAAK,OAAO;AACxG,IAAM,aAAa,CAAC,aAA8B,iBAAiB,KAAK,QAAQ;AAEzE,IAAM,YAAN,MAAgC;AAAA,EACrC;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACF,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACA,YAAwB,CAAC;AAAA,EAClC;AAAA,EACA,gBAAgB;AAAA,EACP;AAAA,EACA;AAAA,EAEjB,YAAY,UAA4B,CAAC,GAAG;AAC1C,SAAK,YAAY,QAAQ,aAAa;AACtC,SAAK,SAAS,QAAQ,WAAW,KAAK,YAAY,KAAK;AAAA,EACzD;AAAA,EAEA,UAAkB;AAChB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAQ,M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C,UAAM,OAAO,KAAK,IAAI,GAAG,QAAQ,aAAa,KAAK,MAAM,CAAC;AAC1D,UAAM,SAAS,IAAI,OAAO,aAAa,KAAK,MAAM,CAAC;AACnD,UAAM,OAAiB,CAAC;AACxB,QAAI,SAAS;AACb,SAAK,gBAAgB;AACrB,eAAW,QAAQ,KAAK,KAAK,MAAM,IAAI,GAAG;AACxC,UAAI,MAAM;AACV,UAAI,OAAO;AACX,UAAI,WAAW;AACf,YAAM,eAAe,KAAK,UAAU,UAAU,KAAK,UAAU,SAAS,KAAK;AAC3E,YAAM,QAAQ,MAAY;AACxB,aAAK,KAAK,GAAG,KAAK,WAAW,IAAI,KAAK,SAAS,MAAM,GAAG,GAAG,EAAE;AAC7D,cAAM;AACN,eAAO;AAAA,MACT;AACA,iBAAW,YAAY,UAAU,IAAI,GAAG;AACtC,cAAM,QAAQ,aAAa,QAAQ;AACnC,YAAI,OAAO,QAAQ,QAAQ,OAAO,EAAG,OAAM;AAC3C,YAAI,aAAa,KAAK,QAAQ;AAC5B,eAAK,gBAAgB,KAAK;AAC1B,iBAAO,KAAK,MAAM,QAAQ;AAAA,QAC5B,OAAO;AACL,iBAAO;AAAA,QACT;AACA,gBAAQ;AACR,oBAAY,SAAS;AAAA,MACvB;AACA,UAAI,gBAAgB,KAAK,WAAW,SAAS,KAAK,QAAQ;AACxD,YAAI,OAAO,IAAI,QAAQ,OAAO,EAAG,OAAM;AACvC,aAAK,gBAAgB,KAAK;AAC1B,eAAO,KAAK,MAAM,GAAG;AAAA,MACvB;AACA,YAAM;AACN,gBAAU,KAAK,SAAS;AAAA,IAC1B;AACA,WAAO;AAAA,EACT;AACF;",
6
+ "names": []
7
+ }
@@ -1,21 +1,25 @@
1
+ import {
2
+ hostTerm,
3
+ rememberHostKey
4
+ } from "./chunk-XVA63H6I.js";
5
+
1
6
  // src/ui/tui/view.ts
2
7
  import { isUiNode, signal, UiNode, untrack } from "@oh-my-pi/pi-tui";
3
- import { defineRolePainter } from "@oh-my-pi/pi-tui/term/paint";
4
- import { renderBlock } from "@oh-my-pi/pi-tui/term/render";
5
- import { defineRoleWidget } from "@oh-my-pi/pi-tui/term/widgets";
6
8
  import { truncate } from "@oh-my-pi/pi-tui/text/width";
7
9
  var VIEW_ROLE = "fabric.view";
8
10
  var WHEEL_ROWS = 3;
9
11
  var mounted = /* @__PURE__ */ new WeakMap();
10
12
  var roleRegistered = false;
11
13
  var registerRole = () => {
12
- if (roleRegistered) return;
14
+ if (roleRegistered) return true;
15
+ const { paint, widgets } = hostTerm();
16
+ if (!paint || !widgets) return false;
13
17
  roleRegistered = true;
14
- defineRolePainter("canvas", VIEW_ROLE, (node, cx) => {
18
+ paint.defineRolePainter("canvas", VIEW_ROLE, (node, cx) => {
15
19
  const rows = mounted.get(node)?.paint(cx.width) ?? [];
16
20
  return { rows, hits: rows.length > 0 ? [{ row: 0, col: 0, width: cx.width, height: rows.length, node }] : [] };
17
21
  });
18
- defineRoleWidget("canvas", VIEW_ROLE, {
22
+ widgets.defineRoleWidget("canvas", VIEW_ROLE, {
19
23
  mouse(node, mouse) {
20
24
  const entry = mounted.get(node);
21
25
  if (!entry?.view.handleWheel || mouse.action !== "press") return false;
@@ -25,18 +29,22 @@ var registerRole = () => {
25
29
  return true;
26
30
  }
27
31
  });
32
+ return true;
28
33
  };
29
34
  var EMPTY_ROWS = { render: () => [] };
35
+ var HOST_PREVIEW_UNAVAILABLE = "Preview unavailable: this OMP host does not provide pi-tui term/render.";
30
36
  var isRows = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !isUiNode(value) && "render" in value && typeof value.render === "function";
31
37
  var asRows = (output, theme) => {
32
38
  if (output === void 0 || output === null || output === false || output === "") return EMPTY_ROWS;
33
39
  if (isRows(output)) return output;
40
+ const render = hostTerm().render;
41
+ if (!render) return { render: (width) => [truncate(HOST_PREVIEW_UNAVAILABLE, width)] };
34
42
  const node = isUiNode(output) ? output : new UiNode("col", { children: output });
35
- return { render: (width) => renderBlock(node, width, { theme }).rows };
43
+ return { render: (width) => render.renderBlock(node, width, { theme }).rows };
36
44
  };
37
45
  var errorText = (error) => error instanceof Error ? error.message : String(error);
38
46
  var mountView = (size, build, onError) => {
39
- registerRole();
47
+ const role = registerRole();
40
48
  const revision = signal(0);
41
49
  const requestRender = () => revision.set(untrack(revision) + 1);
42
50
  const view = build({ requestRender, size });
@@ -65,8 +73,12 @@ var mountView = (size, build, onError) => {
65
73
  };
66
74
  const node = new UiNode("canvas", {
67
75
  paint,
68
- term: { role: VIEW_ROLE },
69
- onKey: (key) => key.kind !== "release" && deliver(key.raw),
76
+ ...role ? { term: { role: VIEW_ROLE } } : {},
77
+ onKey: (key) => {
78
+ if (key.kind === "release") return false;
79
+ rememberHostKey(key);
80
+ return deliver(key.raw);
81
+ },
70
82
  onPaste: (paste) => deliver(`\x1B[200~${paste.text}\x1B[201~`)
71
83
  });
72
84
  mounted.set(node, { view, paint, wheel: (rows) => contain(() => view.handleWheel?.(rows)) });
@@ -78,4 +90,4 @@ export {
78
90
  asRows,
79
91
  mountView
80
92
  };
81
- //# sourceMappingURL=chunk-MIGBZN2K.js.map
93
+ //# sourceMappingURL=chunk-CYNNPPN4.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ui/tui/view.ts"],
4
+ "sourcesContent": ["import { isUiNode, signal, type KeyEvent, type PasteEvent, UiNode, untrack } from \"@oh-my-pi/pi-tui\";\nimport type { Theme } from \"@oh-my-pi/pi-tui/theme/contract\";\nimport { truncate } from \"@oh-my-pi/pi-tui/text/width\";\nimport { hostTerm } from \"./host-term.js\";\nimport { rememberHostKey } from \"./input.js\";\n\nexport interface Rows {\n render(width: number): readonly string[];\n invalidate?(): void;\n}\n\nexport interface FabricView extends Rows {\n handleInput?(data: string): void;\n handleWheel?(rows: number): void;\n dispose?(): void;\n}\n\nexport interface FabricViewHost {\n requestRender(): void;\n size(): { readonly columns: number; readonly rows: number };\n}\n\nconst VIEW_ROLE = \"fabric.view\";\nconst WHEEL_ROWS = 3;\nconst mounted = new WeakMap<UiNode, { view: FabricView; paint: (width: number) => string[]; wheel: (rows: number) => void }>();\nlet roleRegistered = false;\n\nconst registerRole = (): boolean => {\n if (roleRegistered) return true;\n const { paint, widgets } = hostTerm();\n if (!paint || !widgets) return false;\n roleRegistered = true;\n paint.defineRolePainter(\"canvas\", VIEW_ROLE, (node, cx) => {\n const rows = mounted.get(node)?.paint(cx.width) ?? [];\n return { rows, hits: rows.length > 0 ? [{ row: 0, col: 0, width: cx.width, height: rows.length, node }] : [] };\n });\n widgets.defineRoleWidget(\"canvas\", VIEW_ROLE, {\n mouse(node, mouse) {\n const entry = mounted.get(node);\n if (!entry?.view.handleWheel || mouse.action !== \"press\") return false;\n if (mouse.button === \"wheel-up\") entry.wheel(-WHEEL_ROWS);\n else if (mouse.button === \"wheel-down\") entry.wheel(WHEEL_ROWS);\n else return false;\n return true;\n },\n });\n return true;\n};\n\nexport const mountedView = (node: unknown): FabricView | undefined =>\n isUiNode(node) ? mounted.get(node)?.view : undefined;\n\nconst EMPTY_ROWS: Rows = { render: () => [] };\nconst HOST_PREVIEW_UNAVAILABLE = \"Preview unavailable: this OMP host does not provide pi-tui term/render.\";\n\nexport const isRows = (value: unknown): value is Rows =>\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n !isUiNode(value) &&\n \"render\" in value &&\n typeof value.render === \"function\";\n\nexport const asRows = (output: unknown, theme: Theme): Rows => {\n if (output === undefined || output === null || output === false || output === \"\") return EMPTY_ROWS;\n if (isRows(output)) return output;\n const render = hostTerm().render;\n if (!render) return { render: (width) => [truncate(HOST_PREVIEW_UNAVAILABLE, width)] };\n const node = isUiNode(output) ? output : new UiNode(\"col\", { children: output });\n return { render: (width) => render.renderBlock(node, width, { theme }).rows };\n};\n\nconst errorText = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\nexport const mountView = <V extends FabricView>(\n size: FabricViewHost[\"size\"],\n build: (host: FabricViewHost) => V,\n onError?: (error: unknown) => void,\n): { node: UiNode; view: V } => {\n const role = registerRole();\n const revision = signal(0);\n const requestRender = (): void => revision.set(untrack(revision) + 1);\n const view = build({ requestRender, size });\n let paintFailed = false;\n const contain = (action: () => void): true => {\n try {\n action();\n } catch (error) {\n onError?.(error);\n }\n requestRender();\n return true;\n };\n const deliver = (data: string): boolean => contain(() => view.handleInput?.(data));\n const paint = (width: number): string[] => {\n revision();\n try {\n const rows = view.render(width).map((row) => truncate(row, width, \"\"));\n paintFailed = false;\n return rows;\n } catch (error) {\n if (!paintFailed) onError?.(error);\n paintFailed = true;\n return [truncate(`\u26A0 Fabric view failed to render: ${errorText(error)}`, width)];\n }\n };\n const node = new UiNode(\"canvas\", {\n paint,\n ...(role ? { term: { role: VIEW_ROLE } } : {}),\n onKey: (key: KeyEvent) => {\n if (key.kind === \"release\") return false;\n rememberHostKey(key);\n return deliver(key.raw);\n },\n onPaste: (paste: PasteEvent) => deliver(`\\x1b[200~${paste.text}\\x1b[201~`),\n });\n mounted.set(node, { view, paint, wheel: (rows) => contain(() => view.handleWheel?.(rows)) });\n return { node, view };\n};\n"],
5
+ "mappings": ";;;;;;AAAA,SAAS,UAAU,QAAwC,QAAQ,eAAe;AAElF,SAAS,gBAAgB;AAoBzB,IAAM,YAAY;AAClB,IAAM,aAAa;AACnB,IAAM,UAAU,oBAAI,QAAyG;AAC7H,IAAI,iBAAiB;AAErB,IAAM,eAAe,MAAe;AAClC,MAAI,eAAgB,QAAO;AAC3B,QAAM,EAAE,OAAO,QAAQ,IAAI,SAAS;AACpC,MAAI,CAAC,SAAS,CAAC,QAAS,QAAO;AAC/B,mBAAiB;AACjB,QAAM,kBAAkB,UAAU,WAAW,CAAC,MAAM,OAAO;AACzD,UAAM,OAAO,QAAQ,IAAI,IAAI,GAAG,MAAM,GAAG,KAAK,KAAK,CAAC;AACpD,WAAO,EAAE,MAAM,MAAM,KAAK,SAAS,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,O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ENT_TIMEOUT_MS,
32
32
  MIN_AGENT_TIMEOUT_MS,
33
33
  resolveAgentDir
34
- } from "./chunk-CNCRWY4Q.js";
34
+ } from "./chunk-GS6IWGXQ.js";
35
35
  import {
36
36
  THINKING_LEVELS,
37
37
  isFabricThinking
@@ -6507,7 +6507,7 @@ var ParticipantDirectory = class {
6507
6507
  initialError = error;
6508
6508
  }
6509
6509
  if (this.options.enabled) {
6510
- this.#timer = setInterval(() => void this.refresh().catch(() => void 0), this.#heartbeatMs);
6510
+ this.#timer = setInterval(() => void (this.#refreshing ?? this.refresh()).catch(() => void 0), this.#heartbeatMs);
6511
6511
  this.#timer.unref();
6512
6512
  }
6513
6513
  if (initialError) throw initialError;
@@ -6527,7 +6527,12 @@ var ParticipantDirectory = class {
6527
6527
  }
6528
6528
  async refresh() {
6529
6529
  if (this.#closed) return;
6530
- if (this.#refreshing) return this.#refreshing;
6530
+ const inFlight = this.#refreshing;
6531
+ if (inFlight) {
6532
+ await inFlight.catch(() => void 0);
6533
+ if (this.#closed) return;
6534
+ if (this.#refreshing && this.#refreshing !== inFlight) return this.#refreshing;
6535
+ }
6531
6536
  const operation = this.#refresh();
6532
6537
  this.#refreshing = operation;
6533
6538
  try {
@@ -7003,4 +7008,4 @@ export {
7003
7008
  agentParticipantRecords,
7004
7009
  actorParticipantRecord
7005
7010
  };
7006
- //# sourceMappingURL=chunk-ANHZ3SWB.js.map
7011
+ //# sourceMappingURL=chunk-DGKGPZET.js.map