@themoltnet/agent-daemon 0.64.0 → 0.65.0

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 +54 -5
  2. package/package.json +10 -10
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,8 @@ 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
+ teams: "teams" in value ? readOperatorTeams(value.teams) : []
9615
9630
  };
9616
9631
  } catch (error) {
9617
9632
  if (error.code !== "ENOENT") throw error;
@@ -9624,6 +9639,9 @@ var OperatorOAuth = class {
9624
9639
  operatorConfigured() {
9625
9640
  return this.operator !== null;
9626
9641
  }
9642
+ listTeams() {
9643
+ return this.operator?.teams ?? [];
9644
+ }
9627
9645
  removeOperator() {
9628
9646
  this.cancel();
9629
9647
  rmSync(join(this.root, "operator.json"), { force: true });
@@ -9647,7 +9665,8 @@ var OperatorOAuth = class {
9647
9665
  return {
9648
9666
  issuer: payload.iss,
9649
9667
  subject: payload.sub,
9650
- provisioning: claims["moltnet:provisioning"]
9668
+ provisioning: claims["moltnet:provisioning"],
9669
+ teams: readOperatorTeams(claims["moltnet:operator_teams"])
9651
9670
  };
9652
9671
  }
9653
9672
  async authorize(grant, signal) {
@@ -9736,7 +9755,8 @@ var OperatorOAuth = class {
9736
9755
  try {
9737
9756
  writeFileSync(join(this.root, "operator.json"), JSON.stringify({
9738
9757
  issuer: operator.issuer,
9739
- subject: operator.subject
9758
+ subject: operator.subject,
9759
+ teams: grant ? [] : operator.teams
9740
9760
  }), {
9741
9761
  mode: 384,
9742
9762
  flag: "wx"
@@ -9748,8 +9768,12 @@ var OperatorOAuth = class {
9748
9768
  }
9749
9769
  this.operator = {
9750
9770
  issuer: operator.issuer,
9751
- subject: operator.subject
9771
+ subject: operator.subject,
9772
+ teams: grant ? [] : operator.teams
9752
9773
  };
9774
+ } else if (!grant) {
9775
+ this.operator.teams = operator.teams;
9776
+ writeFileSync(join(this.root, "operator.json"), JSON.stringify(this.operator), { mode: 384 });
9753
9777
  }
9754
9778
  return tokens.access_token;
9755
9779
  } finally {
@@ -12873,6 +12897,31 @@ function buildAgentServer(input) {
12873
12897
  app.get("/v1/native/operator", { schema: { hide: true } }, async (request) => {
12874
12898
  return { operatorConfigured: (await requireNativeOrigin(requireAuthorizedOrigin, request, oauth)).operatorConfigured() };
12875
12899
  });
12900
+ app.get("/v1/operator/teams", { schema: {
12901
+ operationId: "listAgentServerOperatorTeams",
12902
+ tags: ["operator"],
12903
+ security: [{ agentServerToken: [] }],
12904
+ response: { 200: {
12905
+ type: "object",
12906
+ required: ["items"],
12907
+ properties: { items: {
12908
+ type: "array",
12909
+ items: {
12910
+ type: "object",
12911
+ required: ["id", "name"],
12912
+ properties: {
12913
+ id: {
12914
+ type: "string",
12915
+ format: "uuid"
12916
+ },
12917
+ name: { type: "string" }
12918
+ }
12919
+ }
12920
+ } }
12921
+ } }
12922
+ } }, async (request) => {
12923
+ return { items: (await requireNativeOrigin(requireAuthorizedOrigin, request, oauth)).listTeams() };
12924
+ });
12876
12925
  app.post("/v1/operator/cancel", { schema: {
12877
12926
  operationId: "cancelAgentServerOperatorApproval",
12878
12927
  tags: ["operator"],
@@ -14187,7 +14236,7 @@ async function writeCache(cache) {
14187
14236
  }
14188
14237
  //#endregion
14189
14238
  //#region src/version.ts
14190
- var DAEMON_VERSION = "0.64.0";
14239
+ var DAEMON_VERSION = "0.65.0";
14191
14240
  //#endregion
14192
14241
  //#region src/cli.ts
14193
14242
  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.0",
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/pi-runtime": "0.18.4",
90
+ "@themoltnet/sdk": "0.146.0"
91
91
  },
92
92
  "devDependencies": {
93
93
  "@fastify/swagger": "^9.6.1",
@@ -98,16 +98,16 @@
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/bootstrap": "0.1.0",
103
+ "@moltnet/crypto-service": "0.1.0",
105
104
  "@moltnet/execution-plan": "0.1.0",
106
- "@moltnet/observability": "0.1.0",
107
105
  "@moltnet/loopback-companion": "0.1.0",
106
+ "@moltnet/models": "0.1.0",
107
+ "@moltnet/tasks": "0.1.0",
108
108
  "@moltnet/runtime-profiles": "0.1.0",
109
- "@moltnet/crypto-service": "0.1.0",
110
- "@moltnet/tasks": "0.1.0"
109
+ "@moltnet/observability": "0.1.0",
110
+ "@moltnet/execution-integrations": "0.1.0"
111
111
  },
112
112
  "nx": {
113
113
  "projectType": "application",