@a9i5k4/dsh-literature 0.3.4 → 0.3.5
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/lib/index.js +13 -13
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -757,7 +757,7 @@ var UA, FetchFailure;
|
|
|
757
757
|
var init_net = __esm({
|
|
758
758
|
"src/node/net.js"() {
|
|
759
759
|
init_log();
|
|
760
|
-
UA = "dsh-literature/0.3.
|
|
760
|
+
UA = "dsh-literature/0.3.5 (+https://github.com/deepseek-ai/deepseek-harness)";
|
|
761
761
|
FetchFailure = class extends Error {
|
|
762
762
|
constructor(message, { code = "network", status = 0, retryable = true, cause } = {}) {
|
|
763
763
|
super(message, { cause });
|
|
@@ -36406,7 +36406,7 @@ async function readJsonBody2(req) {
|
|
|
36406
36406
|
const { readJsonBody: read } = await Promise.resolve().then(() => (init_http(), http_exports));
|
|
36407
36407
|
return read(req);
|
|
36408
36408
|
}
|
|
36409
|
-
async function handler(req, res, ctx2) {
|
|
36409
|
+
async function handler(req, res, ctx2, { activation } = {}) {
|
|
36410
36410
|
if (!isLoopbackRequest(req)) {
|
|
36411
36411
|
writeJson(res, 403, { error: "forbidden: loopback-only", code: "forbidden" });
|
|
36412
36412
|
return;
|
|
@@ -36687,8 +36687,8 @@ async function handler(req, res, ctx2) {
|
|
|
36687
36687
|
else res.end();
|
|
36688
36688
|
}
|
|
36689
36689
|
}
|
|
36690
|
-
function registerRoutes(ctx2, { activation
|
|
36691
|
-
const disposers = [ctx2.webServer.register({ kind: "prefix", path: PREFIX2, handler: (req, res) => handler(req, res, ctx2) })];
|
|
36690
|
+
function registerRoutes(ctx2, { activation } = {}) {
|
|
36691
|
+
const disposers = [ctx2.webServer.register({ kind: "prefix", path: PREFIX2, handler: (req, res) => handler(req, res, ctx2, { activation }) })];
|
|
36692
36692
|
if (typeof ctx2.on === "function") {
|
|
36693
36693
|
disposers.push(
|
|
36694
36694
|
ctx2.on("session/event", (session) => {
|
|
@@ -37307,14 +37307,14 @@ function textFromSessionEvent(event) {
|
|
|
37307
37307
|
}
|
|
37308
37308
|
return "";
|
|
37309
37309
|
}
|
|
37310
|
-
function registerSessionHook(ctx2, { activation
|
|
37310
|
+
function registerSessionHook(ctx2, { activation, detectIntent: detectIntent2 } = {}) {
|
|
37311
37311
|
const disposers = [];
|
|
37312
37312
|
disposers.push(
|
|
37313
37313
|
ctx2.on("session/event", (session, event) => {
|
|
37314
37314
|
const text = textFromSessionEvent(event);
|
|
37315
|
-
if (
|
|
37315
|
+
if (activation && detectIntent2 && event?.type === "user/message") {
|
|
37316
37316
|
const verdict = detectIntent2(textFromSessionEvent(event));
|
|
37317
|
-
if (verdict.active)
|
|
37317
|
+
if (verdict.active) activation.activate(verdict.reason);
|
|
37318
37318
|
}
|
|
37319
37319
|
if (!text || text.length < 20) return;
|
|
37320
37320
|
if (!extractIdentifiers(text).length) return;
|
|
@@ -37508,12 +37508,12 @@ function apply(ctx2, config) {
|
|
|
37508
37508
|
const ready = (async () => {
|
|
37509
37509
|
await ensureDirs();
|
|
37510
37510
|
await init();
|
|
37511
|
-
const
|
|
37512
|
-
|
|
37511
|
+
const activation = createActivation();
|
|
37512
|
+
activation.activate("always-on");
|
|
37513
37513
|
const toolsCtl = registerTools(ctx2);
|
|
37514
37514
|
toolsCtl.mount();
|
|
37515
|
-
disposers.push(
|
|
37516
|
-
disposers.push(() =>
|
|
37515
|
+
disposers.push(activation.onTransition(({ active }) => active ? toolsCtl.mount() : toolsCtl.unmount()));
|
|
37516
|
+
disposers.push(() => activation.dispose());
|
|
37517
37517
|
try {
|
|
37518
37518
|
disposers.push(
|
|
37519
37519
|
ctx2.systemPrompt.section({
|
|
@@ -37533,9 +37533,9 @@ function apply(ctx2, config) {
|
|
|
37533
37533
|
} catch (e) {
|
|
37534
37534
|
error("systemPrompt unavailable:", e.message);
|
|
37535
37535
|
}
|
|
37536
|
-
disposers.push(...registerRoutes(ctx2, { activation
|
|
37536
|
+
disposers.push(...registerRoutes(ctx2, { activation }));
|
|
37537
37537
|
try {
|
|
37538
|
-
disposers.push(...registerSessionHook(ctx2, { activation
|
|
37538
|
+
disposers.push(...registerSessionHook(ctx2, { activation, detectIntent }));
|
|
37539
37539
|
} catch (e) {
|
|
37540
37540
|
error("session hook unavailable:", e.message);
|
|
37541
37541
|
}
|
package/package.json
CHANGED