@telepath-computer/television 0.1.27 → 0.1.28
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/browser/assets/{index-C0Ygc25s.js → index-BjBCLw1q.js} +4 -4
- package/dist/browser/index.html +1 -1
- package/dist/cli.cjs +206 -205
- package/dist/electron.cjs +208 -212
- package/package.json +12 -4
package/dist/cli.cjs
CHANGED
|
@@ -59900,7 +59900,7 @@ var require_websocket_server = __commonJS({
|
|
|
59900
59900
|
}
|
|
59901
59901
|
});
|
|
59902
59902
|
|
|
59903
|
-
//
|
|
59903
|
+
// packages/cli/src/index.ts
|
|
59904
59904
|
var index_exports = {};
|
|
59905
59905
|
__export(index_exports, {
|
|
59906
59906
|
resolveStaticDirFromEntrypoint: () => resolveStaticDirFromEntrypoint,
|
|
@@ -60093,29 +60093,7 @@ var Daemon = class {
|
|
|
60093
60093
|
}
|
|
60094
60094
|
};
|
|
60095
60095
|
|
|
60096
|
-
// src/
|
|
60097
|
-
var import_node_os2 = __toESM(require("node:os"), 1);
|
|
60098
|
-
var import_node_path2 = __toESM(require("node:path"), 1);
|
|
60099
|
-
var TRUE_ENV_VALUE = "true";
|
|
60100
|
-
var APP_HIDDEN_DIRECTORY = ".television";
|
|
60101
|
-
var TELEVISION_DATA_DIR_ENV = "TELEVISION_DATA_DIR";
|
|
60102
|
-
var DEFAULT_SERVER_HOST = "localhost";
|
|
60103
|
-
var DEFAULT_SERVER_PORT = 32848;
|
|
60104
|
-
var DEFAULT_SERVER_URL = buildServerURL(DEFAULT_SERVER_HOST, DEFAULT_SERVER_PORT);
|
|
60105
|
-
function buildServerURL(host, port) {
|
|
60106
|
-
return `http://${host}:${port}`;
|
|
60107
|
-
}
|
|
60108
|
-
function getTelevisionDataDir() {
|
|
60109
|
-
return process.env[TELEVISION_DATA_DIR_ENV] ?? import_node_path2.default.join(import_node_os2.default.homedir(), APP_HIDDEN_DIRECTORY);
|
|
60110
|
-
}
|
|
60111
|
-
function isVitestRuntime() {
|
|
60112
|
-
return process.env.VITEST === TRUE_ENV_VALUE;
|
|
60113
|
-
}
|
|
60114
|
-
function isDevMode() {
|
|
60115
|
-
return process.env.NODE_ENV !== "production";
|
|
60116
|
-
}
|
|
60117
|
-
|
|
60118
|
-
// src/server/client.ts
|
|
60096
|
+
// packages/server/src/client.ts
|
|
60119
60097
|
var TelevisionClient = class {
|
|
60120
60098
|
serverURL;
|
|
60121
60099
|
token;
|
|
@@ -60228,7 +60206,7 @@ var TelevisionClient = class {
|
|
|
60228
60206
|
}
|
|
60229
60207
|
};
|
|
60230
60208
|
|
|
60231
|
-
//
|
|
60209
|
+
// packages/server/src/server.ts
|
|
60232
60210
|
var import_express2 = __toESM(require_express2(), 1);
|
|
60233
60211
|
|
|
60234
60212
|
// node_modules/@telepath-computer/tool-router/dist/index.js
|
|
@@ -82514,7 +82492,7 @@ function createAPIRouter(options) {
|
|
|
82514
82492
|
return router;
|
|
82515
82493
|
}
|
|
82516
82494
|
|
|
82517
|
-
//
|
|
82495
|
+
// packages/server/src/server.ts
|
|
82518
82496
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
82519
82497
|
|
|
82520
82498
|
// node_modules/ws/wrapper.mjs
|
|
@@ -82527,15 +82505,15 @@ var import_subprotocol = __toESM(require_subprotocol(), 1);
|
|
|
82527
82505
|
var import_websocket = __toESM(require_websocket(), 1);
|
|
82528
82506
|
var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
82529
82507
|
|
|
82530
|
-
//
|
|
82508
|
+
// packages/server/src/acp-bridge.ts
|
|
82531
82509
|
var import_node_child_process2 = require("node:child_process");
|
|
82532
82510
|
var import_promises2 = require("node:fs/promises");
|
|
82533
|
-
var
|
|
82534
|
-
var
|
|
82511
|
+
var import_node_os2 = require("node:os");
|
|
82512
|
+
var import_node_path2 = __toESM(require("node:path"), 1);
|
|
82535
82513
|
var ACP_COMMAND = "openclaw";
|
|
82536
82514
|
var ACP_ARGS = ["acp"];
|
|
82537
82515
|
var ACP_STOP_TIMEOUT_MS = 5e3;
|
|
82538
|
-
var ACP_STUB_CWD =
|
|
82516
|
+
var ACP_STUB_CWD = import_node_path2.default.join((0, import_node_os2.homedir)(), ".television", "acp");
|
|
82539
82517
|
var ACPBridge = class {
|
|
82540
82518
|
child = null;
|
|
82541
82519
|
status = "exited";
|
|
@@ -82665,84 +82643,6 @@ var ACPBridge = class {
|
|
|
82665
82643
|
}
|
|
82666
82644
|
};
|
|
82667
82645
|
|
|
82668
|
-
// src/acp-bridge-types.ts
|
|
82669
|
-
function isACPBridgeClientMessage(value) {
|
|
82670
|
-
if (typeof value !== "object" || value === null || !("type" in value)) {
|
|
82671
|
-
return false;
|
|
82672
|
-
}
|
|
82673
|
-
const message = value;
|
|
82674
|
-
switch (message.type) {
|
|
82675
|
-
case "acp-bridge-connect":
|
|
82676
|
-
return true;
|
|
82677
|
-
case "acp-bridge-message":
|
|
82678
|
-
return "message" in message;
|
|
82679
|
-
default:
|
|
82680
|
-
return false;
|
|
82681
|
-
}
|
|
82682
|
-
}
|
|
82683
|
-
|
|
82684
|
-
// node_modules/@rupertsworld/event-target/dist/index.js
|
|
82685
|
-
var RESERVED_EVENT_KEYS = /* @__PURE__ */ new Set([
|
|
82686
|
-
"target",
|
|
82687
|
-
"currentTarget",
|
|
82688
|
-
"eventPhase",
|
|
82689
|
-
"defaultPrevented",
|
|
82690
|
-
"isTrusted",
|
|
82691
|
-
"timeStamp",
|
|
82692
|
-
"srcElement",
|
|
82693
|
-
"returnValue",
|
|
82694
|
-
"cancelBubble",
|
|
82695
|
-
"NONE",
|
|
82696
|
-
"CAPTURING_PHASE",
|
|
82697
|
-
"AT_TARGET",
|
|
82698
|
-
"BUBBLING_PHASE",
|
|
82699
|
-
"composedPath",
|
|
82700
|
-
"stopPropagation",
|
|
82701
|
-
"stopImmediatePropagation",
|
|
82702
|
-
"preventDefault",
|
|
82703
|
-
"initEvent"
|
|
82704
|
-
]);
|
|
82705
|
-
function assertNoReservedPayloadKeys(props) {
|
|
82706
|
-
for (const key of Object.keys(props)) {
|
|
82707
|
-
if (RESERVED_EVENT_KEYS.has(key)) {
|
|
82708
|
-
throw new Error(`Event payload key "${key}" is reserved; choose a different property name`);
|
|
82709
|
-
}
|
|
82710
|
-
}
|
|
82711
|
-
}
|
|
82712
|
-
function assignPayload(target, props) {
|
|
82713
|
-
assertNoReservedPayloadKeys(props);
|
|
82714
|
-
for (const key of Object.keys(props)) {
|
|
82715
|
-
Object.defineProperty(target, key, {
|
|
82716
|
-
value: props[key],
|
|
82717
|
-
writable: true,
|
|
82718
|
-
enumerable: true,
|
|
82719
|
-
configurable: true
|
|
82720
|
-
});
|
|
82721
|
-
}
|
|
82722
|
-
}
|
|
82723
|
-
function defineEvent() {
|
|
82724
|
-
class DefinedEvent extends Event {
|
|
82725
|
-
constructor(type, init) {
|
|
82726
|
-
const { type: initType, bubbles, cancelable, composed, ...payload } = init ?? {};
|
|
82727
|
-
if (initType !== void 0) {
|
|
82728
|
-
throw new Error(`Do not pass "type" in init; use the constructor argument instead`);
|
|
82729
|
-
}
|
|
82730
|
-
super(type, { bubbles, cancelable, composed });
|
|
82731
|
-
assignPayload(this, payload);
|
|
82732
|
-
}
|
|
82733
|
-
}
|
|
82734
|
-
return DefinedEvent;
|
|
82735
|
-
}
|
|
82736
|
-
var EventTarget = class extends globalThis.EventTarget {
|
|
82737
|
-
};
|
|
82738
|
-
|
|
82739
|
-
// src/events.ts
|
|
82740
|
-
var ChangeEvent = defineEvent();
|
|
82741
|
-
var ServerMessageEvent = defineEvent();
|
|
82742
|
-
var LayoutMutationEvent = defineEvent();
|
|
82743
|
-
var LayoutScrollEvent = defineEvent();
|
|
82744
|
-
var StoreChangeEvent = defineEvent();
|
|
82745
|
-
|
|
82746
82646
|
// node_modules/ulid/dist/node/index.js
|
|
82747
82647
|
var import_node_crypto = __toESM(require("node:crypto"), 1);
|
|
82748
82648
|
var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
@@ -82838,10 +82738,7 @@ function ulid3(seedTime, prng) {
|
|
|
82838
82738
|
return encodeTime(seed, TIME_LEN) + encodeRandom(RANDOM_LEN, currentPRNG);
|
|
82839
82739
|
}
|
|
82840
82740
|
|
|
82841
|
-
// src/
|
|
82842
|
-
var import_node_crypto2 = require("node:crypto");
|
|
82843
|
-
|
|
82844
|
-
// src/artifacts.ts
|
|
82741
|
+
// packages/shared/src/artifacts.ts
|
|
82845
82742
|
var ValidationError = class extends Error {
|
|
82846
82743
|
constructor(message) {
|
|
82847
82744
|
super(message);
|
|
@@ -82866,6 +82763,10 @@ var HTMLArtifactSchema = external_exports3.object({
|
|
|
82866
82763
|
token: external_exports3.string(),
|
|
82867
82764
|
source: FileArtifactSourceSchema
|
|
82868
82765
|
});
|
|
82766
|
+
var ARTIFACT_TYPES = ["markdown", "html"];
|
|
82767
|
+
function isArtifactType(value) {
|
|
82768
|
+
return ARTIFACT_TYPES.includes(value);
|
|
82769
|
+
}
|
|
82869
82770
|
var ArtifactSchema = external_exports3.discriminatedUnion("type", [
|
|
82870
82771
|
MarkdownArtifactSchema,
|
|
82871
82772
|
HTMLArtifactSchema
|
|
@@ -82906,11 +82807,7 @@ function wrapArtifactHTML(input) {
|
|
|
82906
82807
|
</html>`;
|
|
82907
82808
|
}
|
|
82908
82809
|
|
|
82909
|
-
// src/
|
|
82910
|
-
var import_node_fs2 = require("node:fs");
|
|
82911
|
-
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
82912
|
-
|
|
82913
|
-
// src/constants.ts
|
|
82810
|
+
// packages/layout/src/constants.ts
|
|
82914
82811
|
var LAYOUT_FULL_WIDTH_UNITS = 4;
|
|
82915
82812
|
var LAYOUT_FULL_HEIGHT_UNITS = 6;
|
|
82916
82813
|
var MIN_LAYOUT_CARD_WIDTH_UNITS = 2;
|
|
@@ -82922,44 +82819,7 @@ var CARD_GAP = 16;
|
|
|
82922
82819
|
var CARD_WIDTH = DEFAULT_LAYOUT_UNIT * LAYOUT_FULL_WIDTH_UNITS + CARD_GAP * (LAYOUT_FULL_WIDTH_UNITS - 1);
|
|
82923
82820
|
var CARD_HEIGHT = DEFAULT_LAYOUT_UNIT * LAYOUT_FULL_HEIGHT_UNITS + CARD_GAP * (LAYOUT_FULL_HEIGHT_UNITS - 1);
|
|
82924
82821
|
|
|
82925
|
-
// src/
|
|
82926
|
-
function createCardNode(artifactID, overrides = {}) {
|
|
82927
|
-
return {
|
|
82928
|
-
id: overrides.id ?? ulid3(),
|
|
82929
|
-
type: "card",
|
|
82930
|
-
artifactID,
|
|
82931
|
-
width: overrides.width ?? DEFAULT_LAYOUT_CARD_WIDTH,
|
|
82932
|
-
height: overrides.height ?? DEFAULT_LAYOUT_CARD_HEIGHT
|
|
82933
|
-
};
|
|
82934
|
-
}
|
|
82935
|
-
function layoutContainsArtifactID(layout, artifactID) {
|
|
82936
|
-
return layout.some((node) => nodeContainsArtifactID(node, artifactID));
|
|
82937
|
-
}
|
|
82938
|
-
function nodeContainsArtifactID(node, artifactID) {
|
|
82939
|
-
switch (node.type) {
|
|
82940
|
-
case "card":
|
|
82941
|
-
return node.artifactID === artifactID;
|
|
82942
|
-
case "row":
|
|
82943
|
-
return node.children.some((child) => child.artifactID === artifactID);
|
|
82944
|
-
case "stack":
|
|
82945
|
-
return node.children.some((child) => nodeContainsArtifactID(child, artifactID));
|
|
82946
|
-
}
|
|
82947
|
-
}
|
|
82948
|
-
function getWorkspaceArtifactIDs(workspace) {
|
|
82949
|
-
return workspace.layout.flatMap(collectArtifactIDs);
|
|
82950
|
-
}
|
|
82951
|
-
function collectArtifactIDs(node) {
|
|
82952
|
-
switch (node.type) {
|
|
82953
|
-
case "card":
|
|
82954
|
-
return [node.artifactID];
|
|
82955
|
-
case "row":
|
|
82956
|
-
return node.children.map((child) => child.artifactID);
|
|
82957
|
-
case "stack":
|
|
82958
|
-
return node.children.flatMap(collectArtifactIDs);
|
|
82959
|
-
}
|
|
82960
|
-
}
|
|
82961
|
-
|
|
82962
|
-
// src/layout/layout.ts
|
|
82822
|
+
// packages/layout/src/layout.ts
|
|
82963
82823
|
var LEGACY_BAND_HEIGHT_ROWS = 6;
|
|
82964
82824
|
var LEGACY_NARROW_COLS = 1;
|
|
82965
82825
|
var LEGACY_FULL_COLS = 2;
|
|
@@ -83230,7 +83090,125 @@ function cloneStackChild(node) {
|
|
|
83230
83090
|
};
|
|
83231
83091
|
}
|
|
83232
83092
|
|
|
83233
|
-
// src/
|
|
83093
|
+
// packages/shared/src/types.ts
|
|
83094
|
+
function createCardNode(artifactID, overrides = {}) {
|
|
83095
|
+
return {
|
|
83096
|
+
id: overrides.id ?? ulid3(),
|
|
83097
|
+
type: "card",
|
|
83098
|
+
artifactID,
|
|
83099
|
+
width: overrides.width ?? DEFAULT_LAYOUT_CARD_WIDTH,
|
|
83100
|
+
height: overrides.height ?? DEFAULT_LAYOUT_CARD_HEIGHT
|
|
83101
|
+
};
|
|
83102
|
+
}
|
|
83103
|
+
function layoutContainsArtifactID(layout, artifactID) {
|
|
83104
|
+
return layout.some((node) => nodeContainsArtifactID(node, artifactID));
|
|
83105
|
+
}
|
|
83106
|
+
function nodeContainsArtifactID(node, artifactID) {
|
|
83107
|
+
switch (node.type) {
|
|
83108
|
+
case "card":
|
|
83109
|
+
return node.artifactID === artifactID;
|
|
83110
|
+
case "row":
|
|
83111
|
+
return node.children.some((child) => child.artifactID === artifactID);
|
|
83112
|
+
case "stack":
|
|
83113
|
+
return node.children.some((child) => nodeContainsArtifactID(child, artifactID));
|
|
83114
|
+
}
|
|
83115
|
+
}
|
|
83116
|
+
function getWorkspaceArtifactIDs(workspace) {
|
|
83117
|
+
return workspace.layout.flatMap(collectArtifactIDs);
|
|
83118
|
+
}
|
|
83119
|
+
function collectArtifactIDs(node) {
|
|
83120
|
+
switch (node.type) {
|
|
83121
|
+
case "card":
|
|
83122
|
+
return [node.artifactID];
|
|
83123
|
+
case "row":
|
|
83124
|
+
return node.children.map((child) => child.artifactID);
|
|
83125
|
+
case "stack":
|
|
83126
|
+
return node.children.flatMap(collectArtifactIDs);
|
|
83127
|
+
}
|
|
83128
|
+
}
|
|
83129
|
+
|
|
83130
|
+
// node_modules/@rupertsworld/event-target/dist/index.js
|
|
83131
|
+
var RESERVED_EVENT_KEYS = /* @__PURE__ */ new Set([
|
|
83132
|
+
"target",
|
|
83133
|
+
"currentTarget",
|
|
83134
|
+
"eventPhase",
|
|
83135
|
+
"defaultPrevented",
|
|
83136
|
+
"isTrusted",
|
|
83137
|
+
"timeStamp",
|
|
83138
|
+
"srcElement",
|
|
83139
|
+
"returnValue",
|
|
83140
|
+
"cancelBubble",
|
|
83141
|
+
"NONE",
|
|
83142
|
+
"CAPTURING_PHASE",
|
|
83143
|
+
"AT_TARGET",
|
|
83144
|
+
"BUBBLING_PHASE",
|
|
83145
|
+
"composedPath",
|
|
83146
|
+
"stopPropagation",
|
|
83147
|
+
"stopImmediatePropagation",
|
|
83148
|
+
"preventDefault",
|
|
83149
|
+
"initEvent"
|
|
83150
|
+
]);
|
|
83151
|
+
function assertNoReservedPayloadKeys(props) {
|
|
83152
|
+
for (const key of Object.keys(props)) {
|
|
83153
|
+
if (RESERVED_EVENT_KEYS.has(key)) {
|
|
83154
|
+
throw new Error(`Event payload key "${key}" is reserved; choose a different property name`);
|
|
83155
|
+
}
|
|
83156
|
+
}
|
|
83157
|
+
}
|
|
83158
|
+
function assignPayload(target, props) {
|
|
83159
|
+
assertNoReservedPayloadKeys(props);
|
|
83160
|
+
for (const key of Object.keys(props)) {
|
|
83161
|
+
Object.defineProperty(target, key, {
|
|
83162
|
+
value: props[key],
|
|
83163
|
+
writable: true,
|
|
83164
|
+
enumerable: true,
|
|
83165
|
+
configurable: true
|
|
83166
|
+
});
|
|
83167
|
+
}
|
|
83168
|
+
}
|
|
83169
|
+
function defineEvent() {
|
|
83170
|
+
class DefinedEvent extends Event {
|
|
83171
|
+
constructor(type, init) {
|
|
83172
|
+
const { type: initType, bubbles, cancelable, composed, ...payload } = init ?? {};
|
|
83173
|
+
if (initType !== void 0) {
|
|
83174
|
+
throw new Error(`Do not pass "type" in init; use the constructor argument instead`);
|
|
83175
|
+
}
|
|
83176
|
+
super(type, { bubbles, cancelable, composed });
|
|
83177
|
+
assignPayload(this, payload);
|
|
83178
|
+
}
|
|
83179
|
+
}
|
|
83180
|
+
return DefinedEvent;
|
|
83181
|
+
}
|
|
83182
|
+
var EventTarget = class extends globalThis.EventTarget {
|
|
83183
|
+
};
|
|
83184
|
+
|
|
83185
|
+
// packages/shared/src/events.ts
|
|
83186
|
+
var ChangeEvent = defineEvent();
|
|
83187
|
+
var ServerMessageEvent = defineEvent();
|
|
83188
|
+
var LayoutMutationEvent = defineEvent();
|
|
83189
|
+
var LayoutScrollEvent = defineEvent();
|
|
83190
|
+
var StoreChangeEvent = defineEvent();
|
|
83191
|
+
|
|
83192
|
+
// packages/shared/src/acp-bridge-types.ts
|
|
83193
|
+
function isACPBridgeClientMessage(value) {
|
|
83194
|
+
if (typeof value !== "object" || value === null || !("type" in value)) {
|
|
83195
|
+
return false;
|
|
83196
|
+
}
|
|
83197
|
+
const message = value;
|
|
83198
|
+
switch (message.type) {
|
|
83199
|
+
case "acp-bridge-connect":
|
|
83200
|
+
return true;
|
|
83201
|
+
case "acp-bridge-message":
|
|
83202
|
+
return "message" in message;
|
|
83203
|
+
default:
|
|
83204
|
+
return false;
|
|
83205
|
+
}
|
|
83206
|
+
}
|
|
83207
|
+
|
|
83208
|
+
// packages/server/src/server-store.ts
|
|
83209
|
+
var import_node_crypto2 = require("node:crypto");
|
|
83210
|
+
var import_node_fs2 = require("node:fs");
|
|
83211
|
+
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
83234
83212
|
var JSON_INDENT_SPACES = 2;
|
|
83235
83213
|
var AUTH_TOKEN_BYTES = 32;
|
|
83236
83214
|
var DEFAULT_COLS = 2;
|
|
@@ -83478,7 +83456,7 @@ var ServerStore = class extends EventTarget {
|
|
|
83478
83456
|
}
|
|
83479
83457
|
load() {
|
|
83480
83458
|
for (const file2 of this.readEntityFiles(this.workspacesDir)) {
|
|
83481
|
-
const filePath =
|
|
83459
|
+
const filePath = import_node_path3.default.join(this.workspacesDir, file2);
|
|
83482
83460
|
const raw = this.readJsonFile(filePath);
|
|
83483
83461
|
if (!raw || typeof raw !== "object") continue;
|
|
83484
83462
|
const renamedLegacyFields = migrateWorkspaceJson(raw);
|
|
@@ -83492,7 +83470,7 @@ var ServerStore = class extends EventTarget {
|
|
|
83492
83470
|
}
|
|
83493
83471
|
}
|
|
83494
83472
|
for (const file2 of this.readEntityFiles(this.artifactsDir)) {
|
|
83495
|
-
const filePath =
|
|
83473
|
+
const filePath = import_node_path3.default.join(this.artifactsDir, file2);
|
|
83496
83474
|
const artifactData = this.readJsonFile(filePath);
|
|
83497
83475
|
if (!artifactData) continue;
|
|
83498
83476
|
const artifact = this.validateArtifactData(artifactData, file2, filePath);
|
|
@@ -83517,7 +83495,7 @@ var ServerStore = class extends EventTarget {
|
|
|
83517
83495
|
layout: []
|
|
83518
83496
|
};
|
|
83519
83497
|
this.workspaces.set(workspace.id, workspace);
|
|
83520
|
-
this.workspaceFilePaths.set(workspace.id,
|
|
83498
|
+
this.workspaceFilePaths.set(workspace.id, import_node_path3.default.join(this.workspacesDir, `${workspace.id}.json`));
|
|
83521
83499
|
this.persistWorkspace(workspace);
|
|
83522
83500
|
}
|
|
83523
83501
|
ensureDirectories() {
|
|
@@ -83552,40 +83530,40 @@ var ServerStore = class extends EventTarget {
|
|
|
83552
83530
|
}
|
|
83553
83531
|
persistWorkspace(workspace) {
|
|
83554
83532
|
(0, import_node_fs2.writeFileSync)(
|
|
83555
|
-
|
|
83533
|
+
import_node_path3.default.join(this.workspacesDir, `${workspace.id}.json`),
|
|
83556
83534
|
JSON.stringify(workspace, null, JSON_INDENT_SPACES)
|
|
83557
83535
|
);
|
|
83558
83536
|
}
|
|
83559
83537
|
persistArtifact(artifact) {
|
|
83560
83538
|
(0, import_node_fs2.writeFileSync)(
|
|
83561
|
-
|
|
83539
|
+
import_node_path3.default.join(this.artifactsDir, `${artifact.id}.json`),
|
|
83562
83540
|
JSON.stringify(artifact, null, JSON_INDENT_SPACES)
|
|
83563
83541
|
);
|
|
83564
83542
|
}
|
|
83565
83543
|
deleteArtifactFile(artifactID) {
|
|
83566
|
-
(0, import_node_fs2.rmSync)(
|
|
83544
|
+
(0, import_node_fs2.rmSync)(import_node_path3.default.join(this.artifactsDir, `${artifactID}.json`), { force: true });
|
|
83567
83545
|
}
|
|
83568
83546
|
deleteWorkspaceFile(workspaceID) {
|
|
83569
|
-
(0, import_node_fs2.rmSync)(
|
|
83547
|
+
(0, import_node_fs2.rmSync)(import_node_path3.default.join(this.workspacesDir, `${workspaceID}.json`), {
|
|
83570
83548
|
force: true
|
|
83571
83549
|
});
|
|
83572
83550
|
}
|
|
83573
83551
|
get workspacesDir() {
|
|
83574
|
-
return
|
|
83552
|
+
return import_node_path3.default.join(this.dataDir, "workspaces");
|
|
83575
83553
|
}
|
|
83576
83554
|
get artifactsDir() {
|
|
83577
|
-
return
|
|
83555
|
+
return import_node_path3.default.join(this.dataDir, "artifacts");
|
|
83578
83556
|
}
|
|
83579
83557
|
get tokenPath() {
|
|
83580
|
-
return
|
|
83558
|
+
return import_node_path3.default.join(this.dataDir, "token");
|
|
83581
83559
|
}
|
|
83582
83560
|
};
|
|
83583
83561
|
|
|
83584
|
-
// src/file-artifact-path.ts
|
|
83562
|
+
// packages/server/src/file-artifact-path.ts
|
|
83585
83563
|
var import_node_fs3 = require("node:fs");
|
|
83586
|
-
var
|
|
83564
|
+
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
83587
83565
|
function validateArtifactFilePath(type, inputPath) {
|
|
83588
|
-
const normalized =
|
|
83566
|
+
const normalized = import_node_path4.default.posix.normalize(inputPath);
|
|
83589
83567
|
if (!normalized.startsWith("/")) {
|
|
83590
83568
|
throw new Error(`Path must be absolute: ${inputPath}`);
|
|
83591
83569
|
}
|
|
@@ -83612,10 +83590,10 @@ function ensureArtifactFileExists(inputPath) {
|
|
|
83612
83590
|
}
|
|
83613
83591
|
}
|
|
83614
83592
|
function deriveArtifactTitleFromPath(inputPath) {
|
|
83615
|
-
return
|
|
83593
|
+
return import_node_path4.default.basename(inputPath);
|
|
83616
83594
|
}
|
|
83617
83595
|
function pathContainsTempComponent(inputPath) {
|
|
83618
|
-
const normalized =
|
|
83596
|
+
const normalized = import_node_path4.default.posix.normalize(inputPath).toLowerCase();
|
|
83619
83597
|
const segments = normalized.split("/").filter(Boolean);
|
|
83620
83598
|
return segments.includes("tmp") || segments.includes("temp");
|
|
83621
83599
|
}
|
|
@@ -83626,7 +83604,7 @@ function writeArtifactFileContent(inputPath, content) {
|
|
|
83626
83604
|
(0, import_node_fs3.writeFileSync)(inputPath, content, "utf8");
|
|
83627
83605
|
}
|
|
83628
83606
|
|
|
83629
|
-
//
|
|
83607
|
+
// packages/server/src/tools.ts
|
|
83630
83608
|
var import_node_fs4 = require("node:fs");
|
|
83631
83609
|
function listWorkspaceChoices(workspaces) {
|
|
83632
83610
|
return workspaces.map((workspace) => `${workspace.name} (${workspace.id})`).join(", ");
|
|
@@ -83812,18 +83790,18 @@ function createTools(store) {
|
|
|
83812
83790
|
];
|
|
83813
83791
|
}
|
|
83814
83792
|
|
|
83815
|
-
//
|
|
83793
|
+
// packages/server/src/artifact-renderer.ts
|
|
83816
83794
|
var import_node_fs5 = require("node:fs");
|
|
83817
|
-
var
|
|
83795
|
+
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
83818
83796
|
var cachedBundle = null;
|
|
83819
83797
|
function findRuntimeDir(staticDir) {
|
|
83820
83798
|
const candidates = [
|
|
83821
|
-
staticDir ?
|
|
83822
|
-
|
|
83823
|
-
|
|
83799
|
+
staticDir ? import_node_path5.default.resolve(staticDir, "..", "artifact-runtime") : null,
|
|
83800
|
+
import_node_path5.default.resolve(process.cwd(), "dist", "artifact-runtime"),
|
|
83801
|
+
import_node_path5.default.resolve(process.cwd(), "src", "artifact-runtime")
|
|
83824
83802
|
].filter((candidate) => typeof candidate === "string");
|
|
83825
83803
|
for (const candidate of candidates) {
|
|
83826
|
-
if ((0, import_node_fs5.existsSync)(
|
|
83804
|
+
if ((0, import_node_fs5.existsSync)(import_node_path5.default.join(candidate, "style.css")) && (0, import_node_fs5.existsSync)(import_node_path5.default.join(candidate, "index.js")) || (0, import_node_fs5.existsSync)(import_node_path5.default.join(candidate, "base.css")) && (0, import_node_fs5.existsSync)(import_node_path5.default.join(candidate, "runtime.js"))) {
|
|
83827
83805
|
return candidate;
|
|
83828
83806
|
}
|
|
83829
83807
|
}
|
|
@@ -83834,8 +83812,8 @@ function loadRuntimeFiles(staticDir) {
|
|
|
83834
83812
|
return cachedBundle;
|
|
83835
83813
|
}
|
|
83836
83814
|
const runtimeDir = findRuntimeDir(staticDir);
|
|
83837
|
-
const cssPath = (0, import_node_fs5.existsSync)(
|
|
83838
|
-
const jsPath = (0, import_node_fs5.existsSync)(
|
|
83815
|
+
const cssPath = (0, import_node_fs5.existsSync)(import_node_path5.default.join(runtimeDir, "style.css")) ? import_node_path5.default.join(runtimeDir, "style.css") : import_node_path5.default.join(runtimeDir, "base.css");
|
|
83816
|
+
const jsPath = (0, import_node_fs5.existsSync)(import_node_path5.default.join(runtimeDir, "index.js")) ? import_node_path5.default.join(runtimeDir, "index.js") : import_node_path5.default.join(runtimeDir, "runtime.js");
|
|
83839
83817
|
const bundle = {
|
|
83840
83818
|
css: (0, import_node_fs5.readFileSync)(cssPath, "utf8"),
|
|
83841
83819
|
js: (0, import_node_fs5.readFileSync)(jsPath, "utf8")
|
|
@@ -83884,14 +83862,14 @@ function parseEditableMarkdownClientMessage(data) {
|
|
|
83884
83862
|
// node_modules/watcher/dist/watcher.js
|
|
83885
83863
|
var import_node_events = require("node:events");
|
|
83886
83864
|
var import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
83887
|
-
var
|
|
83865
|
+
var import_node_path9 = __toESM(require("node:path"), 1);
|
|
83888
83866
|
|
|
83889
83867
|
// node_modules/watcher/dist/constants.js
|
|
83890
|
-
var
|
|
83868
|
+
var import_node_os3 = __toESM(require("node:os"), 1);
|
|
83891
83869
|
var DEBOUNCE = 300;
|
|
83892
83870
|
var DEPTH = 20;
|
|
83893
83871
|
var LIMIT = 1e7;
|
|
83894
|
-
var PLATFORM =
|
|
83872
|
+
var PLATFORM = import_node_os3.default.platform();
|
|
83895
83873
|
var IS_MAC = PLATFORM === "darwin";
|
|
83896
83874
|
var IS_WINDOWS = PLATFORM === "win32";
|
|
83897
83875
|
var HAS_NATIVE_RECURSION = IS_MAC || IS_WINDOWS;
|
|
@@ -84020,7 +83998,7 @@ var debounce_default = debounce;
|
|
|
84020
83998
|
|
|
84021
83999
|
// node_modules/watcher/dist/utils.js
|
|
84022
84000
|
var import_node_fs8 = __toESM(require("node:fs"), 1);
|
|
84023
|
-
var
|
|
84001
|
+
var import_node_path7 = __toESM(require("node:path"), 1);
|
|
84024
84002
|
|
|
84025
84003
|
// node_modules/stubborn-fs/dist/index.js
|
|
84026
84004
|
var import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
@@ -84226,7 +84204,7 @@ var dist_default = FS;
|
|
|
84226
84204
|
|
|
84227
84205
|
// node_modules/tiny-readdir/dist/index.js
|
|
84228
84206
|
var import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
84229
|
-
var
|
|
84207
|
+
var import_node_path6 = __toESM(require("node:path"), 1);
|
|
84230
84208
|
|
|
84231
84209
|
// node_modules/promise-make-naked/dist/utils.js
|
|
84232
84210
|
var noop = () => {
|
|
@@ -84388,7 +84366,7 @@ var readdir = (rootPath, options) => {
|
|
|
84388
84366
|
const handleDirent = (dirmap, rootPath2, dirent, depth) => {
|
|
84389
84367
|
if (signal.aborted)
|
|
84390
84368
|
return;
|
|
84391
|
-
const separator = rootPath2 ===
|
|
84369
|
+
const separator = rootPath2 === import_node_path6.default.sep ? "" : import_node_path6.default.sep;
|
|
84392
84370
|
const name = dirent.name;
|
|
84393
84371
|
const subPath = `${rootPath2}${separator}${name}`;
|
|
84394
84372
|
if (isIgnored(subPath))
|
|
@@ -84441,7 +84419,7 @@ var readdir = (rootPath, options) => {
|
|
|
84441
84419
|
return decrement();
|
|
84442
84420
|
if (signal.aborted)
|
|
84443
84421
|
return decrement();
|
|
84444
|
-
const name =
|
|
84422
|
+
const name = import_node_path6.default.basename(realPath);
|
|
84445
84423
|
const dirmap = map2[rootPath2] = { directories: [], directoriesNames: /* @__PURE__ */ new Set(), directoriesNamesToPaths: {}, files: [], filesNames: /* @__PURE__ */ new Set(), filesNamesToPaths: {}, symlinks: [], symlinksNames: /* @__PURE__ */ new Set(), symlinksNamesToPaths: {} };
|
|
84446
84424
|
handleStat(dirmap, realPath, name, stat, depth);
|
|
84447
84425
|
decrement();
|
|
@@ -84449,7 +84427,7 @@ var readdir = (rootPath, options) => {
|
|
|
84449
84427
|
});
|
|
84450
84428
|
};
|
|
84451
84429
|
const populateResultFromRoot = async (rootPath2, depth = 1) => {
|
|
84452
|
-
rootPath2 =
|
|
84430
|
+
rootPath2 = import_node_path6.default.normalize(rootPath2);
|
|
84453
84431
|
visited.add(rootPath2);
|
|
84454
84432
|
populateResultFromPath(rootPath2, depth);
|
|
84455
84433
|
await promise2;
|
|
@@ -84543,7 +84521,7 @@ var Utils = {
|
|
|
84543
84521
|
/* FS API */
|
|
84544
84522
|
fs: {
|
|
84545
84523
|
getDepth: (targetPath) => {
|
|
84546
|
-
return Math.max(0, targetPath.split(
|
|
84524
|
+
return Math.max(0, targetPath.split(import_node_path7.default.sep).length - 1);
|
|
84547
84525
|
},
|
|
84548
84526
|
getRealPath: (targetPath, native) => {
|
|
84549
84527
|
try {
|
|
@@ -84553,7 +84531,7 @@ var Utils = {
|
|
|
84553
84531
|
}
|
|
84554
84532
|
},
|
|
84555
84533
|
isSubPath: (targetPath, subPath) => {
|
|
84556
|
-
return subPath.startsWith(targetPath) && subPath[targetPath.length] ===
|
|
84534
|
+
return subPath.startsWith(targetPath) && subPath[targetPath.length] === import_node_path7.default.sep && subPath.length - targetPath.length > import_node_path7.default.sep.length;
|
|
84557
84535
|
},
|
|
84558
84536
|
poll: (targetPath, timeout = POLLING_TIMEOUT) => {
|
|
84559
84537
|
return dist_default.retry.stat(timeout)(targetPath, { bigint: true }).catch(Utils.lang.noop);
|
|
@@ -84572,7 +84550,7 @@ var Utils = {
|
|
|
84572
84550
|
var utils_default = Utils;
|
|
84573
84551
|
|
|
84574
84552
|
// node_modules/watcher/dist/watcher_handler.js
|
|
84575
|
-
var
|
|
84553
|
+
var import_node_path8 = __toESM(require("node:path"), 1);
|
|
84576
84554
|
var WatcherHandler = class {
|
|
84577
84555
|
/* CONSTRUCTOR */
|
|
84578
84556
|
constructor(watcher, config2, base) {
|
|
@@ -84708,7 +84686,7 @@ var WatcherHandler = class {
|
|
|
84708
84686
|
}
|
|
84709
84687
|
}
|
|
84710
84688
|
onTargetUnlink(targetPath) {
|
|
84711
|
-
this.watcher.watchersClose(
|
|
84689
|
+
this.watcher.watchersClose(import_node_path8.default.dirname(targetPath), targetPath, false);
|
|
84712
84690
|
if (this._isSubRoot(targetPath)) {
|
|
84713
84691
|
if (this.options.renameDetection) {
|
|
84714
84692
|
this.watcher._locker.getLockTargetUnlink(targetPath, this.options.renameTimeout);
|
|
@@ -84718,7 +84696,7 @@ var WatcherHandler = class {
|
|
|
84718
84696
|
}
|
|
84719
84697
|
}
|
|
84720
84698
|
onTargetUnlinkDir(targetPath) {
|
|
84721
|
-
this.watcher.watchersClose(
|
|
84699
|
+
this.watcher.watchersClose(import_node_path8.default.dirname(targetPath), targetPath, false);
|
|
84722
84700
|
this.watcher.watchersClose(targetPath);
|
|
84723
84701
|
if (this._isSubRoot(targetPath)) {
|
|
84724
84702
|
if (this.options.renameDetection) {
|
|
@@ -84753,7 +84731,7 @@ var WatcherHandler = class {
|
|
|
84753
84731
|
onWatcherChange(event = FSTargetEvent.CHANGE, targetName) {
|
|
84754
84732
|
if (this.watcher.isClosed())
|
|
84755
84733
|
return;
|
|
84756
|
-
const targetPath =
|
|
84734
|
+
const targetPath = import_node_path8.default.resolve(this.folderPath, targetName || "");
|
|
84757
84735
|
if (this.filePath && targetPath !== this.folderPath && targetPath !== this.filePath)
|
|
84758
84736
|
return;
|
|
84759
84737
|
if (this.watcher.isIgnored(targetPath, this.options.ignore))
|
|
@@ -85325,14 +85303,14 @@ var Watcher = class _Watcher extends import_node_events.EventEmitter {
|
|
|
85325
85303
|
const configsSibling = this._watchers[folderPath];
|
|
85326
85304
|
if (!!configsSibling?.find((config2) => config2.handler === handler && (!config2.filePath || config2.filePath === filePath) && config2.options.ignore === options.ignore && !!config2.options.native === !!options.native && (!options.recursive || config2.options.recursive)))
|
|
85327
85305
|
return true;
|
|
85328
|
-
let folderAncestorPath =
|
|
85306
|
+
let folderAncestorPath = import_node_path9.default.dirname(folderPath);
|
|
85329
85307
|
for (let depth = 1; depth < Infinity; depth++) {
|
|
85330
85308
|
const configsAncestor = this._watchers[folderAncestorPath];
|
|
85331
85309
|
if (!!configsAncestor?.find((config2) => (depth === 1 || config2.options.recursive && depth <= (config2.options.depth ?? DEPTH)) && config2.handler === handler && (!config2.filePath || config2.filePath === filePath) && config2.options.ignore === options.ignore && !!config2.options.native === !!options.native && (!options.recursive || config2.options.recursive && (HAS_NATIVE_RECURSION && config2.options.native !== false))))
|
|
85332
85310
|
return true;
|
|
85333
85311
|
if (!HAS_NATIVE_RECURSION)
|
|
85334
85312
|
break;
|
|
85335
|
-
const folderAncestorPathNext =
|
|
85313
|
+
const folderAncestorPathNext = import_node_path9.default.dirname(folderPath);
|
|
85336
85314
|
if (folderAncestorPath === folderAncestorPathNext)
|
|
85337
85315
|
break;
|
|
85338
85316
|
folderAncestorPath = folderAncestorPathNext;
|
|
@@ -85357,7 +85335,7 @@ var Watcher = class _Watcher extends import_node_events.EventEmitter {
|
|
|
85357
85335
|
const isRoot = this._roots.has(filePath || folderPath);
|
|
85358
85336
|
if (isRoot) {
|
|
85359
85337
|
const parentOptions = { ...options, ignoreInitial: true, recursive: false };
|
|
85360
|
-
const parentFolderPath =
|
|
85338
|
+
const parentFolderPath = import_node_path9.default.dirname(folderPath);
|
|
85361
85339
|
const parentFilePath = folderPath;
|
|
85362
85340
|
await this.watchDirectories([parentFolderPath], parentOptions, handler, parentFilePath, watcherHandler);
|
|
85363
85341
|
}
|
|
@@ -85427,7 +85405,7 @@ var Watcher = class _Watcher extends import_node_events.EventEmitter {
|
|
|
85427
85405
|
if (this.isIgnored(filePath, options.ignore))
|
|
85428
85406
|
return;
|
|
85429
85407
|
options = { ...options, recursive: false };
|
|
85430
|
-
const folderPath =
|
|
85408
|
+
const folderPath = import_node_path9.default.dirname(filePath);
|
|
85431
85409
|
return this.watchDirectory(folderPath, options, handler, filePath);
|
|
85432
85410
|
}
|
|
85433
85411
|
async watchPollingOnce(targetPath, options, callback) {
|
|
@@ -85498,12 +85476,12 @@ var Watcher = class _Watcher extends import_node_events.EventEmitter {
|
|
|
85498
85476
|
async watchPath(targetPath, options, handler) {
|
|
85499
85477
|
if (this.isClosed())
|
|
85500
85478
|
return;
|
|
85501
|
-
targetPath =
|
|
85479
|
+
targetPath = import_node_path9.default.resolve(targetPath);
|
|
85502
85480
|
if (this.isIgnored(targetPath, options.ignore))
|
|
85503
85481
|
return;
|
|
85504
85482
|
const stats = await utils_default.fs.poll(targetPath, options.pollingTimeout);
|
|
85505
85483
|
if (!stats) {
|
|
85506
|
-
const parentPath =
|
|
85484
|
+
const parentPath = import_node_path9.default.dirname(targetPath);
|
|
85507
85485
|
const parentStats = await utils_default.fs.poll(parentPath, options.pollingTimeout);
|
|
85508
85486
|
if (parentStats?.isDirectory()) {
|
|
85509
85487
|
return this.watchUnknownChild(targetPath, options, handler);
|
|
@@ -85691,7 +85669,7 @@ function editableMarkdownSocketServer(options) {
|
|
|
85691
85669
|
return new EditableMarkdownSocketServer(options);
|
|
85692
85670
|
}
|
|
85693
85671
|
|
|
85694
|
-
//
|
|
85672
|
+
// packages/server/src/server.ts
|
|
85695
85673
|
var import_node_fs10 = require("node:fs");
|
|
85696
85674
|
var AUTH_FAILED_CLOSE_CODE = 4401;
|
|
85697
85675
|
var HTTP_UNAUTHORIZED_STATUS = 401;
|
|
@@ -86109,7 +86087,29 @@ function isLayoutNode(value) {
|
|
|
86109
86087
|
}
|
|
86110
86088
|
}
|
|
86111
86089
|
|
|
86112
|
-
// src/
|
|
86090
|
+
// packages/server/src/config.ts
|
|
86091
|
+
var import_node_os4 = __toESM(require("node:os"), 1);
|
|
86092
|
+
var import_node_path10 = __toESM(require("node:path"), 1);
|
|
86093
|
+
var TRUE_ENV_VALUE = "true";
|
|
86094
|
+
var APP_HIDDEN_DIRECTORY = ".television";
|
|
86095
|
+
var TELEVISION_DATA_DIR_ENV = "TELEVISION_DATA_DIR";
|
|
86096
|
+
var DEFAULT_SERVER_HOST = "localhost";
|
|
86097
|
+
var DEFAULT_SERVER_PORT = 32848;
|
|
86098
|
+
var DEFAULT_SERVER_URL = buildServerURL(DEFAULT_SERVER_HOST, DEFAULT_SERVER_PORT);
|
|
86099
|
+
function buildServerURL(host, port) {
|
|
86100
|
+
return `http://${host}:${port}`;
|
|
86101
|
+
}
|
|
86102
|
+
function getTelevisionDataDir() {
|
|
86103
|
+
return process.env[TELEVISION_DATA_DIR_ENV] ?? import_node_path10.default.join(import_node_os4.default.homedir(), APP_HIDDEN_DIRECTORY);
|
|
86104
|
+
}
|
|
86105
|
+
function isVitestRuntime() {
|
|
86106
|
+
return process.env.VITEST === TRUE_ENV_VALUE;
|
|
86107
|
+
}
|
|
86108
|
+
function isDevMode() {
|
|
86109
|
+
return process.env.NODE_ENV !== "production";
|
|
86110
|
+
}
|
|
86111
|
+
|
|
86112
|
+
// packages/cli/src/index.ts
|
|
86113
86113
|
var DAEMON_NAME = "com.television.server";
|
|
86114
86114
|
var MAX_PORT = 65535;
|
|
86115
86115
|
function writeJSON(output, value) {
|
|
@@ -86136,6 +86136,7 @@ function resolveStaticDirFromEntrypoint(entrypoint) {
|
|
|
86136
86136
|
const resolvedEntrypoint = (0, import_node_fs11.realpathSync)(entrypoint);
|
|
86137
86137
|
const entryDir = import_node_path11.default.dirname(resolvedEntrypoint);
|
|
86138
86138
|
const candidates = [
|
|
86139
|
+
import_node_path11.default.resolve(entryDir, "../../../dist/browser"),
|
|
86139
86140
|
import_node_path11.default.resolve(entryDir, "../../dist/browser"),
|
|
86140
86141
|
import_node_path11.default.resolve(entryDir, "browser")
|
|
86141
86142
|
];
|
|
@@ -86239,9 +86240,9 @@ function createProgram(env) {
|
|
|
86239
86240
|
});
|
|
86240
86241
|
});
|
|
86241
86242
|
});
|
|
86242
|
-
program2.command("create-artifact").description("Create an artifact in a workspace").requiredOption("--path <path>", "Artifact file path").option("--type <type>",
|
|
86243
|
-
if (opts.type
|
|
86244
|
-
throw new Error(
|
|
86243
|
+
program2.command("create-artifact").description("Create an artifact in a workspace").requiredOption("--path <path>", "Artifact file path").option("--type <type>", `Artifact type (${ARTIFACT_TYPES.join(" or ")})`, "markdown").option("--workspace <id>", "Target workspace ID").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).action(async (opts) => {
|
|
86244
|
+
if (!isArtifactType(opts.type)) {
|
|
86245
|
+
throw new Error(`--type must be one of: ${ARTIFACT_TYPES.join(", ")}`);
|
|
86245
86246
|
}
|
|
86246
86247
|
ensureArtifactFileExists(opts.path);
|
|
86247
86248
|
const normalizedPath = validateArtifactFilePath(opts.type, opts.path);
|