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/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
- wctx.effect(() => web.register({
6283
+ const settingsRoute = {
6265
6284
  kind: "exact",
6266
6285
  path: "/subagent-library/api",
6267
- handler: async (req, res) => {
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
- }), "subagent-library: settings api route");
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-subagent-library",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Manage reusable roles and groups in DeepSeek Harness Settings and delegate one native subagent at a time.",
5
5
  "keywords": [
6
6
  "deepseek-harness",