@themoltnet/agent-daemon 0.64.0 → 0.65.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.
Files changed (2) hide show
  1. package/dist/cli.js +67 -6
  2. package/package.json +9 -9
package/dist/cli.js CHANGED
@@ -9580,6 +9580,20 @@ async function validateNativeSocket(path) {
9580
9580
  //#region src/lib/agent-server/operator-oauth.ts
9581
9581
  var InvalidOperatorGrantError = class extends Error {};
9582
9582
  var LOCAL_SCOPE = OPERATOR_OAUTH.localControlScope;
9583
+ function readOperatorTeams(value) {
9584
+ if (!Array.isArray(value) || value.length > 256) return [];
9585
+ const teams = value;
9586
+ if (!teams.every(isOperatorTeam)) return [];
9587
+ return teams.map(({ id, name }) => ({
9588
+ id,
9589
+ name
9590
+ }));
9591
+ }
9592
+ function isOperatorTeam(value) {
9593
+ if (!value || typeof value !== "object") return false;
9594
+ const team = value;
9595
+ return typeof team["id"] === "string" && /^[0-9a-f-]{36}$/i.test(team["id"]) && typeof team["name"] === "string" && team["name"].length > 0 && team["name"].length <= 200;
9596
+ }
9583
9597
  /** Trusted native controller owns the verifier, callback and token exchange. */
9584
9598
  var OperatorOAuth = class {
9585
9599
  instance = randomUUID();
@@ -9611,7 +9625,9 @@ var OperatorOAuth = class {
9611
9625
  if (!value || typeof value !== "object" || !("issuer" in value) || !("subject" in value) || typeof value.issuer !== "string" || typeof value.subject !== "string") throw new Error("Invalid operator");
9612
9626
  this.operator = {
9613
9627
  issuer: value.issuer,
9614
- subject: value.subject
9628
+ subject: value.subject,
9629
+ email: "email" in value && typeof value.email === "string" ? value.email : void 0,
9630
+ teams: "teams" in value ? readOperatorTeams(value.teams) : []
9615
9631
  };
9616
9632
  } catch (error) {
9617
9633
  if (error.code !== "ENOENT") throw error;
@@ -9624,6 +9640,12 @@ var OperatorOAuth = class {
9624
9640
  operatorConfigured() {
9625
9641
  return this.operator !== null;
9626
9642
  }
9643
+ operatorEmail() {
9644
+ return this.operator?.email;
9645
+ }
9646
+ listTeams() {
9647
+ return this.operator?.teams ?? [];
9648
+ }
9627
9649
  removeOperator() {
9628
9650
  this.cancel();
9629
9651
  rmSync(join(this.root, "operator.json"), { force: true });
@@ -9647,7 +9669,9 @@ var OperatorOAuth = class {
9647
9669
  return {
9648
9670
  issuer: payload.iss,
9649
9671
  subject: payload.sub,
9650
- provisioning: claims["moltnet:provisioning"]
9672
+ email: typeof claims["moltnet:operator_email"] === "string" ? claims["moltnet:operator_email"] : void 0,
9673
+ provisioning: claims["moltnet:provisioning"],
9674
+ teams: readOperatorTeams(claims["moltnet:operator_teams"])
9651
9675
  };
9652
9676
  }
9653
9677
  async authorize(grant, signal) {
@@ -9736,7 +9760,9 @@ var OperatorOAuth = class {
9736
9760
  try {
9737
9761
  writeFileSync(join(this.root, "operator.json"), JSON.stringify({
9738
9762
  issuer: operator.issuer,
9739
- subject: operator.subject
9763
+ subject: operator.subject,
9764
+ ...operator.email ? { email: operator.email } : {},
9765
+ teams: grant ? [] : operator.teams
9740
9766
  }), {
9741
9767
  mode: 384,
9742
9768
  flag: "wx"
@@ -9748,8 +9774,14 @@ var OperatorOAuth = class {
9748
9774
  }
9749
9775
  this.operator = {
9750
9776
  issuer: operator.issuer,
9751
- subject: operator.subject
9777
+ subject: operator.subject,
9778
+ ...operator.email ? { email: operator.email } : {},
9779
+ teams: grant ? [] : operator.teams
9752
9780
  };
9781
+ } else if (!grant || operator.email) {
9782
+ if (operator.email) this.operator.email = operator.email;
9783
+ if (!grant) this.operator.teams = operator.teams;
9784
+ writeFileSync(join(this.root, "operator.json"), JSON.stringify(this.operator), { mode: 384 });
9753
9785
  }
9754
9786
  return tokens.access_token;
9755
9787
  } finally {
@@ -12871,7 +12903,36 @@ function buildAgentServer(input) {
12871
12903
  return { state: "authorized" };
12872
12904
  });
12873
12905
  app.get("/v1/native/operator", { schema: { hide: true } }, async (request) => {
12874
- return { operatorConfigured: (await requireNativeOrigin(requireAuthorizedOrigin, request, oauth)).operatorConfigured() };
12906
+ const operator = await requireNativeOrigin(requireAuthorizedOrigin, request, oauth);
12907
+ return {
12908
+ operatorConfigured: operator.operatorConfigured(),
12909
+ email: operator.operatorEmail() ?? null
12910
+ };
12911
+ });
12912
+ app.get("/v1/operator/teams", { schema: {
12913
+ operationId: "listAgentServerOperatorTeams",
12914
+ tags: ["operator"],
12915
+ security: [{ agentServerToken: [] }],
12916
+ response: { 200: {
12917
+ type: "object",
12918
+ required: ["items"],
12919
+ properties: { items: {
12920
+ type: "array",
12921
+ items: {
12922
+ type: "object",
12923
+ required: ["id", "name"],
12924
+ properties: {
12925
+ id: {
12926
+ type: "string",
12927
+ format: "uuid"
12928
+ },
12929
+ name: { type: "string" }
12930
+ }
12931
+ }
12932
+ } }
12933
+ } }
12934
+ } }, async (request) => {
12935
+ return { items: (await requireNativeOrigin(requireAuthorizedOrigin, request, oauth)).listTeams() };
12875
12936
  });
12876
12937
  app.post("/v1/operator/cancel", { schema: {
12877
12938
  operationId: "cancelAgentServerOperatorApproval",
@@ -14187,7 +14248,7 @@ async function writeCache(cache) {
14187
14248
  }
14188
14249
  //#endregion
14189
14250
  //#region src/version.ts
14190
- var DAEMON_VERSION = "0.64.0";
14251
+ var DAEMON_VERSION = "0.65.1";
14191
14252
  //#endregion
14192
14253
  //#region src/cli.ts
14193
14254
  async function runAgentDaemonCli(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@themoltnet/agent-daemon",
3
- "version": "0.64.0",
3
+ "version": "0.65.1",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "description": "Universal MoltNet agent daemon host with a built-in Pi/Gondolin runtime and support for trusted operator-owned runtime modules. CLI: moltnet-agent.",
@@ -84,10 +84,10 @@
84
84
  "pino-pretty": "^13.1.3",
85
85
  "proper-lockfile": "4.1.2",
86
86
  "typebox": "^1.2.8",
87
- "@themoltnet/sdk": "0.146.0",
88
- "@themoltnet/pi-runtime": "0.18.4",
89
87
  "@themoltnet/agent-runtime": "1.4.0",
90
- "@themoltnet/os-keyring": "0.4.0"
88
+ "@themoltnet/os-keyring": "0.4.0",
89
+ "@themoltnet/sdk": "0.146.0",
90
+ "@themoltnet/pi-runtime": "0.18.4"
91
91
  },
92
92
  "devDependencies": {
93
93
  "@fastify/swagger": "^9.6.1",
@@ -98,15 +98,15 @@
98
98
  "vite-plugin-dts": "^4.5.4",
99
99
  "vitest": "^3.0.0",
100
100
  "@moltnet/agent-eval": "0.1.0",
101
- "@moltnet/bootstrap": "0.1.0",
102
- "@moltnet/execution-integrations": "0.1.0",
103
101
  "@moltnet/api-client": "0.1.0",
104
- "@moltnet/models": "0.1.0",
102
+ "@moltnet/crypto-service": "0.1.0",
103
+ "@moltnet/bootstrap": "0.1.0",
105
104
  "@moltnet/execution-plan": "0.1.0",
106
- "@moltnet/observability": "0.1.0",
105
+ "@moltnet/execution-integrations": "0.1.0",
107
106
  "@moltnet/loopback-companion": "0.1.0",
107
+ "@moltnet/observability": "0.1.0",
108
+ "@moltnet/models": "0.1.0",
108
109
  "@moltnet/runtime-profiles": "0.1.0",
109
- "@moltnet/crypto-service": "0.1.0",
110
110
  "@moltnet/tasks": "0.1.0"
111
111
  },
112
112
  "nx": {