text
stringlengths
0
1.47k
}
return
}
b := append([]byte(arg), 0)
_, _, e := syscall.Syscall6(syscall.SYS_REBOOT, syscall.LINUX_REBOOT_MAGIC1, syscall.LINUX_REBOOT_MAGIC2, restart2, uintptr(unsafe.Pointer(&b[0])), 0, 0)
if e != 0 {
fmt.Fprintln(os.Stderr, "reboot:", e)
os.Exit(1)
}
}
# ===== file: dashcast/browser.go =====
package main
import (
"context"
# ===== file: lib/client.js =====
window.__ModuleLoader__.load({
id: "@nagi-ovo/dsh-visualize",
factory: (require) => {
var module = { exports: {} };
var exports = module.exports;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
/**
* Narrow one persisted `tool/result` meta value to a {@link VisualizeMeta}.
* Wire data cannot be trusted to match the compiled shape (an older or newer
* host may have logged it), so a mismatch declines to `undefined` — the caller
* falls back to the generic presentation instead of throwing on replay.
* @param meta - the raw persisted meta value.
* @returns the narrowed descriptor, or `undefined` for the generic path.
*/
function visualizeMetaFrom(meta) {
if (typeof meta !== "object" || meta === null) return void 0;
const record = meta;
if (record["kind"] !== "visualize") return void 0;
const { fragment, title, mode, path } = record;
if (typeof fragment !== "string" || typeof title !== "string" || typeof path !== "string") return void 0;
if (mode !== "inline" && mode !== "wide") return void 0;
return {
kind: "visualize",
fragment,
title,
mode,
path
};
}
/**
* Rebuild a descriptor from the call's own arguments when persisted meta is
* missing. Nested dispatches (`run_code` / PTC) never project presentation
* meta, but they do log `arguments`; a create's fragment is in that JSON.
*
* An `update` without a fragment cannot be rebuilt from the wire (the patched
* markup lives in execute's value, which nested logs do not keep) and
* declines. Incomplete streaming JSON is not parsed via throw/catch: only a
* trailing `}` is treated as complete, otherwise a *closed* `"fragment"`
* string is taken through {@link extractStreamingFragment}'s scanner.
* @param argsRaw - running `block.argsRaw` or settled `block.call.argsRaw`.
* @returns a card descriptor, or `undefined` to keep the quiet fallback.
*/
function visualizeMetaFromArgs(argsRaw) {
if (typeof argsRaw !== "string" || argsRaw.length === 0) return void 0;
const complete = parseCompleteArgs(argsRaw);
if (complete !== void 0) {
if (complete["action"] === "update" && typeof complete["fragment"] !== "string") return void 0;
return descriptorFromFields(complete["fragment"], complete["title"], complete["mode"], complete["path"]);
}
const closed = scanFragment(argsRaw, true);
if (closed === void 0) return void 0;
return descriptorFromFields(closed, void 0, void 0, void 0);
}
/**
* Accept only a complete JSON object, gated on a trailing `}` so a streaming
* prefix never enters `JSON.parse`.
* @param raw - accumulated argument text.
* @returns the object, or `undefined` when the prefix is incomplete or illegal.
*/
function parseCompleteArgs(raw) {
let end = raw.length;
while (end > 0) {
const ch = raw[end - 1];
if (ch === " " || ch === "\n" || ch === "\r" || ch === " ") {
end -= 1;
continue;
}
break;
}
if (end === 0 || raw[end - 1] !== "}") return void 0;
try {
const parsed = JSON.parse(raw.slice(0, end));
if (typeof parsed !== "object" || parsed === null) return void 0;
return parsed;
} catch {
return;
}
}
/**
* Narrow wire fields into a descriptor. Empty markup after dropping a