@themoltnet/agent-daemon 0.49.1 → 0.51.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.
package/dist/main.js CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { defaultPiDaemonAdapter } from "./pi.js";
3
- import { runAgentDaemonCli } from "./cli.js";
4
- import { createRequire } from "node:module";
3
+ import { n as loadDaemonRuntimeAdapter, runAgentDaemonCli, t as extractRuntimeModule } from "./cli.js";
5
4
  import { registerInstrumentations } from "@opentelemetry/instrumentation";
6
5
  import { DnsInstrumentation } from "@opentelemetry/instrumentation-dns";
7
6
  import { HttpInstrumentation } from "@opentelemetry/instrumentation-http";
@@ -9,8 +8,6 @@ import { NetInstrumentation } from "@opentelemetry/instrumentation-net";
9
8
  import { PgInstrumentation } from "@opentelemetry/instrumentation-pg";
10
9
  import { PinoInstrumentation } from "@opentelemetry/instrumentation-pino";
11
10
  import { UndiciInstrumentation } from "@opentelemetry/instrumentation-undici";
12
- import { isAbsolute, resolve } from "node:path";
13
- import { pathToFileURL } from "node:url";
14
11
  //#region ../../libs/observability/src/instrumentation.ts
15
12
  /**
16
13
  * Register OTel auto-instrumentation for common Node.js modules.
@@ -90,7 +87,7 @@ initInstrumentation({
90
87
  });
91
88
  //#endregion
92
89
  //#region src/lib/supervisor-parent-guard.ts
93
- /** Exit a supervised run when its serve parent's IPC channel disappears. */
90
+ /** Exit a supervised run when its Agent Server parent's IPC channel disappears. */
94
91
  function installSupervisorParentGuard(proc = process) {
95
92
  if (proc.env["MOLTNET_SUPERVISED_RUN"] !== "1" || typeof proc.disconnect !== "function") return false;
96
93
  if (proc.connected === false) {
@@ -101,70 +98,6 @@ function installSupervisorParentGuard(proc = process) {
101
98
  return true;
102
99
  }
103
100
  //#endregion
104
- //#region src/runtime-loader.ts
105
- function extractRuntimeModule(argv) {
106
- const remaining = [];
107
- let specifier;
108
- let parsingOptions = true;
109
- for (let index = 0; index < argv.length; index += 1) {
110
- const argument = argv[index];
111
- if (argument === "--") {
112
- parsingOptions = false;
113
- remaining.push(argument);
114
- continue;
115
- }
116
- if (!parsingOptions) {
117
- remaining.push(argument);
118
- continue;
119
- }
120
- let candidate;
121
- if (argument === "--runtime") {
122
- candidate = argv[index + 1];
123
- if (!candidate) throw new Error("Missing value for --runtime");
124
- index += 1;
125
- } else if (argument.startsWith("--runtime=")) {
126
- candidate = argument.slice(10);
127
- if (!candidate) throw new Error("Missing value for --runtime");
128
- } else {
129
- remaining.push(argument);
130
- continue;
131
- }
132
- if (specifier) throw new Error("--runtime may be specified only once");
133
- specifier = candidate;
134
- }
135
- return {
136
- argv: remaining,
137
- specifier
138
- };
139
- }
140
- function resolveRuntimeModuleUrl(specifier, cwd = process.cwd()) {
141
- if (specifier.startsWith("file:")) return new URL(specifier).href;
142
- if (isAbsolute(specifier) || specifier.startsWith("./") || specifier.startsWith("../")) return pathToFileURL(resolve(cwd, specifier)).href;
143
- return pathToFileURL(createRequire(resolve(cwd, "package.json")).resolve(specifier)).href;
144
- }
145
- async function loadDaemonRuntimeAdapter(specifier, options = {}) {
146
- let moduleUrl;
147
- try {
148
- moduleUrl = resolveRuntimeModuleUrl(specifier, options.cwd);
149
- } catch (cause) {
150
- throw new Error(`Unable to resolve runtime module "${specifier}" from ${options.cwd ?? process.cwd()}`, { cause });
151
- }
152
- let namespace;
153
- try {
154
- namespace = await import(moduleUrl);
155
- } catch (cause) {
156
- throw new Error(`Unable to load runtime module "${specifier}"`, { cause });
157
- }
158
- const adapter = namespace.default;
159
- if (!isDaemonRuntimeAdapter(adapter)) throw new Error(`Runtime module "${specifier}" must default-export a DaemonRuntimeAdapter`);
160
- return adapter;
161
- }
162
- function isDaemonRuntimeAdapter(value) {
163
- if (!value || typeof value !== "object") return false;
164
- const candidate = value;
165
- return typeof candidate.runtimeKind === "string" && candidate.runtimeKind.length > 0 && typeof candidate.prepare === "function";
166
- }
167
- //#endregion
168
101
  //#region src/main.ts
169
102
  installSupervisorParentGuard();
170
103
  async function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@themoltnet/agent-daemon",
3
- "version": "0.49.1",
3
+ "version": "0.51.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.",
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@earendil-works/gondolin": "^0.12.0",
51
- "@earendil-works/pi-ai": "0.79.4",
52
- "@earendil-works/pi-coding-agent": "0.79.4",
51
+ "@earendil-works/pi-ai": "0.84.4",
52
+ "@earendil-works/pi-coding-agent": "0.84.4",
53
53
  "@fastify/cors": "^11.0.0",
54
54
  "@fastify/helmet": "^13.0.1",
55
55
  "@fastify/otel": "^0.18.0",
@@ -84,11 +84,12 @@
84
84
  "proper-lockfile": "4.1.2",
85
85
  "typebox": "^1.2.8",
86
86
  "@themoltnet/agent-runtime": "0.45.2",
87
- "@themoltnet/os-keyring": "0.3.0",
88
87
  "@themoltnet/pi-runtime": "0.14.1",
88
+ "@themoltnet/os-keyring": "0.3.0",
89
89
  "@themoltnet/sdk": "0.140.0"
90
90
  },
91
91
  "devDependencies": {
92
+ "@fastify/swagger": "^9.6.1",
92
93
  "@types/proper-lockfile": "^4.1.4",
93
94
  "tsx": "^4.7.0",
94
95
  "typescript": "~5.9.2",
@@ -96,15 +97,15 @@
96
97
  "vite-plugin-dts": "^4.5.4",
97
98
  "vitest": "^3.0.0",
98
99
  "@moltnet/agent-eval": "0.1.0",
100
+ "@moltnet/bootstrap": "0.1.0",
99
101
  "@moltnet/crypto-service": "0.1.0",
100
- "@moltnet/execution-integrations": "0.1.0",
101
102
  "@moltnet/execution-plan": "0.1.0",
102
- "@moltnet/bootstrap": "0.1.0",
103
+ "@moltnet/execution-integrations": "0.1.0",
104
+ "@moltnet/models": "0.1.0",
103
105
  "@moltnet/loopback-companion": "0.1.0",
106
+ "@moltnet/tasks": "0.1.0",
104
107
  "@moltnet/observability": "0.1.0",
105
- "@moltnet/models": "0.1.0",
106
- "@moltnet/runtime-profiles": "0.1.0",
107
- "@moltnet/tasks": "0.1.0"
108
+ "@moltnet/runtime-profiles": "0.1.0"
108
109
  },
109
110
  "nx": {
110
111
  "projectType": "application",
@@ -114,6 +115,11 @@
114
115
  "platform:cli"
115
116
  ],
116
117
  "targets": {
118
+ "generate:openapi": {
119
+ "outputs": [
120
+ "{projectRoot}/openapi.json"
121
+ ]
122
+ },
117
123
  "bundle": {
118
124
  "executor": "nx:run-commands",
119
125
  "cache": false,
@@ -132,6 +138,7 @@
132
138
  "dev": "tsx watch src/main.ts",
133
139
  "start": "node dist/main.js",
134
140
  "build": "vite build",
141
+ "generate:openapi": "tsx scripts/generate-openapi.ts",
135
142
  "check:pack": "tsx ../../tools/src/check-pack.ts --package . && pnpm run smoke:pack",
136
143
  "smoke:pack": "tsx ../../tools/src/smoke-pack.ts --package . --local-dependency ../../libs/sdk --local-dependency ../../libs/os-keyring --local-dependency ../../libs/agent-runtime --local-dependency ../../libs/shell-command-analyzer --local-dependency ../../libs/pi-runtime --copy-file test-fixtures/runtime-adapter.mjs runtime-adapter.mjs --probe-file test-fixtures/keyring-pack-probe.mjs keyring-pack-probe.mjs --bin moltnet-agent --args --runtime ./runtime-adapter.mjs --help --expect \"long-running task worker for MoltNet\""
137
144
  }