oasis_test 0.1.89 → 0.1.90
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 +176 -123
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6001,6 +6001,13 @@ var init_dispatcher = __esm({
|
|
|
6001
6001
|
* 是否相对本会话推进过**(上游产新版才动 pin,天然排除驳回/人类改单)。运行时态、不进 oplog/重放,
|
|
6002
6002
|
* 与 inFlight 同生同灭。 */
|
|
6003
6003
|
inFlightPins = /* @__PURE__ */ new Map();
|
|
6004
|
+
/**
|
|
6005
|
+
* 本次会话的凭据清理器,与 inFlight 同生同灭。
|
|
6006
|
+
* **必须在「只有槽位主人才能解锁」那个守卫里调**(见 handleSessionExit)——
|
|
6007
|
+
* 无差别调用 = 拿僵尸会话的死讯删掉**活会话正在用的** creds 文件,
|
|
6008
|
+
* 那比不清理更糟:活着的 agent 下一次 `gh` 就炸,且现场看起来像凭据凭空消失。
|
|
6009
|
+
*/
|
|
6010
|
+
inFlightCleanup = /* @__PURE__ */ new Map();
|
|
6004
6011
|
/** ADR-0094:本会话已确认不支持原生 append(codex/subprocess 远端报 unsupported,或会话在收尾)——
|
|
6005
6012
|
* 停投,回落"等会话退出 + fresh 重派"。与 inFlight 同生同灭。 */
|
|
6006
6013
|
appendSkip = /* @__PURE__ */ new Set();
|
|
@@ -6934,6 +6941,8 @@ var init_dispatcher = __esm({
|
|
|
6934
6941
|
...Object.keys(jobEnv).length > 0 ? { env: jobEnv } : {},
|
|
6935
6942
|
...provisioned?.wrapperPaths && provisioned.wrapperPaths.length > 0 ? { wrapperPaths: provisioned.wrapperPaths } : {},
|
|
6936
6943
|
...provisioned?.requiredTools && provisioned.requiredTools.length > 0 ? { requiredTools: provisioned.requiredTools } : {},
|
|
6944
|
+
// 凭据本体随 job 下发,供**节点侧本机注入**(见上方 provision 注释)。
|
|
6945
|
+
...provisioned?.connectorCreds && provisioned.connectorCreds.length > 0 ? { connectorCreds: provisioned.connectorCreds } : {},
|
|
6937
6946
|
// ADR-0078 D1/D3:把本次派发的 id 交给 adapter 当 handle.id——于是
|
|
6938
6947
|
// `handle.id` = `agent_runs.id` = token 的 dispatchId claim,三处同值。
|
|
6939
6948
|
dispatchId: attempt
|
|
@@ -6965,6 +6974,7 @@ var init_dispatcher = __esm({
|
|
|
6965
6974
|
}
|
|
6966
6975
|
this.inFlight.set(jobKey, session);
|
|
6967
6976
|
this.inFlightActor.set(jobKey, dispatchSpec.actor);
|
|
6977
|
+
if (provisioned?.cleanup) this.inFlightCleanup.set(jobKey, provisioned.cleanup);
|
|
6968
6978
|
const dispatchedAtMs = Date.now();
|
|
6969
6979
|
this.inFlightStartedAt.set(jobKey, dispatchedAtMs);
|
|
6970
6980
|
const seqAtDispatch = seqNow;
|
|
@@ -7059,6 +7069,12 @@ var init_dispatcher = __esm({
|
|
|
7059
7069
|
this.inFlightStartedAt.delete(jobKey);
|
|
7060
7070
|
this.inFlightPins.delete(jobKey);
|
|
7061
7071
|
this.appendSkip.delete(jobKey);
|
|
7072
|
+
const cleanup = this.inFlightCleanup.get(jobKey);
|
|
7073
|
+
if (cleanup) {
|
|
7074
|
+
this.inFlightCleanup.delete(jobKey);
|
|
7075
|
+
void cleanup().catch(() => {
|
|
7076
|
+
});
|
|
7077
|
+
}
|
|
7062
7078
|
}
|
|
7063
7079
|
const seqAtExit = kernel.model.lastSeq.get(spec.artifactId) ?? 0;
|
|
7064
7080
|
const exitSessionKey = this.produceSessionKeyFor(spec);
|
|
@@ -142160,14 +142176,48 @@ async function prepareConnectorsForJob(job, deps) {
|
|
|
142160
142176
|
}
|
|
142161
142177
|
const keptLocal = localWrappers.filter((p2) => isStagedWrapperUsable(p2));
|
|
142162
142178
|
const keptRemote = remoteWrappers.filter((p2) => (0, import_node_fs5.existsSync)(p2));
|
|
142163
|
-
const
|
|
142164
|
-
if (
|
|
142179
|
+
const droppedWrappers = remoteWrappers.length - keptRemote.length + (localWrappers.length - keptLocal.length);
|
|
142180
|
+
if (droppedWrappers > 0) log("[node-connectors]", `\u4E22\u5F03 ${droppedWrappers} \u6761\u672C\u673A\u4E0D\u53EF\u7528\u7684 wrapper \u8DEF\u5F84`);
|
|
142181
|
+
const staleKeys = /* @__PURE__ */ new Set();
|
|
142182
|
+
const isolationKeys = /* @__PURE__ */ new Set();
|
|
142183
|
+
for (const connector of createAllConnectors()) {
|
|
142184
|
+
if (injected.has(connector.config.slug)) continue;
|
|
142185
|
+
const isolation = new Set(connector.hostCredentialIsolationEnvKeys ?? []);
|
|
142186
|
+
for (const key of connector.injectedEnvKeys) {
|
|
142187
|
+
if (isolation.has(key)) isolationKeys.add(key);
|
|
142188
|
+
else staleKeys.add(key);
|
|
142189
|
+
}
|
|
142190
|
+
}
|
|
142165
142191
|
const basePath = job.env?.["PATH"] ?? process.env["PATH"] ?? "";
|
|
142166
142192
|
const toolsBin = connectorToolsBinDir();
|
|
142167
142193
|
const pathWithTools = basePath.split(":").includes(toolsBin) ? basePath : [toolsBin, basePath].filter(Boolean).join(":");
|
|
142194
|
+
const jobEnv = { ...job.env ?? {}, ...envOverrides, PATH: pathWithTools };
|
|
142195
|
+
let dropped = 0;
|
|
142196
|
+
for (const key of staleKeys) {
|
|
142197
|
+
if (jobEnv[key] === void 0) continue;
|
|
142198
|
+
delete jobEnv[key];
|
|
142199
|
+
dropped++;
|
|
142200
|
+
}
|
|
142201
|
+
if (isolationKeys.size > 0) {
|
|
142202
|
+
const isolationRoot = await (0, import_promises6.mkdtemp)((0, import_node_path9.join)((0, import_node_os5.tmpdir)(), "oasis-node-isolate-"));
|
|
142203
|
+
for (const key of isolationKeys) {
|
|
142204
|
+
const dir = (0, import_node_path9.join)(isolationRoot, key.toLowerCase());
|
|
142205
|
+
await (0, import_promises6.mkdir)(dir, { recursive: true, mode: 448 });
|
|
142206
|
+
jobEnv[key] = dir;
|
|
142207
|
+
}
|
|
142208
|
+
cleanups.push(async () => {
|
|
142209
|
+
await (0, import_promises6.rm)(isolationRoot, { recursive: true, force: true });
|
|
142210
|
+
});
|
|
142211
|
+
}
|
|
142212
|
+
if (dropped > 0) {
|
|
142213
|
+
log(
|
|
142214
|
+
"[node-connectors]",
|
|
142215
|
+
`\u26A0 \u6E05\u6389 ${dropped} \u4E2A\u6307\u5411\u522B\u7684\u673A\u5668\u7684\u8FDE\u63A5\u5668 env \u952E\uFF08server \u53D1\u4E86\u6307\u9488\u4F46\u6CA1\u53D1\u51ED\u636E\uFF09\u2014\u2014\u672C\u8F6E\u8FD9\u4E9B\u8FDE\u63A5\u5668**\u4E0D\u53EF\u7528**\uFF0Cagent \u5E94\u636E\u6B64\u5224\u5B9A\u300C\u6CA1\u6709\u8BE5\u80FD\u529B\u300D\uFF0C\u800C\u4E0D\u662F\u4EE5\u4E3A\u914D\u597D\u4E86\u3002`
|
|
142216
|
+
);
|
|
142217
|
+
}
|
|
142168
142218
|
const preparedJob = {
|
|
142169
142219
|
...job,
|
|
142170
|
-
env:
|
|
142220
|
+
env: jobEnv,
|
|
142171
142221
|
wrapperPaths: [...keptLocal, ...keptRemote]
|
|
142172
142222
|
};
|
|
142173
142223
|
if (injected.size > 0 && (job.limits?.wallClockMs ?? 0) > SESSION_CREDENTIAL_RENEW_INTERVAL_MS) {
|
|
@@ -142225,11 +142275,14 @@ function fetchCredentialsFromServer(job) {
|
|
|
142225
142275
|
return body.connectorCreds ?? [];
|
|
142226
142276
|
};
|
|
142227
142277
|
}
|
|
142228
|
-
var import_node_fs5, SESSION_CREDENTIAL_RENEW_INTERVAL_MS;
|
|
142278
|
+
var import_node_fs5, import_promises6, import_node_os5, import_node_path9, SESSION_CREDENTIAL_RENEW_INTERVAL_MS;
|
|
142229
142279
|
var init_prepare_job = __esm({
|
|
142230
142280
|
"../connectors/src/prepare-job.ts"() {
|
|
142231
142281
|
"use strict";
|
|
142232
142282
|
import_node_fs5 = require("node:fs");
|
|
142283
|
+
import_promises6 = require("node:fs/promises");
|
|
142284
|
+
import_node_os5 = require("node:os");
|
|
142285
|
+
import_node_path9 = require("node:path");
|
|
142233
142286
|
init_base();
|
|
142234
142287
|
init_registry2();
|
|
142235
142288
|
init_logger();
|
|
@@ -142572,8 +142625,8 @@ function materializeFiles(dir, files) {
|
|
|
142572
142625
|
if (!files) return;
|
|
142573
142626
|
for (const [rel, content] of Object.entries(files)) {
|
|
142574
142627
|
try {
|
|
142575
|
-
const file =
|
|
142576
|
-
import_node_fs6.default.mkdirSync(
|
|
142628
|
+
const file = import_node_path10.default.join(dir, rel);
|
|
142629
|
+
import_node_fs6.default.mkdirSync(import_node_path10.default.dirname(file), { recursive: true });
|
|
142577
142630
|
import_node_fs6.default.writeFileSync(file, content);
|
|
142578
142631
|
} catch {
|
|
142579
142632
|
}
|
|
@@ -142589,7 +142642,7 @@ function resolveLegacyWorkRoot(workRoot) {
|
|
|
142589
142642
|
if (workRoot) return workRoot;
|
|
142590
142643
|
const env = process.env["OASIS_WORK_ROOT"];
|
|
142591
142644
|
if (env) return env;
|
|
142592
|
-
return
|
|
142645
|
+
return import_node_os6.default.tmpdir();
|
|
142593
142646
|
}
|
|
142594
142647
|
function resolveWorkRoots(workRoot) {
|
|
142595
142648
|
return { workRoot: resolveWorkRoot(workRoot), legacyRoot: resolveLegacyWorkRoot(workRoot) };
|
|
@@ -142600,7 +142653,7 @@ function slug5(workdirKey) {
|
|
|
142600
142653
|
return `${safe}-${h}`;
|
|
142601
142654
|
}
|
|
142602
142655
|
function sessionDirFor(workRoot, runtimeKind, workdirKey) {
|
|
142603
|
-
return
|
|
142656
|
+
return import_node_path10.default.join(resolveWorkRoot(workRoot), "sessions", runtimeKind, slug5(workdirKey));
|
|
142604
142657
|
}
|
|
142605
142658
|
function sessionDirKind(runtimeKind) {
|
|
142606
142659
|
return runtimeKind === "claude-code" ? "claude" : runtimeKind;
|
|
@@ -142613,20 +142666,20 @@ function resolveSessionDirWithLegacy(args) {
|
|
|
142613
142666
|
return import_node_fs6.default.existsSync(legacy) ? legacy : fresh;
|
|
142614
142667
|
}
|
|
142615
142668
|
function oneShotDirFor(workRoot, runtimeKind) {
|
|
142616
|
-
const base =
|
|
142669
|
+
const base = import_node_path10.default.join(resolveWorkRoot(workRoot), "tmp");
|
|
142617
142670
|
import_node_fs6.default.mkdirSync(base, { recursive: true });
|
|
142618
|
-
return import_node_fs6.default.mkdtempSync(
|
|
142671
|
+
return import_node_fs6.default.mkdtempSync(import_node_path10.default.join(base, `${runtimeKind}-`));
|
|
142619
142672
|
}
|
|
142620
142673
|
function writeMeta(dir, meta) {
|
|
142621
142674
|
try {
|
|
142622
|
-
import_node_fs6.default.writeFileSync(
|
|
142675
|
+
import_node_fs6.default.writeFileSync(import_node_path10.default.join(dir, META_FILE), `${JSON.stringify(meta, null, 2)}
|
|
142623
142676
|
`);
|
|
142624
142677
|
} catch {
|
|
142625
142678
|
}
|
|
142626
142679
|
}
|
|
142627
142680
|
function readMeta(dir) {
|
|
142628
142681
|
try {
|
|
142629
|
-
const raw = JSON.parse(import_node_fs6.default.readFileSync(
|
|
142682
|
+
const raw = JSON.parse(import_node_fs6.default.readFileSync(import_node_path10.default.join(dir, META_FILE), "utf8"));
|
|
142630
142683
|
if (!raw || typeof raw !== "object") return null;
|
|
142631
142684
|
const m2 = raw;
|
|
142632
142685
|
return typeof m2.kind === "string" && typeof m2.createdAt === "string" ? m2 : null;
|
|
@@ -142655,14 +142708,14 @@ function lockWorkdir(dir, pid, holder, workdirKey) {
|
|
|
142655
142708
|
...workdirKey !== void 0 ? { workdirKey } : {}
|
|
142656
142709
|
};
|
|
142657
142710
|
try {
|
|
142658
|
-
import_node_fs6.default.writeFileSync(
|
|
142711
|
+
import_node_fs6.default.writeFileSync(import_node_path10.default.join(dir, LOCK_FILE), `${JSON.stringify(lock)}
|
|
142659
142712
|
`);
|
|
142660
142713
|
} catch {
|
|
142661
142714
|
}
|
|
142662
142715
|
}
|
|
142663
142716
|
function readLock(dir) {
|
|
142664
142717
|
try {
|
|
142665
|
-
const raw = JSON.parse(import_node_fs6.default.readFileSync(
|
|
142718
|
+
const raw = JSON.parse(import_node_fs6.default.readFileSync(import_node_path10.default.join(dir, LOCK_FILE), "utf8"));
|
|
142666
142719
|
if (!raw || typeof raw !== "object") return null;
|
|
142667
142720
|
const l = raw;
|
|
142668
142721
|
return Number.isInteger(l.pid) && l.pid > 0 ? l : null;
|
|
@@ -142672,14 +142725,14 @@ function readLock(dir) {
|
|
|
142672
142725
|
}
|
|
142673
142726
|
function unlockWorkdir(dir) {
|
|
142674
142727
|
try {
|
|
142675
|
-
import_node_fs6.default.unlinkSync(
|
|
142728
|
+
import_node_fs6.default.unlinkSync(import_node_path10.default.join(dir, LOCK_FILE));
|
|
142676
142729
|
} catch {
|
|
142677
142730
|
}
|
|
142678
142731
|
}
|
|
142679
142732
|
function isWorkdirLive(dir) {
|
|
142680
142733
|
let raw;
|
|
142681
142734
|
try {
|
|
142682
|
-
raw = import_node_fs6.default.readFileSync(
|
|
142735
|
+
raw = import_node_fs6.default.readFileSync(import_node_path10.default.join(dir, LOCK_FILE), "utf8");
|
|
142683
142736
|
} catch {
|
|
142684
142737
|
return false;
|
|
142685
142738
|
}
|
|
@@ -142696,7 +142749,7 @@ function clearWorkdir(dir) {
|
|
|
142696
142749
|
);
|
|
142697
142750
|
}
|
|
142698
142751
|
for (const entry of import_node_fs6.default.readdirSync(dir)) {
|
|
142699
|
-
import_node_fs6.default.rmSync(
|
|
142752
|
+
import_node_fs6.default.rmSync(import_node_path10.default.join(dir, entry), { recursive: true, force: true });
|
|
142700
142753
|
}
|
|
142701
142754
|
}
|
|
142702
142755
|
function prepareWorkdir(args) {
|
|
@@ -142726,19 +142779,19 @@ function prepareWorkdir(args) {
|
|
|
142726
142779
|
return dir;
|
|
142727
142780
|
}
|
|
142728
142781
|
function legacyChatSessionDir(workRoot, rtId) {
|
|
142729
|
-
return
|
|
142782
|
+
return import_node_path10.default.join(resolveLegacyWorkRoot(workRoot), "oasis-chat-sessions", rtId.replace(/[^a-zA-Z0-9_-]+/g, "_"));
|
|
142730
142783
|
}
|
|
142731
|
-
var import_node_crypto9, import_node_fs6,
|
|
142784
|
+
var import_node_crypto9, import_node_fs6, import_node_os6, import_node_path10, META_FILE, LOCK_FILE, NEW_WORK_ROOT, LEGACY_ROOTS, LEGACY_ONESHOT_PREFIX;
|
|
142732
142785
|
var init_session_paths = __esm({
|
|
142733
142786
|
"../adapters/src/_core/session-paths.ts"() {
|
|
142734
142787
|
"use strict";
|
|
142735
142788
|
import_node_crypto9 = require("node:crypto");
|
|
142736
142789
|
import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
142737
|
-
|
|
142738
|
-
|
|
142790
|
+
import_node_os6 = __toESM(require("node:os"), 1);
|
|
142791
|
+
import_node_path10 = __toESM(require("node:path"), 1);
|
|
142739
142792
|
META_FILE = ".oasis-meta.json";
|
|
142740
142793
|
LOCK_FILE = ".oasis-lock";
|
|
142741
|
-
NEW_WORK_ROOT = () =>
|
|
142794
|
+
NEW_WORK_ROOT = () => import_node_path10.default.join(import_node_os6.default.homedir(), ".oasis", "work");
|
|
142742
142795
|
LEGACY_ROOTS = ["oasis-chat-sessions", "oasis-transcripts"];
|
|
142743
142796
|
LEGACY_ONESHOT_PREFIX = "oasis-session-";
|
|
142744
142797
|
}
|
|
@@ -143960,7 +144013,7 @@ async function discoverACPModels(bin, provider, args = ["acp"]) {
|
|
|
143960
144013
|
clientCapabilities: {}
|
|
143961
144014
|
});
|
|
143962
144015
|
try {
|
|
143963
|
-
tmpDir = (0, import_node_fs7.mkdtempSync)((0,
|
|
144016
|
+
tmpDir = (0, import_node_fs7.mkdtempSync)((0, import_node_path11.join)((0, import_node_os7.tmpdir)(), `oasis-acp-${provider}-`));
|
|
143964
144017
|
} catch {
|
|
143965
144018
|
return fail();
|
|
143966
144019
|
}
|
|
@@ -144016,14 +144069,14 @@ function parseACPSessionNewModels(result) {
|
|
|
144016
144069
|
async function discoverOpenclawModels(bin) {
|
|
144017
144070
|
throw new Error("discoverOpenclawModels: TODO");
|
|
144018
144071
|
}
|
|
144019
|
-
var import_node_child_process9, import_node_fs7,
|
|
144072
|
+
var import_node_child_process9, import_node_fs7, import_node_os7, import_node_path11, modelCache, CACHE_TTL_MS;
|
|
144020
144073
|
var init_models = __esm({
|
|
144021
144074
|
"../adapters/src/_core/models.ts"() {
|
|
144022
144075
|
"use strict";
|
|
144023
144076
|
import_node_child_process9 = require("node:child_process");
|
|
144024
144077
|
import_node_fs7 = require("node:fs");
|
|
144025
|
-
|
|
144026
|
-
|
|
144078
|
+
import_node_os7 = require("node:os");
|
|
144079
|
+
import_node_path11 = require("node:path");
|
|
144027
144080
|
modelCache = /* @__PURE__ */ new Map();
|
|
144028
144081
|
CACHE_TTL_MS = 6e4;
|
|
144029
144082
|
}
|
|
@@ -146590,7 +146643,7 @@ function dirSizeBytes(dir) {
|
|
|
146590
146643
|
return;
|
|
146591
146644
|
}
|
|
146592
146645
|
for (const e of entries) {
|
|
146593
|
-
const p2 =
|
|
146646
|
+
const p2 = import_node_path12.default.join(d, e.name);
|
|
146594
146647
|
if (e.isSymbolicLink()) continue;
|
|
146595
146648
|
if (e.isDirectory()) {
|
|
146596
146649
|
walk(p2);
|
|
@@ -146607,40 +146660,40 @@ function dirSizeBytes(dir) {
|
|
|
146607
146660
|
}
|
|
146608
146661
|
function listWorkdirs(workRoot, legacyRoot) {
|
|
146609
146662
|
const out = [];
|
|
146610
|
-
const sessions =
|
|
146663
|
+
const sessions = import_node_path12.default.join(workRoot, "sessions");
|
|
146611
146664
|
try {
|
|
146612
146665
|
for (const kind of import_node_fs8.default.readdirSync(sessions)) {
|
|
146613
|
-
const kindDir =
|
|
146666
|
+
const kindDir = import_node_path12.default.join(sessions, kind);
|
|
146614
146667
|
try {
|
|
146615
|
-
for (const slug6 of import_node_fs8.default.readdirSync(kindDir)) out.push(
|
|
146668
|
+
for (const slug6 of import_node_fs8.default.readdirSync(kindDir)) out.push(import_node_path12.default.join(kindDir, slug6));
|
|
146616
146669
|
} catch {
|
|
146617
146670
|
}
|
|
146618
146671
|
}
|
|
146619
146672
|
} catch {
|
|
146620
146673
|
}
|
|
146621
|
-
const tmp =
|
|
146674
|
+
const tmp = import_node_path12.default.join(workRoot, "tmp");
|
|
146622
146675
|
try {
|
|
146623
|
-
for (const d of import_node_fs8.default.readdirSync(tmp)) out.push(
|
|
146676
|
+
for (const d of import_node_fs8.default.readdirSync(tmp)) out.push(import_node_path12.default.join(tmp, d));
|
|
146624
146677
|
} catch {
|
|
146625
146678
|
}
|
|
146626
146679
|
for (const legacy of LEGACY_ROOTS) {
|
|
146627
|
-
const root =
|
|
146680
|
+
const root = import_node_path12.default.join(legacyRoot, legacy);
|
|
146628
146681
|
try {
|
|
146629
|
-
for (const d of import_node_fs8.default.readdirSync(root)) out.push(
|
|
146682
|
+
for (const d of import_node_fs8.default.readdirSync(root)) out.push(import_node_path12.default.join(root, d));
|
|
146630
146683
|
} catch {
|
|
146631
146684
|
}
|
|
146632
146685
|
}
|
|
146633
146686
|
try {
|
|
146634
146687
|
for (const d of import_node_fs8.default.readdirSync(legacyRoot)) {
|
|
146635
|
-
if (d.startsWith(LEGACY_ONESHOT_PREFIX)) out.push(
|
|
146688
|
+
if (d.startsWith(LEGACY_ONESHOT_PREFIX)) out.push(import_node_path12.default.join(legacyRoot, d));
|
|
146636
146689
|
}
|
|
146637
146690
|
} catch {
|
|
146638
146691
|
}
|
|
146639
146692
|
return [...new Set(out)];
|
|
146640
146693
|
}
|
|
146641
146694
|
function kindFromPath(workRoot, dir) {
|
|
146642
|
-
const rel =
|
|
146643
|
-
const parts = rel.split(
|
|
146695
|
+
const rel = import_node_path12.default.relative(workRoot, dir);
|
|
146696
|
+
const parts = rel.split(import_node_path12.default.sep);
|
|
146644
146697
|
if (parts[0] === "sessions" && parts[1]) return parts[1];
|
|
146645
146698
|
if (parts[0] === "tmp" && parts[1]) return parts[1].replace(/-[^-]*$/, "");
|
|
146646
146699
|
return void 0;
|
|
@@ -146682,7 +146735,7 @@ async function runGcSweep(deps) {
|
|
|
146682
146735
|
let deleted = 0;
|
|
146683
146736
|
for (const d of decisions) {
|
|
146684
146737
|
if (d.action !== "delete") continue;
|
|
146685
|
-
if (import_node_fs8.default.existsSync(
|
|
146738
|
+
if (import_node_fs8.default.existsSync(import_node_path12.default.join(d.dir, LOCK_FILE)) && isWorkdirLive(d.dir)) {
|
|
146686
146739
|
log3(`[gc] \u8DF3\u8FC7 ${d.dir}\uFF1A\u6267\u884C\u524D\u590D\u67E5\u53D1\u73B0\u5DF2\u88AB\u5360\u7528`);
|
|
146687
146740
|
continue;
|
|
146688
146741
|
}
|
|
@@ -146733,12 +146786,12 @@ function startGcLoop(deps) {
|
|
|
146733
146786
|
clearInterval(timer);
|
|
146734
146787
|
};
|
|
146735
146788
|
}
|
|
146736
|
-
var import_node_fs8,
|
|
146789
|
+
var import_node_fs8, import_node_path12;
|
|
146737
146790
|
var init_gc_loop = __esm({
|
|
146738
146791
|
"../adapters/src/_core/gc-loop.ts"() {
|
|
146739
146792
|
"use strict";
|
|
146740
146793
|
import_node_fs8 = __toESM(require("node:fs"), 1);
|
|
146741
|
-
|
|
146794
|
+
import_node_path12 = __toESM(require("node:path"), 1);
|
|
146742
146795
|
init_session_paths();
|
|
146743
146796
|
init_workdir_gc();
|
|
146744
146797
|
}
|
|
@@ -146774,14 +146827,14 @@ var init_src4 = __esm({
|
|
|
146774
146827
|
});
|
|
146775
146828
|
|
|
146776
146829
|
// ../connectors/src/connector-adapter.ts
|
|
146777
|
-
var
|
|
146830
|
+
var import_promises7, import_node_fs9, import_node_os8, import_node_path13, ConnectorAwareAdapter;
|
|
146778
146831
|
var init_connector_adapter = __esm({
|
|
146779
146832
|
"../connectors/src/connector-adapter.ts"() {
|
|
146780
146833
|
"use strict";
|
|
146781
|
-
|
|
146834
|
+
import_promises7 = require("node:fs/promises");
|
|
146782
146835
|
import_node_fs9 = require("node:fs");
|
|
146783
|
-
|
|
146784
|
-
|
|
146836
|
+
import_node_os8 = require("node:os");
|
|
146837
|
+
import_node_path13 = require("node:path");
|
|
146785
146838
|
init_src4();
|
|
146786
146839
|
init_base();
|
|
146787
146840
|
init_prepare_job();
|
|
@@ -146804,11 +146857,11 @@ var init_connector_adapter = __esm({
|
|
|
146804
146857
|
const wrapperPaths = [...prepared.job.wrapperPaths ?? [], ...sentinelWrappers];
|
|
146805
146858
|
let extraEnv = { ...strippedEnv };
|
|
146806
146859
|
if (wrapperPaths.length > 0) {
|
|
146807
|
-
const wrapperBinDir = await (0,
|
|
146808
|
-
await (0,
|
|
146860
|
+
const wrapperBinDir = await (0, import_promises7.mkdtemp)((0, import_node_path13.join)((0, import_node_os8.tmpdir)(), "oasis-wrappers-"));
|
|
146861
|
+
await (0, import_promises7.mkdir)(wrapperBinDir, { recursive: true });
|
|
146809
146862
|
for (const wp of wrapperPaths) {
|
|
146810
|
-
const linkName = (0,
|
|
146811
|
-
await (0,
|
|
146863
|
+
const linkName = (0, import_node_path13.basename)(wp).replace(/\.sh$/, "");
|
|
146864
|
+
await (0, import_promises7.symlink)(wp, (0, import_node_path13.join)(wrapperBinDir, linkName));
|
|
146812
146865
|
}
|
|
146813
146866
|
extraEnv = { ...extraEnv, PATH: [wrapperBinDir, extraEnv["PATH"] ?? ""].filter(Boolean).join(":") };
|
|
146814
146867
|
log("[adapter]", ` connectors injected +${Date.now() - t0}ms wrappers=${wrapperPaths.length}`);
|
|
@@ -149595,12 +149648,12 @@ async function startOasisServer(opts) {
|
|
|
149595
149648
|
const actorCtx = await opts.resolveActorContext(body.actorId).catch(() => null);
|
|
149596
149649
|
if (actorCtx) {
|
|
149597
149650
|
const { mkdtempSync: mkdtempSync5, mkdirSync: mkdirSync21, writeFileSync: writeFileSync13 } = await import("node:fs");
|
|
149598
|
-
const { join:
|
|
149599
|
-
const { tmpdir:
|
|
149600
|
-
const dir = mkdtempSync5(
|
|
149651
|
+
const { join: join32, dirname: dirname24 } = await import("node:path");
|
|
149652
|
+
const { tmpdir: tmpdir10 } = await import("node:os");
|
|
149653
|
+
const dir = mkdtempSync5(join32(tmpdir10(), "oasis-chat-"));
|
|
149601
149654
|
if (actorCtx.config?.prompt) {
|
|
149602
149655
|
for (const [rel, content] of Object.entries(splitIdentityFiles2(actorCtx.config.prompt))) {
|
|
149603
|
-
const file =
|
|
149656
|
+
const file = join32(dir, rel);
|
|
149604
149657
|
mkdirSync21(dirname24(file), { recursive: true });
|
|
149605
149658
|
writeFileSync13(file, content);
|
|
149606
149659
|
}
|
|
@@ -149612,12 +149665,12 @@ async function startOasisServer(opts) {
|
|
|
149612
149665
|
const s2 = byId.get(id);
|
|
149613
149666
|
return s2 ? `- **${s2.name}** (\`${s2.id}\`): ${s2.description}` : `- \`${id}\`\uFF08\u672A\u5728\u6280\u80FD\u5E93\u4E2D\uFF0C\u53EF\u80FD\u5DF2\u5378\u8F7D\uFF09`;
|
|
149614
149667
|
});
|
|
149615
|
-
writeFileSync13(
|
|
149668
|
+
writeFileSync13(join32(dir, "SKILLS.md"), ["# \u53EF\u7528\u6280\u80FD", "", "\u4EE5\u4E0B\u6280\u80FD\u5DF2\u4E3A\u4F60\u542F\u7528\uFF0C\u53EF\u5728\u672C\u6B21\u4F1A\u8BDD\u4E2D\u76F4\u63A5\u4F7F\u7528\uFF1A", "", ...lines].join("\n"));
|
|
149616
149669
|
}
|
|
149617
149670
|
if (opts.materializeSkills) {
|
|
149618
149671
|
const skillFiles = await opts.materializeSkills(body.actorId, "claude").catch(() => ({}));
|
|
149619
149672
|
for (const [rel, content] of Object.entries(skillFiles)) {
|
|
149620
|
-
const file =
|
|
149673
|
+
const file = join32(dir, rel);
|
|
149621
149674
|
mkdirSync21(dirname24(file), { recursive: true });
|
|
149622
149675
|
writeFileSync13(file, content);
|
|
149623
149676
|
}
|
|
@@ -149631,7 +149684,7 @@ async function startOasisServer(opts) {
|
|
|
149631
149684
|
const modeNote = c.mode === "oauth" ? "OAuth \xB7 \u51ED\u8BC1\u7531\u5E73\u53F0\u7BA1\u7406\uFF0C\u901A\u8FC7\u5BF9\u5E94 CLI wrapper \u8C03\u7528" : "\u76F4\u63A5\u5199\u5165 \xB7 \u51ED\u8BC1\u5DF2\u6CE8\u5165\u73AF\u5883\u53D8\u91CF";
|
|
149632
149685
|
return `- **${c.name}** (\`${c.id}\`): ${statusNote} \xB7 ${modeNote}`;
|
|
149633
149686
|
});
|
|
149634
|
-
writeFileSync13(
|
|
149687
|
+
writeFileSync13(join32(dir, "CONNECTORS.md"), ["# \u53EF\u7528\u8FDE\u63A5\u5668", "", "\u4EE5\u4E0B\u8FDE\u63A5\u5668\u5DF2\u4E3A\u672C\u6B21\u4F1A\u8BDD\u914D\u7F6E\uFF0C\u51ED\u8BC1\u5DF2\u901A\u8FC7\u73AF\u5883\u53D8\u91CF\u6216 CLI wrapper \u6CE8\u5165\uFF0C\u65E0\u9700\u624B\u52A8\u914D\u7F6E\uFF1A", "", ...lines].join("\n"));
|
|
149635
149688
|
}
|
|
149636
149689
|
spawnCwd = dir;
|
|
149637
149690
|
}
|
|
@@ -158793,7 +158846,7 @@ var init_skill_materializer = __esm({
|
|
|
158793
158846
|
|
|
158794
158847
|
// ../server/src/governance/connector-skills.ts
|
|
158795
158848
|
function connectorSkillsDir(dataDir, connectorId) {
|
|
158796
|
-
return (0,
|
|
158849
|
+
return (0, import_node_path14.join)(dataDir, "connector-skills", connectorId);
|
|
158797
158850
|
}
|
|
158798
158851
|
function parseConnectorSkillId(id) {
|
|
158799
158852
|
if (!id.startsWith("connector:")) return null;
|
|
@@ -158803,17 +158856,17 @@ function parseConnectorSkillId(id) {
|
|
|
158803
158856
|
return { connectorId: rest.slice(0, i), slug: rest.slice(i + 1) };
|
|
158804
158857
|
}
|
|
158805
158858
|
async function collect(root, dir, out) {
|
|
158806
|
-
for (const e of await (0,
|
|
158807
|
-
const abs = (0,
|
|
158859
|
+
for (const e of await (0, import_promises8.readdir)(dir, { withFileTypes: true })) {
|
|
158860
|
+
const abs = (0, import_node_path14.join)(dir, e.name);
|
|
158808
158861
|
if (e.isDirectory()) await collect(root, abs, out);
|
|
158809
|
-
else if (e.isFile()) out[(0,
|
|
158862
|
+
else if (e.isFile()) out[(0, import_node_path14.relative)(root, abs).split(/[\\/]/).join("/")] = await (0, import_promises8.readFile)(abs, "utf8");
|
|
158810
158863
|
}
|
|
158811
158864
|
}
|
|
158812
158865
|
async function readLocalPack(dataDir, connectorId) {
|
|
158813
158866
|
const root = connectorSkillsDir(dataDir, connectorId);
|
|
158814
158867
|
let slugs;
|
|
158815
158868
|
try {
|
|
158816
|
-
slugs = (await (0,
|
|
158869
|
+
slugs = (await (0, import_promises8.readdir)(root, { withFileTypes: true })).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
158817
158870
|
} catch {
|
|
158818
158871
|
return [];
|
|
158819
158872
|
}
|
|
@@ -158821,7 +158874,7 @@ async function readLocalPack(dataDir, connectorId) {
|
|
|
158821
158874
|
for (const slug6 of slugs) {
|
|
158822
158875
|
const files = {};
|
|
158823
158876
|
try {
|
|
158824
|
-
await collect((0,
|
|
158877
|
+
await collect((0, import_node_path14.join)(root, slug6), (0, import_node_path14.join)(root, slug6), files);
|
|
158825
158878
|
} catch {
|
|
158826
158879
|
continue;
|
|
158827
158880
|
}
|
|
@@ -158837,17 +158890,17 @@ async function readLocalPack(dataDir, connectorId) {
|
|
|
158837
158890
|
async function writePack(dataDir, connectorId, pack) {
|
|
158838
158891
|
const root = connectorSkillsDir(dataDir, connectorId);
|
|
158839
158892
|
const tmp = `${root}.tmp`;
|
|
158840
|
-
await (0,
|
|
158893
|
+
await (0, import_promises8.rm)(tmp, { recursive: true, force: true });
|
|
158841
158894
|
for (const s2 of pack) {
|
|
158842
158895
|
for (const [rel, content] of Object.entries(s2.files)) {
|
|
158843
|
-
const abs = (0,
|
|
158844
|
-
await (0,
|
|
158845
|
-
await (0,
|
|
158896
|
+
const abs = (0, import_node_path14.join)(tmp, s2.slug, rel);
|
|
158897
|
+
await (0, import_promises8.mkdir)((0, import_node_path14.dirname)(abs), { recursive: true });
|
|
158898
|
+
await (0, import_promises8.writeFile)(abs, content, "utf8");
|
|
158846
158899
|
}
|
|
158847
158900
|
}
|
|
158848
|
-
await (0,
|
|
158849
|
-
await (0,
|
|
158850
|
-
await (0,
|
|
158901
|
+
await (0, import_promises8.rm)(root, { recursive: true, force: true });
|
|
158902
|
+
await (0, import_promises8.mkdir)((0, import_node_path14.dirname)(root), { recursive: true });
|
|
158903
|
+
await (0, import_promises8.rename)(tmp, root);
|
|
158851
158904
|
}
|
|
158852
158905
|
function packMatches(local, remote) {
|
|
158853
158906
|
if (local.length !== remote.length) return false;
|
|
@@ -158874,12 +158927,12 @@ async function syncConnectorSkills(args) {
|
|
|
158874
158927
|
log3(`[connector-skills] ${args.connectorId}\uFF1A\u5DF2\u4ECE\u5382\u5546\u540C\u6B65 ${fresh.length} \u4E2A\u6280\u80FD`);
|
|
158875
158928
|
return { skills: fresh, outcome: "fetched" };
|
|
158876
158929
|
}
|
|
158877
|
-
var
|
|
158930
|
+
var import_promises8, import_node_path14, toId;
|
|
158878
158931
|
var init_connector_skills = __esm({
|
|
158879
158932
|
"../server/src/governance/connector-skills.ts"() {
|
|
158880
158933
|
"use strict";
|
|
158881
|
-
|
|
158882
|
-
|
|
158934
|
+
import_promises8 = require("node:fs/promises");
|
|
158935
|
+
import_node_path14 = require("node:path");
|
|
158883
158936
|
init_src5();
|
|
158884
158937
|
toId = (connectorId, slug6) => `connector:${connectorId}/${slug6}`;
|
|
158885
158938
|
}
|
|
@@ -162311,10 +162364,10 @@ function nodesDomain(deps) {
|
|
|
162311
162364
|
}
|
|
162312
162365
|
}
|
|
162313
162366
|
try {
|
|
162314
|
-
const here = (0,
|
|
162367
|
+
const here = (0, import_node_path15.dirname)((0, import_node_url4.fileURLToPath)(__esm_import_meta_url));
|
|
162315
162368
|
for (const rel of ["../../../../node-daemon/package.json", "../../../../../node-daemon/package.json"]) {
|
|
162316
162369
|
try {
|
|
162317
|
-
const raw = (0, import_node_fs11.readFileSync)((0,
|
|
162370
|
+
const raw = (0, import_node_fs11.readFileSync)((0, import_node_path15.resolve)(here, rel), "utf8");
|
|
162318
162371
|
const pkg = JSON.parse(raw);
|
|
162319
162372
|
if (pkg.version) return { version: pkg.version, source: "monorepo" };
|
|
162320
162373
|
} catch {
|
|
@@ -162626,14 +162679,14 @@ function nodesDomain(deps) {
|
|
|
162626
162679
|
});
|
|
162627
162680
|
};
|
|
162628
162681
|
}
|
|
162629
|
-
var import_node_crypto26, import_node_fs11, import_node_url4,
|
|
162682
|
+
var import_node_crypto26, import_node_fs11, import_node_url4, import_node_path15;
|
|
162630
162683
|
var init_routes5 = __esm({
|
|
162631
162684
|
"../server/src/domains/nodes/routes.ts"() {
|
|
162632
162685
|
"use strict";
|
|
162633
162686
|
import_node_crypto26 = require("node:crypto");
|
|
162634
162687
|
import_node_fs11 = require("node:fs");
|
|
162635
162688
|
import_node_url4 = require("node:url");
|
|
162636
|
-
|
|
162689
|
+
import_node_path15 = require("node:path");
|
|
162637
162690
|
init_src4();
|
|
162638
162691
|
init_connect_script();
|
|
162639
162692
|
init_node_health();
|
|
@@ -164008,12 +164061,12 @@ function nameKey(name) {
|
|
|
164008
164061
|
function cleanName(name) {
|
|
164009
164062
|
return name.trim().replace(/\s+/g, " ");
|
|
164010
164063
|
}
|
|
164011
|
-
var import_node_fs12,
|
|
164064
|
+
var import_node_fs12, import_node_path16, import_node_crypto27, SEP, keyOf, prefixOf, MemoryWorkorderTagStore, FileWorkorderTagStore;
|
|
164012
164065
|
var init_tags = __esm({
|
|
164013
164066
|
"../server/src/domains/collab/tags.ts"() {
|
|
164014
164067
|
"use strict";
|
|
164015
164068
|
import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
164016
|
-
|
|
164069
|
+
import_node_path16 = __toESM(require("node:path"), 1);
|
|
164017
164070
|
import_node_crypto27 = __toESM(require("node:crypto"), 1);
|
|
164018
164071
|
SEP = "::";
|
|
164019
164072
|
keyOf = (companyId, id) => `${companyId}${SEP}${id}`;
|
|
@@ -164099,7 +164152,7 @@ var init_tags = __esm({
|
|
|
164099
164152
|
}
|
|
164100
164153
|
persist() {
|
|
164101
164154
|
try {
|
|
164102
|
-
import_node_fs12.default.mkdirSync(
|
|
164155
|
+
import_node_fs12.default.mkdirSync(import_node_path16.default.dirname(this.file), { recursive: true });
|
|
164103
164156
|
const tmp = `${this.file}.tmp`;
|
|
164104
164157
|
import_node_fs12.default.writeFileSync(tmp, JSON.stringify(Object.fromEntries(this.map), null, 2));
|
|
164105
164158
|
import_node_fs12.default.renameSync(tmp, this.file);
|
|
@@ -165055,10 +165108,10 @@ function tokenType(p2) {
|
|
|
165055
165108
|
function parseOtlpMetricsUsage(body) {
|
|
165056
165109
|
const req = body;
|
|
165057
165110
|
const out = [];
|
|
165058
|
-
for (const
|
|
165059
|
-
const runId = attrString(
|
|
165111
|
+
for (const rm6 of req.resourceMetrics ?? []) {
|
|
165112
|
+
const runId = attrString(rm6.resource?.attributes, "oasis.run_id");
|
|
165060
165113
|
if (!runId) continue;
|
|
165061
|
-
const actorId = attrString(
|
|
165114
|
+
const actorId = attrString(rm6.resource?.attributes, "oasis.actor_id");
|
|
165062
165115
|
let input = 0;
|
|
165063
165116
|
let output = 0;
|
|
165064
165117
|
let cacheRead = 0;
|
|
@@ -165066,7 +165119,7 @@ function parseOtlpMetricsUsage(body) {
|
|
|
165066
165119
|
let costUsd = 0;
|
|
165067
165120
|
let sawToken = false;
|
|
165068
165121
|
let sawCost = false;
|
|
165069
|
-
for (const sm of
|
|
165122
|
+
for (const sm of rm6.scopeMetrics ?? []) {
|
|
165070
165123
|
for (const m2 of sm.metrics ?? []) {
|
|
165071
165124
|
const name = (m2.name ?? "").toLowerCase();
|
|
165072
165125
|
const points = m2.sum?.dataPoints ?? m2.gauge?.dataPoints ?? [];
|
|
@@ -167553,12 +167606,12 @@ function normalize(patch) {
|
|
|
167553
167606
|
...reviewRoles !== void 0 ? { reviewRoles: [...new Set(reviewRoles.map((r) => r.trim()).filter(Boolean))] } : {}
|
|
167554
167607
|
};
|
|
167555
167608
|
}
|
|
167556
|
-
var import_node_fs13,
|
|
167609
|
+
var import_node_fs13, import_node_path17, SEP2, keyOf2, prefixOf2, MemoryPlaybookOverrideStore, FilePlaybookOverrideStore;
|
|
167557
167610
|
var init_overrides = __esm({
|
|
167558
167611
|
"../server/src/domains/playbooks/overrides.ts"() {
|
|
167559
167612
|
"use strict";
|
|
167560
167613
|
import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
167561
|
-
|
|
167614
|
+
import_node_path17 = __toESM(require("node:path"), 1);
|
|
167562
167615
|
SEP2 = "::";
|
|
167563
167616
|
keyOf2 = (companyId, ref2, nodeKey) => `${companyId}${SEP2}${ref2}${SEP2}${nodeKey}`;
|
|
167564
167617
|
prefixOf2 = (companyId, ref2) => `${companyId}${SEP2}${ref2}${SEP2}`;
|
|
@@ -167597,7 +167650,7 @@ var init_overrides = __esm({
|
|
|
167597
167650
|
}
|
|
167598
167651
|
persist() {
|
|
167599
167652
|
try {
|
|
167600
|
-
import_node_fs13.default.mkdirSync(
|
|
167653
|
+
import_node_fs13.default.mkdirSync(import_node_path17.default.dirname(this.file), { recursive: true });
|
|
167601
167654
|
const tmp = `${this.file}.tmp`;
|
|
167602
167655
|
import_node_fs13.default.writeFileSync(tmp, JSON.stringify(Object.fromEntries(this.map), null, 2));
|
|
167603
167656
|
import_node_fs13.default.renameSync(tmp, this.file);
|
|
@@ -168036,12 +168089,12 @@ var init_daemon_adapter = __esm({
|
|
|
168036
168089
|
});
|
|
168037
168090
|
|
|
168038
168091
|
// ../server/src/side-map.ts
|
|
168039
|
-
var import_node_fs14,
|
|
168092
|
+
var import_node_fs14, import_node_path18, FileSideMap;
|
|
168040
168093
|
var init_side_map = __esm({
|
|
168041
168094
|
"../server/src/side-map.ts"() {
|
|
168042
168095
|
"use strict";
|
|
168043
168096
|
import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
168044
|
-
|
|
168097
|
+
import_node_path18 = __toESM(require("node:path"), 1);
|
|
168045
168098
|
FileSideMap = class {
|
|
168046
168099
|
constructor(file) {
|
|
168047
168100
|
this.file = file;
|
|
@@ -168068,7 +168121,7 @@ var init_side_map = __esm({
|
|
|
168068
168121
|
}
|
|
168069
168122
|
persist() {
|
|
168070
168123
|
try {
|
|
168071
|
-
import_node_fs14.default.mkdirSync(
|
|
168124
|
+
import_node_fs14.default.mkdirSync(import_node_path18.default.dirname(this.file), { recursive: true });
|
|
168072
168125
|
const tmp = `${this.file}.tmp`;
|
|
168073
168126
|
import_node_fs14.default.writeFileSync(tmp, JSON.stringify(Object.fromEntries(this.map), null, 2));
|
|
168074
168127
|
import_node_fs14.default.renameSync(tmp, this.file);
|
|
@@ -169524,26 +169577,26 @@ ${ctx.nodeFault}
|
|
|
169524
169577
|
|
|
169525
169578
|
// ../server/src/governance/builtin-skills.ts
|
|
169526
169579
|
async function collectDir(root, dir, out) {
|
|
169527
|
-
const entries = await (0,
|
|
169580
|
+
const entries = await (0, import_promises9.readdir)(dir, { withFileTypes: true });
|
|
169528
169581
|
for (const e of entries) {
|
|
169529
|
-
const abs = (0,
|
|
169582
|
+
const abs = (0, import_node_path19.join)(dir, e.name);
|
|
169530
169583
|
if (e.isDirectory()) {
|
|
169531
169584
|
await collectDir(root, abs, out);
|
|
169532
169585
|
} else if (e.isFile()) {
|
|
169533
|
-
const info = await (0,
|
|
169586
|
+
const info = await (0, import_promises9.stat)(abs);
|
|
169534
169587
|
if (info.size > MAX_FILE_BYTES3) {
|
|
169535
169588
|
console.warn(`[builtin-skills] skip oversized file (${info.size}B): ${abs}`);
|
|
169536
169589
|
continue;
|
|
169537
169590
|
}
|
|
169538
|
-
const rel = (0,
|
|
169539
|
-
out[rel] = await (0,
|
|
169591
|
+
const rel = (0, import_node_path19.relative)(root, abs).split(/[\\/]/).join("/");
|
|
169592
|
+
out[rel] = await (0, import_promises9.readFile)(abs, "utf8");
|
|
169540
169593
|
}
|
|
169541
169594
|
}
|
|
169542
169595
|
}
|
|
169543
169596
|
async function loadBuiltinSkills(skillsDir) {
|
|
169544
169597
|
let dirents;
|
|
169545
169598
|
try {
|
|
169546
|
-
dirents = await (0,
|
|
169599
|
+
dirents = await (0, import_promises9.readdir)(skillsDir, { withFileTypes: true });
|
|
169547
169600
|
} catch {
|
|
169548
169601
|
return [];
|
|
169549
169602
|
}
|
|
@@ -169551,7 +169604,7 @@ async function loadBuiltinSkills(skillsDir) {
|
|
|
169551
169604
|
for (const d of dirents) {
|
|
169552
169605
|
if (!d.isDirectory()) continue;
|
|
169553
169606
|
const slug6 = d.name;
|
|
169554
|
-
const skillDir = (0,
|
|
169607
|
+
const skillDir = (0, import_node_path19.join)(skillsDir, slug6);
|
|
169555
169608
|
const files = {};
|
|
169556
169609
|
try {
|
|
169557
169610
|
await collectDir(skillDir, skillDir, files);
|
|
@@ -169579,12 +169632,12 @@ function materializeBuiltinSkills(builtins, skillsDirPrefix) {
|
|
|
169579
169632
|
}
|
|
169580
169633
|
return out;
|
|
169581
169634
|
}
|
|
169582
|
-
var
|
|
169635
|
+
var import_promises9, import_node_path19, MAX_FILE_BYTES3;
|
|
169583
169636
|
var init_builtin_skills = __esm({
|
|
169584
169637
|
"../server/src/governance/builtin-skills.ts"() {
|
|
169585
169638
|
"use strict";
|
|
169586
|
-
|
|
169587
|
-
|
|
169639
|
+
import_promises9 = require("node:fs/promises");
|
|
169640
|
+
import_node_path19 = require("node:path");
|
|
169588
169641
|
init_skill_fetcher();
|
|
169589
169642
|
init_skill_materializer();
|
|
169590
169643
|
MAX_FILE_BYTES3 = 1 << 20;
|
|
@@ -182610,7 +182663,7 @@ var SessionManager = class {
|
|
|
182610
182663
|
|
|
182611
182664
|
// ../cli/src/daemon/ws-client.ts
|
|
182612
182665
|
init_wrapper();
|
|
182613
|
-
var
|
|
182666
|
+
var import_node_os9 = require("node:os");
|
|
182614
182667
|
var import_node_crypto38 = require("node:crypto");
|
|
182615
182668
|
init_src5();
|
|
182616
182669
|
|
|
@@ -182666,7 +182719,7 @@ function detectRuntimes() {
|
|
|
182666
182719
|
|
|
182667
182720
|
// ../cli/src/daemon/workdir-handler.ts
|
|
182668
182721
|
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
182669
|
-
var
|
|
182722
|
+
var import_node_path20 = __toESM(require("node:path"), 1);
|
|
182670
182723
|
init_src4();
|
|
182671
182724
|
init_src();
|
|
182672
182725
|
var WORKDIR_READ_MAX_BYTES2 = 2 * 1024 * 1024;
|
|
@@ -182685,10 +182738,10 @@ function isSensitiveSegment(segment) {
|
|
|
182685
182738
|
}
|
|
182686
182739
|
function relPathIsSensitive(rel) {
|
|
182687
182740
|
if (!rel) return false;
|
|
182688
|
-
return rel.split(
|
|
182741
|
+
return rel.split(import_node_path20.default.sep).some((seg) => seg.length > 0 && isSensitiveSegment(seg));
|
|
182689
182742
|
}
|
|
182690
182743
|
function withinBase(p2, base) {
|
|
182691
|
-
return p2 === base || p2.startsWith(base +
|
|
182744
|
+
return p2 === base || p2.startsWith(base + import_node_path20.default.sep);
|
|
182692
182745
|
}
|
|
182693
182746
|
function normalizeRel(raw) {
|
|
182694
182747
|
const trimmed = (raw ?? "").trim();
|
|
@@ -182705,7 +182758,7 @@ async function trustedCanonicalContainer(req, logicalBase, dirKind) {
|
|
|
182705
182758
|
} catch {
|
|
182706
182759
|
return null;
|
|
182707
182760
|
}
|
|
182708
|
-
return isLegacy ?
|
|
182761
|
+
return isLegacy ? import_node_path20.default.join(trustedRootReal, "oasis-chat-sessions") : import_node_path20.default.join(trustedRootReal, "sessions", dirKind);
|
|
182709
182762
|
}
|
|
182710
182763
|
async function resolveWithinWorkdir(req) {
|
|
182711
182764
|
const dirKind = sessionDirKind(req.runtimeKind);
|
|
@@ -182723,11 +182776,11 @@ async function resolveWithinWorkdir(req) {
|
|
|
182723
182776
|
} catch {
|
|
182724
182777
|
return { ok: false, code: "NOT_FOUND" };
|
|
182725
182778
|
}
|
|
182726
|
-
if (
|
|
182779
|
+
if (import_node_path20.default.dirname(base) !== canonicalContainer) return { ok: false, code: "PATH_ESCAPE" };
|
|
182727
182780
|
const rel = normalizeRel(req.path);
|
|
182728
|
-
const requested =
|
|
182781
|
+
const requested = import_node_path20.default.resolve(base, rel);
|
|
182729
182782
|
if (!withinBase(requested, base)) return { ok: false, code: "PATH_ESCAPE" };
|
|
182730
|
-
const cleanRel = base === requested ? "" :
|
|
182783
|
+
const cleanRel = base === requested ? "" : import_node_path20.default.relative(base, requested);
|
|
182731
182784
|
if (relPathIsSensitive(cleanRel)) return { ok: false, code: "SENSITIVE" };
|
|
182732
182785
|
let real;
|
|
182733
182786
|
try {
|
|
@@ -182737,7 +182790,7 @@ async function resolveWithinWorkdir(req) {
|
|
|
182737
182790
|
return { ok: false, code: "PATH_ESCAPE" };
|
|
182738
182791
|
}
|
|
182739
182792
|
if (!withinBase(real, base)) return { ok: false, code: "PATH_ESCAPE" };
|
|
182740
|
-
const realRel = base === real ? "" :
|
|
182793
|
+
const realRel = base === real ? "" : import_node_path20.default.relative(base, real);
|
|
182741
182794
|
if (relPathIsSensitive(realRel)) return { ok: false, code: "SENSITIVE" };
|
|
182742
182795
|
return { ok: true, base, real };
|
|
182743
182796
|
}
|
|
@@ -182773,7 +182826,7 @@ async function handleWorkdirList(req) {
|
|
|
182773
182826
|
const slice = truncated ? visible.slice(0, WORKDIR_LIST_MAX_ENTRIES) : visible;
|
|
182774
182827
|
const entries = [];
|
|
182775
182828
|
for (const d of slice) {
|
|
182776
|
-
const abs =
|
|
182829
|
+
const abs = import_node_path20.default.join(anchor, d.name);
|
|
182777
182830
|
try {
|
|
182778
182831
|
const st = await import_node_fs16.default.promises.lstat(abs);
|
|
182779
182832
|
if (st.isSymbolicLink()) continue;
|
|
@@ -182805,7 +182858,7 @@ async function verifyOpenedFd(fh, base, fallback) {
|
|
|
182805
182858
|
const fdReal = await fdCanonicalPath(fh);
|
|
182806
182859
|
if (fdReal === null) return { anchor: fallback };
|
|
182807
182860
|
if (!withinBase(fdReal, base)) return { error: { ok: false, code: "PATH_ESCAPE" } };
|
|
182808
|
-
const fdRel = base === fdReal ? "" :
|
|
182861
|
+
const fdRel = base === fdReal ? "" : import_node_path20.default.relative(base, fdReal);
|
|
182809
182862
|
if (relPathIsSensitive(fdRel)) return { error: { ok: false, code: "SENSITIVE" } };
|
|
182810
182863
|
return { anchor: `/proc/self/fd/${fh.fd}` };
|
|
182811
182864
|
}
|
|
@@ -182894,7 +182947,7 @@ function looksBinary(bytes) {
|
|
|
182894
182947
|
function contentTypeFor(absPath, bytes) {
|
|
182895
182948
|
const sniffed = sniffContentType(bytes);
|
|
182896
182949
|
if (sniffed) return sniffed;
|
|
182897
|
-
const ext =
|
|
182950
|
+
const ext = import_node_path20.default.extname(absPath).toLowerCase();
|
|
182898
182951
|
if (EXT_CONTENT_TYPE[ext]) return EXT_CONTENT_TYPE[ext];
|
|
182899
182952
|
return looksBinary(bytes) ? "application/octet-stream" : "text/plain; charset=utf-8";
|
|
182900
182953
|
}
|
|
@@ -183237,7 +183290,7 @@ var DaemonWsClient = class {
|
|
|
183237
183290
|
buildMeta() {
|
|
183238
183291
|
const activeSessions = this.sessions.activeSessions();
|
|
183239
183292
|
return {
|
|
183240
|
-
hostname: (0,
|
|
183293
|
+
hostname: (0, import_node_os9.hostname)(),
|
|
183241
183294
|
adapters: this.adapters,
|
|
183242
183295
|
...this.reportRuntimes ? { runtimes: this.runtimes } : {},
|
|
183243
183296
|
nodeVersion: process.version,
|
|
@@ -183267,18 +183320,18 @@ var RuntimeRouterAdapter = class {
|
|
|
183267
183320
|
|
|
183268
183321
|
// ../cli/src/daemon/reap-claude-projects.ts
|
|
183269
183322
|
var import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
183270
|
-
var
|
|
183271
|
-
var
|
|
183323
|
+
var import_node_os10 = __toESM(require("node:os"), 1);
|
|
183324
|
+
var import_node_path21 = __toESM(require("node:path"), 1);
|
|
183272
183325
|
function claudeProjectSlug(cwd) {
|
|
183273
183326
|
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
183274
183327
|
}
|
|
183275
183328
|
function claudeProjectsRoot() {
|
|
183276
|
-
const configDir = process.env["CLAUDE_CONFIG_DIR"] ||
|
|
183277
|
-
return
|
|
183329
|
+
const configDir = process.env["CLAUDE_CONFIG_DIR"] || import_node_path21.default.join(import_node_os10.default.homedir(), ".claude");
|
|
183330
|
+
return import_node_path21.default.join(configDir, "projects");
|
|
183278
183331
|
}
|
|
183279
183332
|
function reapClaudeProjects(workdir, runtimeKind) {
|
|
183280
183333
|
if (runtimeKind !== "claude" && runtimeKind !== "claude-code") return;
|
|
183281
|
-
const dir =
|
|
183334
|
+
const dir = import_node_path21.default.join(claudeProjectsRoot(), claudeProjectSlug(workdir));
|
|
183282
183335
|
if (!import_node_fs17.default.existsSync(dir)) return;
|
|
183283
183336
|
try {
|
|
183284
183337
|
import_node_fs17.default.rmSync(dir, { recursive: true, force: true });
|
|
@@ -183288,7 +183341,7 @@ function reapClaudeProjects(workdir, runtimeKind) {
|
|
|
183288
183341
|
|
|
183289
183342
|
// ../cli/src/node.ts
|
|
183290
183343
|
init_src4();
|
|
183291
|
-
var
|
|
183344
|
+
var import_node_os11 = __toESM(require("node:os"), 1);
|
|
183292
183345
|
var RESILIENCE = {
|
|
183293
183346
|
codex: { idleTimeoutMs: 6e5 }
|
|
183294
183347
|
};
|
|
@@ -183352,7 +183405,7 @@ async function startNode(opts) {
|
|
|
183352
183405
|
console.log(`[oasis node] ${opts.nodeId} \u2192 ${opts.serverUrl}`);
|
|
183353
183406
|
client.start();
|
|
183354
183407
|
const { workRoot, legacyRoot } = resolveWorkRoots(opts.workRoot);
|
|
183355
|
-
const workRootIsEphemeral = workRoot.startsWith(
|
|
183408
|
+
const workRootIsEphemeral = workRoot.startsWith(import_node_os11.default.tmpdir());
|
|
183356
183409
|
if (opts.gcEnabled === false && !workRootIsEphemeral) {
|
|
183357
183410
|
console.warn(`[oasis node] \u26A0 \u56DE\u6536\u5668\u5DF2\u5173\u95ED\uFF0C\u800C\u5DE5\u4F5C\u533A\u5728\u6301\u4E45\u76D8\uFF08${workRoot}\uFF09\u2014\u2014\u6CA1\u6709\u4EFB\u4F55\u5783\u573E\u56DE\u6536\uFF0C\u5B9E\u6D4B\u4E24\u5468\u4F1A\u6DA8 12.4GB\u3002\u4EC5\u4F9B\u6392\u969C\uFF0C\u522B\u957F\u671F\u8FD9\u4E48\u8DD1\u3002`);
|
|
183358
183411
|
}
|
|
@@ -183387,7 +183440,7 @@ async function startNode(opts) {
|
|
|
183387
183440
|
var import_node_child_process16 = require("node:child_process");
|
|
183388
183441
|
var import_node_fs18 = require("node:fs");
|
|
183389
183442
|
var import_node_crypto39 = require("node:crypto");
|
|
183390
|
-
var
|
|
183443
|
+
var import_node_os12 = require("node:os");
|
|
183391
183444
|
function linuxMachineId() {
|
|
183392
183445
|
for (const p2 of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
|
|
183393
183446
|
try {
|
|
@@ -183427,13 +183480,13 @@ function windowsMachineId() {
|
|
|
183427
183480
|
}
|
|
183428
183481
|
function fallbackFingerprint() {
|
|
183429
183482
|
const macs = [];
|
|
183430
|
-
const ifaces = (0,
|
|
183483
|
+
const ifaces = (0, import_node_os12.networkInterfaces)();
|
|
183431
183484
|
for (const name of Object.keys(ifaces).sort()) {
|
|
183432
183485
|
for (const ni of ifaces[name] ?? []) {
|
|
183433
183486
|
if (!ni.internal && ni.mac && ni.mac !== "00:00:00:00:00:00") macs.push(ni.mac);
|
|
183434
183487
|
}
|
|
183435
183488
|
}
|
|
183436
|
-
return `fallback:${(0,
|
|
183489
|
+
return `fallback:${(0, import_node_os12.hostname)()}:${macs.sort()[0] ?? "no-mac"}`;
|
|
183437
183490
|
}
|
|
183438
183491
|
function machineFingerprint() {
|
|
183439
183492
|
const byOs = process.platform === "darwin" ? macMachineId() : process.platform === "win32" ? windowsMachineId() : linuxMachineId();
|
|
@@ -183443,7 +183496,7 @@ var defaultSources = {
|
|
|
183443
183496
|
machineFingerprint,
|
|
183444
183497
|
osUser: () => {
|
|
183445
183498
|
try {
|
|
183446
|
-
return (0,
|
|
183499
|
+
return (0, import_node_os12.userInfo)().username;
|
|
183447
183500
|
} catch {
|
|
183448
183501
|
return process.env["USER"] ?? process.env["USERNAME"] ?? "unknown";
|
|
183449
183502
|
}
|
|
@@ -186851,7 +186904,7 @@ function syncRuntimeAssets(candidateRoots, binDir) {
|
|
|
186851
186904
|
}
|
|
186852
186905
|
|
|
186853
186906
|
// src/index.ts
|
|
186854
|
-
var PKG_VERSION = true ? "0.1.
|
|
186907
|
+
var PKG_VERSION = true ? "0.1.90" : "dev";
|
|
186855
186908
|
var OASIS_DIR = path29.join(os9.homedir(), ".oasis");
|
|
186856
186909
|
var CONFIG_FILE = path29.join(OASIS_DIR, "node-config.json");
|
|
186857
186910
|
var PID_FILE = path29.join(OASIS_DIR, "node.pid");
|