dsh-subagent-library 0.4.0 → 0.4.1
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/CHANGELOG.md +16 -1
- package/README.en.md +58 -26
- package/README.md +59 -27
- package/assets/readme/hero.svg +3 -3
- package/assets/readme/member-model-effort.png +0 -0
- package/assets/readme/screenshot-settings.png +0 -0
- package/lib/client.js +375 -147
- package/lib/index.js +37 -3
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -5572,6 +5572,25 @@ function formatCatalog(rows, kind, groupId) {
|
|
|
5572
5572
|
return lines;
|
|
5573
5573
|
}
|
|
5574
5574
|
|
|
5575
|
+
//#endregion
|
|
5576
|
+
//#region src/settings-access.ts
|
|
5577
|
+
/** New routers supply the admitted peer. Older ones delegate admission to Connection. */
|
|
5578
|
+
function settingsAccessStatus(ctx, req, peer) {
|
|
5579
|
+
try {
|
|
5580
|
+
if (peer === void 0) {
|
|
5581
|
+
const admission = ctx.get("connection")?.admit(req);
|
|
5582
|
+
if (!admission) return 503;
|
|
5583
|
+
if ("rejection" in admission) return admission.rejection === 401 || admission.rejection === 403 ? admission.rejection : 503;
|
|
5584
|
+
peer = admission.peer;
|
|
5585
|
+
}
|
|
5586
|
+
const kind = peer?.principal?.kind;
|
|
5587
|
+
if (typeof kind !== "string" || !kind) return 503;
|
|
5588
|
+
return kind === "owner" ? 200 : 403;
|
|
5589
|
+
} catch {
|
|
5590
|
+
return 503;
|
|
5591
|
+
}
|
|
5592
|
+
}
|
|
5593
|
+
|
|
5575
5594
|
//#endregion
|
|
5576
5595
|
//#region src/index.ts
|
|
5577
5596
|
const name = "subagent-library";
|
|
@@ -6261,10 +6280,24 @@ function apply(ctx, config) {
|
|
|
6261
6280
|
warnings
|
|
6262
6281
|
};
|
|
6263
6282
|
};
|
|
6264
|
-
|
|
6283
|
+
const settingsRoute = {
|
|
6265
6284
|
kind: "exact",
|
|
6266
6285
|
path: "/subagent-library/api",
|
|
6267
|
-
|
|
6286
|
+
auth: "required",
|
|
6287
|
+
handler: async (req, res, peer) => {
|
|
6288
|
+
const access = settingsAccessStatus(ctx, req, peer);
|
|
6289
|
+
if (access !== 200) {
|
|
6290
|
+
const error = {
|
|
6291
|
+
401: "unauthorized",
|
|
6292
|
+
403: "forbidden",
|
|
6293
|
+
503: "host-authentication-unavailable"
|
|
6294
|
+
}[access];
|
|
6295
|
+
sendJson(res, access, {
|
|
6296
|
+
ok: false,
|
|
6297
|
+
error
|
|
6298
|
+
});
|
|
6299
|
+
return;
|
|
6300
|
+
}
|
|
6268
6301
|
if (req.method === "GET") {
|
|
6269
6302
|
if (settingsFailure !== void 0) {
|
|
6270
6303
|
sendJson(res, 503, {
|
|
@@ -6359,7 +6392,8 @@ function apply(ctx, config) {
|
|
|
6359
6392
|
}
|
|
6360
6393
|
sendJson(res, status, response);
|
|
6361
6394
|
}
|
|
6362
|
-
}
|
|
6395
|
+
};
|
|
6396
|
+
wctx.effect(() => web.register(settingsRoute), "subagent-library: settings api route");
|
|
6363
6397
|
});
|
|
6364
6398
|
registerLibraryTools(ctx, loadEffective, routeNoteText, () => settingsFailure);
|
|
6365
6399
|
}
|
package/package.json
CHANGED