omnius 1.0.932 → 1.0.934
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.
- package/dist/index.js +2 -2
- package/dist/tui/native/worker.js +166 -0
- package/dist/update-worker-runtime.js +72 -4
- package/dist/update-worker.js +89 -6
- package/docs/getting-started/install.md +26 -0
- package/docs/guides/telegram.md +11 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/dist/index.js
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 41409090 bytes
|
|
4
|
+
sha256: 75db10244c46c9e454a1b4b1a16022fbf00325ce81bff455e75b5cff51ec04a0
|
|
@@ -73,6 +73,7 @@ function sanitizeNativeInterfaceState(value) {
|
|
|
73
73
|
scrollTop: offset(instruments.scrollTop),
|
|
74
74
|
deviceScrollTop: offset(instruments.deviceScrollTop),
|
|
75
75
|
...typeof instruments.routeAttempts === "boolean" ? { routeAttempts: instruments.routeAttempts } : {},
|
|
76
|
+
...typeof instruments.telegram === "boolean" ? { telegram: instruments.telegram } : {},
|
|
76
77
|
...taskNotes ? { taskNotes: { open: taskNotes.open !== false, tasks: taskNotes.tasks !== false, notes: taskNotes.notes !== false, layers: taskNotes.layers !== false, disclosures: taskDisclosures } } : {},
|
|
77
78
|
...workQueue ? { workQueue: { open: workQueue.open !== false, history: workQueue.history === true, disclosures: workDisclosures } } : {},
|
|
78
79
|
...workspaceFiles ? { workspaceFiles: {
|
|
@@ -5745,10 +5746,166 @@ var ChannelMap = class extends BoxRenderable9 {
|
|
|
5745
5746
|
}
|
|
5746
5747
|
}
|
|
5747
5748
|
};
|
|
5749
|
+
var NativeTelegramView = class extends BoxRenderable9 {
|
|
5750
|
+
constructor(renderer2, colors, onAction, reveal) {
|
|
5751
|
+
super(renderer2, { id: "omnius-telegram", width: "100%", minWidth: 0, flexDirection: "column", flexShrink: 0, visible: false });
|
|
5752
|
+
this.renderer = renderer2;
|
|
5753
|
+
this.colors = colors;
|
|
5754
|
+
this.onAction = onAction;
|
|
5755
|
+
this.reveal = reveal;
|
|
5756
|
+
this.header = new SectionBanner(renderer2, "TELEGRAM", "omnius-telegram:heading", () => this.setExpanded(!this.expanded));
|
|
5757
|
+
this.header.update("TELEGRAM", false);
|
|
5758
|
+
this.header.on(RenderableEvents6.FOCUSED, () => this.reveal?.(this.header));
|
|
5759
|
+
this.add(this.header);
|
|
5760
|
+
this.body = new BoxRenderable9(renderer2, { id: "omnius-telegram:body", width: "100%", minWidth: 0, flexDirection: "column", flexShrink: 0, visible: false });
|
|
5761
|
+
this.add(this.body);
|
|
5762
|
+
const text = (id) => new TextRenderable8(renderer2, {
|
|
5763
|
+
id,
|
|
5764
|
+
content: "",
|
|
5765
|
+
width: "100%",
|
|
5766
|
+
minWidth: 0,
|
|
5767
|
+
flexShrink: 0,
|
|
5768
|
+
wrapMode: "word",
|
|
5769
|
+
fg: colors.foreground,
|
|
5770
|
+
bg: colors.background
|
|
5771
|
+
});
|
|
5772
|
+
this.details = text("omnius-telegram:details");
|
|
5773
|
+
this.body.add(this.details);
|
|
5774
|
+
this.error = text("omnius-telegram:error");
|
|
5775
|
+
this.body.add(this.error);
|
|
5776
|
+
this.applyTheme(colors);
|
|
5777
|
+
}
|
|
5778
|
+
renderer;
|
|
5779
|
+
colors;
|
|
5780
|
+
onAction;
|
|
5781
|
+
reveal;
|
|
5782
|
+
header;
|
|
5783
|
+
body;
|
|
5784
|
+
details;
|
|
5785
|
+
error;
|
|
5786
|
+
actions = /* @__PURE__ */ new Map();
|
|
5787
|
+
expanded = false;
|
|
5788
|
+
busy = false;
|
|
5789
|
+
ownsFocus() {
|
|
5790
|
+
for (let node = this.renderer.currentFocusedRenderable; node; node = node.parent) {
|
|
5791
|
+
if (node === this) return true;
|
|
5792
|
+
}
|
|
5793
|
+
return false;
|
|
5794
|
+
}
|
|
5795
|
+
update(state) {
|
|
5796
|
+
this.visible = state?.configured === true;
|
|
5797
|
+
this.body.visible = this.visible && this.expanded;
|
|
5798
|
+
if (!this.visible || !state) return;
|
|
5799
|
+
this.busy = state.busy === true;
|
|
5800
|
+
const safe3 = (value) => plainText(value).replace(/[\r\n\t]+/g, " ");
|
|
5801
|
+
const details = [
|
|
5802
|
+
`STATUS ${state.status.toUpperCase()} · ${state.owner.toUpperCase()}${state.busy ? " · UPDATING" : ""}`,
|
|
5803
|
+
...state.botUsername ? [`BOT @${safe3(state.botUsername).replace(/^@/, "")}`] : [],
|
|
5804
|
+
`MODE ${state.mode.toUpperCase()} · SLOTS ${instrumentNumber(state.slots)}`,
|
|
5805
|
+
`POLLING ${state.enabled ? "ENABLED" : "DISABLED"}${state.pollPhase ? ` · ${safe3(state.pollPhase)}` : ""}`,
|
|
5806
|
+
...state.activeTasks !== void 0 || state.queuedTasks !== void 0 ? [`TASKS ${instrumentNumber(state.activeTasks)} ACTIVE · ${instrumentNumber(state.queuedTasks)} QUEUED`] : [],
|
|
5807
|
+
...state.privacyLimited ? ["Group visibility is limited by bot privacy."] : [],
|
|
5808
|
+
...state.restartRequired ? ["Restart required to apply settings."] : [],
|
|
5809
|
+
...state.detail ? [safe3(state.detail)] : []
|
|
5810
|
+
].join("\n");
|
|
5811
|
+
if (this.details.plainText !== details) this.details.content = details;
|
|
5812
|
+
this.error.content = safe3(state.error);
|
|
5813
|
+
this.error.visible = Boolean(state.error);
|
|
5814
|
+
const current = new Set(state.actions.map((action) => action.id));
|
|
5815
|
+
for (const [id, row] of this.actions) if (!current.has(id)) {
|
|
5816
|
+
if (row.control.focused) this.header.focus();
|
|
5817
|
+
row.control.destroy();
|
|
5818
|
+
this.actions.delete(id);
|
|
5819
|
+
}
|
|
5820
|
+
for (const [index, action] of state.actions.entries()) {
|
|
5821
|
+
let row = this.actions.get(action.id);
|
|
5822
|
+
if (!row) {
|
|
5823
|
+
const activate = () => {
|
|
5824
|
+
const latest = this.actions.get(action.id);
|
|
5825
|
+
if (this.visible && this.expanded && !this.busy && latest && !latest.action.disabled) {
|
|
5826
|
+
this.onAction?.(latest.action.command ?? latest.action.id);
|
|
5827
|
+
}
|
|
5828
|
+
};
|
|
5829
|
+
const control = new TextRenderable8(this.renderer, {
|
|
5830
|
+
id: `omnius-telegram:action:${action.id}`,
|
|
5831
|
+
content: "",
|
|
5832
|
+
width: "100%",
|
|
5833
|
+
minWidth: 0,
|
|
5834
|
+
height: 1,
|
|
5835
|
+
flexShrink: 0,
|
|
5836
|
+
wrapMode: "none",
|
|
5837
|
+
truncate: true,
|
|
5838
|
+
selectable: false,
|
|
5839
|
+
fg: this.colors.foreground,
|
|
5840
|
+
bg: this.colors.background,
|
|
5841
|
+
onMouseDown: (event) => {
|
|
5842
|
+
if (event.button === 0) {
|
|
5843
|
+
if (control.focusable) control.focus();
|
|
5844
|
+
activate();
|
|
5845
|
+
event.preventDefault();
|
|
5846
|
+
event.stopPropagation();
|
|
5847
|
+
}
|
|
5848
|
+
},
|
|
5849
|
+
onKeyDown: (key) => {
|
|
5850
|
+
if (key.eventType !== "release" && (key.name === "return" || key.sequence === " ")) {
|
|
5851
|
+
activate();
|
|
5852
|
+
key.preventDefault();
|
|
5853
|
+
key.stopPropagation();
|
|
5854
|
+
}
|
|
5855
|
+
}
|
|
5856
|
+
});
|
|
5857
|
+
const style = () => {
|
|
5858
|
+
control.attributes = (control.focusable ? 0 : TextAttributes8.DIM) | (this.actions.get(action.id)?.action.active ? TextAttributes8.BOLD : 0) | (control.focused ? TextAttributes8.INVERSE : 0);
|
|
5859
|
+
};
|
|
5860
|
+
control.on(RenderableEvents6.FOCUSED, () => {
|
|
5861
|
+
style();
|
|
5862
|
+
this.reveal?.(control);
|
|
5863
|
+
});
|
|
5864
|
+
control.on(RenderableEvents6.BLURRED, style);
|
|
5865
|
+
row = { control, action };
|
|
5866
|
+
this.actions.set(action.id, row);
|
|
5867
|
+
this.body.add(control);
|
|
5868
|
+
}
|
|
5869
|
+
row.action = action;
|
|
5870
|
+
row.control.content = safe3(action.label);
|
|
5871
|
+
row.control.focusable = !this.busy && !action.disabled;
|
|
5872
|
+
row.control.attributes = (row.control.focusable ? 0 : TextAttributes8.DIM) | (action.active ? TextAttributes8.BOLD : 0) | (row.control.focused ? TextAttributes8.INVERSE : 0);
|
|
5873
|
+
if (this.body.getChildren()[index + 2] !== row.control) this.body.add(row.control, index + 2);
|
|
5874
|
+
if (!row.control.focusable && row.control.focused) this.header.focus();
|
|
5875
|
+
}
|
|
5876
|
+
}
|
|
5877
|
+
setExpanded(expanded) {
|
|
5878
|
+
if (!expanded && this.ownsFocus()) this.header.focus();
|
|
5879
|
+
this.expanded = expanded;
|
|
5880
|
+
this.header.update("TELEGRAM", expanded);
|
|
5881
|
+
this.body.visible = this.visible && expanded;
|
|
5882
|
+
}
|
|
5883
|
+
get isExpanded() {
|
|
5884
|
+
return this.expanded;
|
|
5885
|
+
}
|
|
5886
|
+
focusTargets() {
|
|
5887
|
+
return this.visible ? [this.header, ...this.expanded ? this.body.getChildren().filter((node) => node instanceof TextRenderable8 && node.focusable) : []] : [];
|
|
5888
|
+
}
|
|
5889
|
+
applyTheme(colors) {
|
|
5890
|
+
this.colors = colors;
|
|
5891
|
+
this.backgroundColor = colors.background;
|
|
5892
|
+
this.header.fg = colors.foreground;
|
|
5893
|
+
this.header.bg = colors.background;
|
|
5894
|
+
this.details.fg = colors.foreground;
|
|
5895
|
+
this.details.bg = colors.background;
|
|
5896
|
+
this.error.fg = colors.error;
|
|
5897
|
+
this.error.bg = colors.background;
|
|
5898
|
+
for (const row of this.actions.values()) {
|
|
5899
|
+
row.control.fg = colors.foreground;
|
|
5900
|
+
row.control.bg = colors.background;
|
|
5901
|
+
}
|
|
5902
|
+
}
|
|
5903
|
+
};
|
|
5748
5904
|
var InstrumentRail = class extends BoxRenderable9 {
|
|
5749
5905
|
workQueue;
|
|
5750
5906
|
workspaceFiles;
|
|
5751
5907
|
taskNotes;
|
|
5908
|
+
telegram;
|
|
5752
5909
|
scroll;
|
|
5753
5910
|
inferenceHeader;
|
|
5754
5911
|
sessionHeader;
|
|
@@ -5821,6 +5978,8 @@ var InstrumentRail = class extends BoxRenderable9 {
|
|
|
5821
5978
|
selection: background
|
|
5822
5979
|
}, (target) => this.reveal(target));
|
|
5823
5980
|
this.scroll.add(this.taskNotes);
|
|
5981
|
+
this.telegram = new NativeTelegramView(renderer2, colors, options.onAction, (target) => this.reveal(target));
|
|
5982
|
+
this.scroll.add(this.telegram);
|
|
5824
5983
|
this.inferenceHeader = new SectionBanner(
|
|
5825
5984
|
renderer2,
|
|
5826
5985
|
"INFERENCE",
|
|
@@ -5935,6 +6094,9 @@ var InstrumentRail = class extends BoxRenderable9 {
|
|
|
5935
6094
|
if (options.colors) this.applyTheme(options.colors);
|
|
5936
6095
|
}
|
|
5937
6096
|
update(state) {
|
|
6097
|
+
const telegramFocused = this.telegram.focusTargets().some((target) => target.focused);
|
|
6098
|
+
this.telegram.update(state.instruments?.telegram);
|
|
6099
|
+
if (telegramFocused && !this.telegram.visible) this.inferenceHeader.focus();
|
|
5938
6100
|
this.workQueue.update(state.workQueue);
|
|
5939
6101
|
this.workspaceFiles.update(state.workspaceFiles);
|
|
5940
6102
|
this.taskNotes.update(state.taskNotes);
|
|
@@ -6038,6 +6200,7 @@ var InstrumentRail = class extends BoxRenderable9 {
|
|
|
6038
6200
|
this.workQueue.applyTheme(colors);
|
|
6039
6201
|
this.workspaceFiles.applyTheme(colors);
|
|
6040
6202
|
this.taskNotes.applyTheme(colors);
|
|
6203
|
+
this.telegram.applyTheme(colors);
|
|
6041
6204
|
styleNativeScrollbars(this.scroll, colors);
|
|
6042
6205
|
styleNativeScrollbars(this.devices.scroll, colors);
|
|
6043
6206
|
}
|
|
@@ -6056,6 +6219,7 @@ var InstrumentRail = class extends BoxRenderable9 {
|
|
|
6056
6219
|
session: this.session.visible,
|
|
6057
6220
|
context: this.contextHeader.expanded,
|
|
6058
6221
|
devices: this.devices.isExpanded,
|
|
6222
|
+
telegram: this.telegram.isExpanded,
|
|
6059
6223
|
deviceSections: this.devices.captureDeviceSections(),
|
|
6060
6224
|
routeAttempts: this.routeAttemptsHeader.expanded,
|
|
6061
6225
|
scrollTop: this.scroll.scrollTop,
|
|
@@ -6069,6 +6233,7 @@ var InstrumentRail = class extends BoxRenderable9 {
|
|
|
6069
6233
|
this.workQueue.restorePresentation(state.workQueue);
|
|
6070
6234
|
this.workspaceFiles.restorePresentation(state.workspaceFiles);
|
|
6071
6235
|
this.taskNotes.restorePresentation(state.taskNotes);
|
|
6236
|
+
this.telegram.setExpanded(state.telegram === true);
|
|
6072
6237
|
if (this.inference.visible !== state.inference) this.toggleSection("inference");
|
|
6073
6238
|
if (this.session.visible !== state.session) this.toggleSection("session");
|
|
6074
6239
|
this.contextHeader.update("CONTEXT DETAILS", state.context);
|
|
@@ -6085,6 +6250,7 @@ var InstrumentRail = class extends BoxRenderable9 {
|
|
|
6085
6250
|
return [
|
|
6086
6251
|
...this.workQueue.focusTargets(),
|
|
6087
6252
|
...this.taskNotes.focusTargets(),
|
|
6253
|
+
...this.telegram.focusTargets(),
|
|
6088
6254
|
this.inferenceHeader,
|
|
6089
6255
|
...this.inference.visible && this.contextHeader.visible ? [this.contextHeader] : [],
|
|
6090
6256
|
...this.inference.visible && this.routeAttemptsHeader.visible ? [this.routeAttemptsHeader] : [],
|
|
@@ -305646,6 +305646,63 @@ function processIdentity2(pid) {
|
|
|
305646
305646
|
return;
|
|
305647
305647
|
}
|
|
305648
305648
|
}
|
|
305649
|
+
function interruptedGuardSnapshot(path3) {
|
|
305650
|
+
try {
|
|
305651
|
+
const before = lstatSync4(path3), owner = privateRecord(path3), metadata = lstatSync4(path3);
|
|
305652
|
+
if (!owner || before.dev !== metadata.dev || before.ino !== metadata.ino || !Number.isSafeInteger(owner.pid) || owner.pid <= 0 || typeof owner.nonce !== "string" || !/^[A-Za-z0-9_-]{1,128}$/.test(owner.nonce) || process.platform === "linux" && (typeof owner.process_identity !== "string" || !/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}:\d+$/i.test(owner.process_identity))) return null;
|
|
305653
|
+
return { owner, metadata };
|
|
305654
|
+
} catch {
|
|
305655
|
+
return null;
|
|
305656
|
+
}
|
|
305657
|
+
}
|
|
305658
|
+
function guardOwnerIsProvablyDead(owner) {
|
|
305659
|
+
if (!isPidAlive(owner.pid)) return true;
|
|
305660
|
+
if (process.platform !== "linux" || !owner.process_identity) return false;
|
|
305661
|
+
try {
|
|
305662
|
+
const boot = readFileSync8("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
305663
|
+
if (owner.process_identity.slice(0, owner.process_identity.lastIndexOf(":")) !== boot) return true;
|
|
305664
|
+
const identity = processIdentity2(owner.pid);
|
|
305665
|
+
if (identity) return identity !== owner.process_identity;
|
|
305666
|
+
const raw = readFileSync8(`/proc/${owner.pid}/stat`, "utf8");
|
|
305667
|
+
return /^[ZX](?:\s|$)/.test(raw.slice(raw.lastIndexOf(")") + 2));
|
|
305668
|
+
} catch {
|
|
305669
|
+
return false;
|
|
305670
|
+
}
|
|
305671
|
+
}
|
|
305672
|
+
function recoverInterruptedUpdateGuard(path3) {
|
|
305673
|
+
const initial = interruptedGuardSnapshot(path3);
|
|
305674
|
+
if (!initial || !guardOwnerIsProvablyDead(initial.owner)) return false;
|
|
305675
|
+
const recoveryPath = path3 + ".recovery", nonce = randomUUID4();
|
|
305676
|
+
let fd;
|
|
305677
|
+
try {
|
|
305678
|
+
fd = openSync4(recoveryPath, constants3.O_WRONLY | constants3.O_CREAT | constants3.O_EXCL | constants3.O_NOFOLLOW, 384);
|
|
305679
|
+
} catch (error) {
|
|
305680
|
+
if (error.code !== "EEXIST") throw error;
|
|
305681
|
+
const busy = new UpdateOwnershipBusyError(`Update guard recovery is active or was interrupted. Inspect the private ${recoveryPath} owner record before retrying.`);
|
|
305682
|
+
Object.assign(busy, { guardPath: recoveryPath });
|
|
305683
|
+
throw busy;
|
|
305684
|
+
}
|
|
305685
|
+
const claimed = fstatSync2(fd);
|
|
305686
|
+
let recorded = false;
|
|
305687
|
+
try {
|
|
305688
|
+
writeFileSync6(fd, JSON.stringify({ pid: process.pid, process_identity: processIdentity2(process.pid), nonce }));
|
|
305689
|
+
fsyncSync2(fd);
|
|
305690
|
+
recorded = true;
|
|
305691
|
+
const current = interruptedGuardSnapshot(path3);
|
|
305692
|
+
if (!current || current.metadata.dev !== initial.metadata.dev || current.metadata.ino !== initial.metadata.ino || current.owner.nonce !== initial.owner.nonce || current.owner.pid !== initial.owner.pid || current.owner.process_identity !== initial.owner.process_identity || !guardOwnerIsProvablyDead(current.owner)) return false;
|
|
305693
|
+
const final = lstatSync4(path3);
|
|
305694
|
+
if (final.dev !== current.metadata.dev || final.ino !== current.metadata.ino) return false;
|
|
305695
|
+
unlinkSync4(path3);
|
|
305696
|
+
return true;
|
|
305697
|
+
} finally {
|
|
305698
|
+
try {
|
|
305699
|
+
const current = lstatSync4(recoveryPath);
|
|
305700
|
+
if (current.dev === claimed.dev && current.ino === claimed.ino && (!recorded || privateRecord(recoveryPath)?.nonce === nonce)) unlinkSync4(recoveryPath);
|
|
305701
|
+
} catch {
|
|
305702
|
+
}
|
|
305703
|
+
closeSync4(fd);
|
|
305704
|
+
}
|
|
305705
|
+
}
|
|
305649
305706
|
function withUpdateOwnership(paths, mutation) {
|
|
305650
305707
|
ensurePrivateDirectories(paths);
|
|
305651
305708
|
const path3 = paths.lockFile + ".guard", nonce = randomUUID4();
|
|
@@ -305654,12 +305711,23 @@ function withUpdateOwnership(paths, mutation) {
|
|
|
305654
305711
|
fd = openSync4(path3, constants3.O_WRONLY | constants3.O_CREAT | constants3.O_EXCL | constants3.O_NOFOLLOW, 384);
|
|
305655
305712
|
} catch (error) {
|
|
305656
305713
|
if (error.code === "EEXIST") {
|
|
305657
|
-
|
|
305658
|
-
|
|
305659
|
-
|
|
305714
|
+
if (recoverInterruptedUpdateGuard(path3)) {
|
|
305715
|
+
try {
|
|
305716
|
+
fd = openSync4(path3, constants3.O_WRONLY | constants3.O_CREAT | constants3.O_EXCL | constants3.O_NOFOLLOW, 384);
|
|
305717
|
+
} catch (next) {
|
|
305718
|
+
if (next.code !== "EEXIST") throw next;
|
|
305719
|
+
}
|
|
305720
|
+
}
|
|
305721
|
+
if (fd === void 0) {
|
|
305722
|
+
const busy = new UpdateOwnershipBusyError(`Update ownership is busy or its guard was interrupted. Retry; if it persists, inspect the private ${path3} owner record before removing that guard.`);
|
|
305723
|
+
Object.assign(busy, { guardPath: path3 });
|
|
305724
|
+
throw busy;
|
|
305725
|
+
}
|
|
305726
|
+
} else {
|
|
305727
|
+
throw error;
|
|
305660
305728
|
}
|
|
305661
|
-
throw error;
|
|
305662
305729
|
}
|
|
305730
|
+
if (fd === void 0) throw new Error("Update ownership descriptor is unavailable");
|
|
305663
305731
|
let original;
|
|
305664
305732
|
try {
|
|
305665
305733
|
original = fstatSync2(fd);
|
package/dist/update-worker.js
CHANGED
|
@@ -161,6 +161,63 @@ function processIdentity(pid) {
|
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
+
function interruptedGuardSnapshot(path) {
|
|
165
|
+
try {
|
|
166
|
+
const before = lstatSync(path), owner = privateRecord(path), metadata = lstatSync(path);
|
|
167
|
+
if (!owner || before.dev !== metadata.dev || before.ino !== metadata.ino || !Number.isSafeInteger(owner.pid) || owner.pid <= 0 || typeof owner.nonce !== "string" || !/^[A-Za-z0-9_-]{1,128}$/.test(owner.nonce) || process.platform === "linux" && (typeof owner.process_identity !== "string" || !/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}:\d+$/i.test(owner.process_identity))) return null;
|
|
168
|
+
return { owner, metadata };
|
|
169
|
+
} catch {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function guardOwnerIsProvablyDead(owner) {
|
|
174
|
+
if (!isPidAlive(owner.pid)) return true;
|
|
175
|
+
if (process.platform !== "linux" || !owner.process_identity) return false;
|
|
176
|
+
try {
|
|
177
|
+
const boot = readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
178
|
+
if (owner.process_identity.slice(0, owner.process_identity.lastIndexOf(":")) !== boot) return true;
|
|
179
|
+
const identity = processIdentity(owner.pid);
|
|
180
|
+
if (identity) return identity !== owner.process_identity;
|
|
181
|
+
const raw = readFileSync(`/proc/${owner.pid}/stat`, "utf8");
|
|
182
|
+
return /^[ZX](?:\s|$)/.test(raw.slice(raw.lastIndexOf(")") + 2));
|
|
183
|
+
} catch {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function recoverInterruptedUpdateGuard(path) {
|
|
188
|
+
const initial = interruptedGuardSnapshot(path);
|
|
189
|
+
if (!initial || !guardOwnerIsProvablyDead(initial.owner)) return false;
|
|
190
|
+
const recoveryPath = path + ".recovery", nonce = randomUUID();
|
|
191
|
+
let fd;
|
|
192
|
+
try {
|
|
193
|
+
fd = openSync(recoveryPath, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 384);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
if (error.code !== "EEXIST") throw error;
|
|
196
|
+
const busy = new UpdateOwnershipBusyError(`Update guard recovery is active or was interrupted. Inspect the private ${recoveryPath} owner record before retrying.`);
|
|
197
|
+
Object.assign(busy, { guardPath: recoveryPath });
|
|
198
|
+
throw busy;
|
|
199
|
+
}
|
|
200
|
+
const claimed = fstatSync(fd);
|
|
201
|
+
let recorded = false;
|
|
202
|
+
try {
|
|
203
|
+
writeFileSync(fd, JSON.stringify({ pid: process.pid, process_identity: processIdentity(process.pid), nonce }));
|
|
204
|
+
fsyncSync(fd);
|
|
205
|
+
recorded = true;
|
|
206
|
+
const current = interruptedGuardSnapshot(path);
|
|
207
|
+
if (!current || current.metadata.dev !== initial.metadata.dev || current.metadata.ino !== initial.metadata.ino || current.owner.nonce !== initial.owner.nonce || current.owner.pid !== initial.owner.pid || current.owner.process_identity !== initial.owner.process_identity || !guardOwnerIsProvablyDead(current.owner)) return false;
|
|
208
|
+
const final = lstatSync(path);
|
|
209
|
+
if (final.dev !== current.metadata.dev || final.ino !== current.metadata.ino) return false;
|
|
210
|
+
unlinkSync(path);
|
|
211
|
+
return true;
|
|
212
|
+
} finally {
|
|
213
|
+
try {
|
|
214
|
+
const current = lstatSync(recoveryPath);
|
|
215
|
+
if (current.dev === claimed.dev && current.ino === claimed.ino && (!recorded || privateRecord(recoveryPath)?.nonce === nonce)) unlinkSync(recoveryPath);
|
|
216
|
+
} catch {
|
|
217
|
+
}
|
|
218
|
+
closeSync(fd);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
164
221
|
function withUpdateOwnership(paths, mutation) {
|
|
165
222
|
ensurePrivateDirectories(paths);
|
|
166
223
|
const path = paths.lockFile + ".guard", nonce = randomUUID();
|
|
@@ -169,12 +226,23 @@ function withUpdateOwnership(paths, mutation) {
|
|
|
169
226
|
fd = openSync(path, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 384);
|
|
170
227
|
} catch (error) {
|
|
171
228
|
if (error.code === "EEXIST") {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
229
|
+
if (recoverInterruptedUpdateGuard(path)) {
|
|
230
|
+
try {
|
|
231
|
+
fd = openSync(path, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 384);
|
|
232
|
+
} catch (next) {
|
|
233
|
+
if (next.code !== "EEXIST") throw next;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (fd === void 0) {
|
|
237
|
+
const busy = new UpdateOwnershipBusyError(`Update ownership is busy or its guard was interrupted. Retry; if it persists, inspect the private ${path} owner record before removing that guard.`);
|
|
238
|
+
Object.assign(busy, { guardPath: path });
|
|
239
|
+
throw busy;
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
throw error;
|
|
175
243
|
}
|
|
176
|
-
throw error;
|
|
177
244
|
}
|
|
245
|
+
if (fd === void 0) throw new Error("Update ownership descriptor is unavailable");
|
|
178
246
|
let original;
|
|
179
247
|
try {
|
|
180
248
|
original = fstatSync(fd);
|
|
@@ -401,7 +469,7 @@ function formatPublicUpdateWorkerFailure(error, env = process.env) {
|
|
|
401
469
|
if (prefix) line = line.replace(/^Error(?: \[[A-Z0-9_]+\])?:\s*/, "");
|
|
402
470
|
return (prefix + line.replace(/(?:https?|wss?|file):\/\/[^\s"'<>]+/gi, "[URL omitted]")).slice(0, 384);
|
|
403
471
|
}
|
|
404
|
-
async function runUpdateWorkerBootstrap(args = process.argv.slice(2)) {
|
|
472
|
+
async function runUpdateWorkerBootstrap(args = process.argv.slice(2), options = {}) {
|
|
405
473
|
let operationId, paths, adopted = false, enteredRuntime = false;
|
|
406
474
|
try {
|
|
407
475
|
const input = parseUpdateWorkerArguments(args);
|
|
@@ -418,7 +486,22 @@ async function runUpdateWorkerBootstrap(args = process.argv.slice(2)) {
|
|
|
418
486
|
return;
|
|
419
487
|
}
|
|
420
488
|
const runtimeUrl = new URL("./update-worker-runtime.js", import.meta.url).href;
|
|
421
|
-
const
|
|
489
|
+
const requestedTimeout = options.runtimeInitializationTimeoutMs;
|
|
490
|
+
const timeoutMs = typeof requestedTimeout === "number" && Number.isFinite(requestedTimeout) ? Math.max(1, Math.min(3e4, requestedTimeout)) : 3e4;
|
|
491
|
+
let initializationTimer;
|
|
492
|
+
let runtime;
|
|
493
|
+
try {
|
|
494
|
+
runtime = await Promise.race([
|
|
495
|
+
import(runtimeUrl),
|
|
496
|
+
new Promise((_resolve, reject) => {
|
|
497
|
+
initializationTimer = setTimeout(() => reject(new Error(
|
|
498
|
+
`Update worker runtime initialization timed out after ${timeoutMs}ms; no installer was started`
|
|
499
|
+
)), timeoutMs);
|
|
500
|
+
})
|
|
501
|
+
]);
|
|
502
|
+
} finally {
|
|
503
|
+
clearTimeout(initializationTimer);
|
|
504
|
+
}
|
|
422
505
|
if (typeof runtime.runUpdateWorkerRuntime !== "function")
|
|
423
506
|
throw new Error("Packaged update runtime export is missing");
|
|
424
507
|
enteredRuntime = true;
|
|
@@ -117,3 +117,29 @@ pnpm --filter @omnius/execution exec vitest run tests/skill-discovery.test.ts
|
|
|
117
117
|
Omnius stores project runtime state under `.omnius/`. This directory includes settings, jobs, context, sponsor state, scoped Telegram persona state, and generated connector artifacts.
|
|
118
118
|
|
|
119
119
|
Do not commit `.omnius/`. Omnius adds it to `.gitignore` automatically for repositories that have or later create a `.gitignore`.
|
|
120
|
+
|
|
121
|
+
## Recover A Blocked Automatic Update
|
|
122
|
+
|
|
123
|
+
If an older installation repeatedly opens **Waiting for the update worker**,
|
|
124
|
+
use another shell in the affected project to disable automatic installation:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
omnius config set updateMode manual
|
|
128
|
+
omnius config set updateMode manual --local
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Close and relaunch the TUI. Manual mode still reports available releases; it
|
|
132
|
+
installs only when requested. After installing a release with the recovery fix,
|
|
133
|
+
`/update auto` restores automatic updates.
|
|
134
|
+
|
|
135
|
+
On Linux, update recovery checks the worker's boot and process-start identity.
|
|
136
|
+
A valid ownership guard left by a dead process can be recovered after a crash
|
|
137
|
+
or reboot. A live, incomplete or replaced guard is retained and reported as an
|
|
138
|
+
error with a Close action instead of an indefinite queued dialog. Avoid deleting
|
|
139
|
+
the update state or locks while an installer may still be running.
|
|
140
|
+
|
|
141
|
+
Worker runtime initialization has a 30-second limit before an installer starts.
|
|
142
|
+
Package preparation and a running installation retain their own lifecycle; the
|
|
143
|
+
initialization limit does not interrupt them. The progress view distinguishes
|
|
144
|
+
dispatch, runtime initialization and package preparation. Its elapsed counter
|
|
145
|
+
measures time, not proof of worker activity.
|
package/docs/guides/telegram.md
CHANGED
|
@@ -12,6 +12,17 @@ The Telegram bridge is a scoped public ingress and egress layer. It supports adm
|
|
|
12
12
|
/telegram stop
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
The TUI's right details sidebar includes a **TELEGRAM** dropdown after a bot is
|
|
16
|
+
configured. It shows bridge state, polling, interaction mode and work slots,
|
|
17
|
+
with controls for managing the bot and opening its settings. Click the heading
|
|
18
|
+
or focus it with Tab and press Enter or Space to expand it. On narrow terminals,
|
|
19
|
+
open **DETAILS** first. The dropdown remains available while the bot is stopped
|
|
20
|
+
or polling is disabled.
|
|
21
|
+
|
|
22
|
+
Workspace-owned bots use the daemon's existing controls. Settings that require
|
|
23
|
+
a worker restart are labeled as applying on the next start. A bot owned by
|
|
24
|
+
another terminal remains under that terminal's control.
|
|
25
|
+
|
|
15
26
|
## Workspace Services
|
|
16
27
|
|
|
17
28
|
The Omnius daemon supervises Telegram agents for registered workspaces, so a terminal does not need to stay open. A workspace must have its own saved `telegramKey`; global bot tokens are never copied across projects. Existing Telegram enablement, endpoint, credentials, and GPU selections still apply.
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.934",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omnius",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.934",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED