@scp-dev/broker 0.1.4 → 0.1.6

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 CHANGED
@@ -732,7 +732,8 @@ function startBridge(options) {
732
732
  labels: view.labels,
733
733
  status: view.status ? { state: view.status.state, note: options.redact ? "" : view.status.note } : null,
734
734
  presence: view.presence,
735
- last_seen: view.last_seen
735
+ last_seen: view.last_seen,
736
+ ...view.kind === "agent" ? { wake: view.wake ?? null } : {}
736
737
  };
737
738
  }
738
739
  function localViews() {
@@ -1210,7 +1211,19 @@ var SCOPE_METHODS = /* @__PURE__ */ new Set([
1210
1211
  var CHANGES_SCOPE = /* @__PURE__ */ new Set(["rules_set", "rules_widen", "rules_lift", "group"]);
1211
1212
  var ASK_RECHECK_MS = 1e3;
1212
1213
  var STOP_RECHECK_MS = 1e3;
1213
- var TRANSIENT_METHODS = /* @__PURE__ */ new Set(["event", "status", "whoami", "inject", "injected", "peek_turn", "stop_wait", "prompted", "title_infer"]);
1214
+ var TRANSIENT_METHODS = /* @__PURE__ */ new Set([
1215
+ "event",
1216
+ "status",
1217
+ "whoami",
1218
+ "inject",
1219
+ "injected",
1220
+ "peek_turn",
1221
+ "stop_wait",
1222
+ "prompted",
1223
+ "title_infer",
1224
+ "subagent_title",
1225
+ "wake"
1226
+ ]);
1214
1227
  var GRANT_UNBOUND = `a spawn-env grant binds only a new harness process: run the harness with it, or name the child (${CLI_NAME} spawn-env --name / --as)`;
1215
1228
  function workerResults(result) {
1216
1229
  return result.messages.length - (result.others_shown ?? 0) + result.more;
@@ -1857,6 +1870,17 @@ async function startBroker(options) {
1857
1870
  if (changed) bridge?.changed(me);
1858
1871
  return { changed };
1859
1872
  }
1873
+ case "subagent_title": {
1874
+ const changed = core.subagentTitle(me, params, hookOf(s));
1875
+ if (changed) bridge?.changed(changed);
1876
+ return { changed: changed !== null };
1877
+ }
1878
+ case "wake": {
1879
+ if (s.data.lineage && !s.data.own) throw new RelayError3("unauthorized", "only the endpoint's own session says how it wakes");
1880
+ const changed = core.setWake(me, params.via, hookOf(s));
1881
+ if (changed) bridge?.changed(me);
1882
+ return { changed };
1883
+ }
1860
1884
  case "rename": {
1861
1885
  const renamed = core.rename(actorOf(s), { ...params.endpoint !== void 0 ? { endpoint: params.endpoint } : {}, handle: params.handle });
1862
1886
  membership(renamed.endpoint, renamed.session, true, renamed.from);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scp-dev/broker",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Swarm Communication Protocol local broker: a unix socket JSON-RPC daemon over the relay core, its client and the bridge to an account hub.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://scp.dev",
@@ -37,8 +37,8 @@
37
37
  "typecheck": "tsc -p ."
38
38
  },
39
39
  "dependencies": {
40
- "@scp-dev/core": "0.1.3",
41
- "@scp-dev/hub": "0.3.0"
40
+ "@scp-dev/core": "0.1.4",
41
+ "@scp-dev/hub": "0.4.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.5.1"
package/src/bridge.ts CHANGED
@@ -316,6 +316,7 @@ export function startBridge(options: BridgeOptions): Bridge {
316
316
  status: view.status ? { state: view.status.state, note: options.redact ? "" : view.status.note } : null,
317
317
  presence: view.presence,
318
318
  last_seen: view.last_seen,
319
+ ...(view.kind === "agent" ? { wake: view.wake ?? null } : {}),
319
320
  }
320
321
  }
321
322
 
package/src/server.ts CHANGED
@@ -148,7 +148,19 @@ const CHANGES_SCOPE = new Set(["rules_set", "rules_widen", "rules_lift", "group"
148
148
  const ASK_RECHECK_MS = 1000
149
149
  /** how often a waiting stop rechecks its workers, since a worker's exit or lapse wakes no one */
150
150
  const STOP_RECHECK_MS = 1000
151
- const TRANSIENT_METHODS = new Set(["event", "status", "whoami", "inject", "injected", "peek_turn", "stop_wait", "prompted", "title_infer"])
151
+ const TRANSIENT_METHODS = new Set([
152
+ "event",
153
+ "status",
154
+ "whoami",
155
+ "inject",
156
+ "injected",
157
+ "peek_turn",
158
+ "stop_wait",
159
+ "prompted",
160
+ "title_infer",
161
+ "subagent_title",
162
+ "wake",
163
+ ])
152
164
  const GRANT_UNBOUND = `a spawn-env grant binds only a new harness process: run the harness with it, or name the child (${CLI_NAME} spawn-env --name / --as)`
153
165
 
154
166
  /** the workers' messages and handbacks a stop's push would show, and those of theirs left unread past it */
@@ -871,6 +883,17 @@ export async function startBroker(options: BrokerOptions): Promise<Broker> {
871
883
  if (changed) bridge?.changed(me)
872
884
  return { changed }
873
885
  }
886
+ case "subagent_title": {
887
+ const changed = core.subagentTitle(me, params, hookOf(s))
888
+ if (changed) bridge?.changed(changed)
889
+ return { changed: changed !== null }
890
+ }
891
+ case "wake": {
892
+ if (s.data.lineage && !s.data.own) throw new RelayError("unauthorized", "only the endpoint's own session says how it wakes")
893
+ const changed = core.setWake(me, params.via, hookOf(s))
894
+ if (changed) bridge?.changed(me)
895
+ return { changed }
896
+ }
874
897
  case "rename": {
875
898
  const renamed = core.rename(actorOf(s), { ...(params.endpoint !== undefined ? { endpoint: params.endpoint } : {}), handle: params.handle })
876
899
  membership(renamed.endpoint, renamed.session, true, renamed.from)