@0xmaxma/claude-gateway 2.1.1 → 2.1.3
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/README.md +1 -1
- package/config.template.json +1 -1
- package/dist/agent/dreaming/index.d.ts +6 -0
- package/dist/agent/dreaming/index.d.ts.map +1 -1
- package/dist/agent/dreaming/index.js +3 -3
- package/dist/agent/dreaming/index.js.map +1 -1
- package/dist/agent/runner.d.ts +1 -1
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +9 -4
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/workspace-loader.d.ts +12 -0
- package/dist/agent/workspace-loader.d.ts.map +1 -1
- package/dist/agent/workspace-loader.js +34 -4
- package/dist/agent/workspace-loader.js.map +1 -1
- package/dist/api/cron-router.d.ts.map +1 -1
- package/dist/api/cron-router.js +3 -2
- package/dist/api/cron-router.js.map +1 -1
- package/dist/api/gateway-router.d.ts.map +1 -1
- package/dist/api/gateway-router.js +1 -1
- package/dist/api/gateway-router.js.map +1 -1
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +40 -5
- package/dist/api/router.js.map +1 -1
- package/dist/api/share-router.d.ts +1 -1
- package/dist/api/share-router.d.ts.map +1 -1
- package/dist/api/share-router.js +14 -5
- package/dist/api/share-router.js.map +1 -1
- package/dist/api/voice-call-router.d.ts.map +1 -1
- package/dist/api/voice-call-router.js +8 -5
- package/dist/api/voice-call-router.js.map +1 -1
- package/dist/api/voice-router.js +1 -1
- package/dist/api/voice-router.js.map +1 -1
- package/dist/api/voice-settings-router.d.ts.map +1 -1
- package/dist/api/voice-settings-router.js +15 -0
- package/dist/api/voice-settings-router.js.map +1 -1
- package/dist/apps/agent-manager.d.ts +17 -2
- package/dist/apps/agent-manager.d.ts.map +1 -1
- package/dist/apps/agent-manager.js +78 -4
- package/dist/apps/agent-manager.js.map +1 -1
- package/dist/apps/compose-generator.d.ts +8 -0
- package/dist/apps/compose-generator.d.ts.map +1 -1
- package/dist/apps/compose-generator.js +22 -3
- package/dist/apps/compose-generator.js.map +1 -1
- package/dist/apps/conversation-sandbox.d.ts +78 -0
- package/dist/apps/conversation-sandbox.d.ts.map +1 -0
- package/dist/apps/conversation-sandbox.js +357 -0
- package/dist/apps/conversation-sandbox.js.map +1 -0
- package/dist/apps/installer.d.ts +8 -3
- package/dist/apps/installer.d.ts.map +1 -1
- package/dist/apps/installer.js +89 -18
- package/dist/apps/installer.js.map +1 -1
- package/dist/apps/registry.d.ts +2 -0
- package/dist/apps/registry.d.ts.map +1 -1
- package/dist/build-provenance.json +4 -4
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +3 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/config/migrator.d.ts +2 -0
- package/dist/config/migrator.d.ts.map +1 -1
- package/dist/config/migrator.js +37 -1
- package/dist/config/migrator.js.map +1 -1
- package/dist/config/reload-policy.d.ts.map +1 -1
- package/dist/config/reload-policy.js +2 -0
- package/dist/config/reload-policy.js.map +1 -1
- package/dist/cron/manager.d.ts +15 -0
- package/dist/cron/manager.d.ts.map +1 -1
- package/dist/cron/manager.js +53 -1
- package/dist/cron/manager.js.map +1 -1
- package/dist/index.js +21 -9
- package/dist/index.js.map +1 -1
- package/dist/orchestration/bridge.d.ts +4 -0
- package/dist/orchestration/bridge.d.ts.map +1 -1
- package/dist/orchestration/bridge.js +25 -6
- package/dist/orchestration/bridge.js.map +1 -1
- package/dist/orchestration/capabilities.d.ts.map +1 -1
- package/dist/orchestration/capabilities.js +1 -0
- package/dist/orchestration/capabilities.js.map +1 -1
- package/dist/orchestration/config.js +1 -1
- package/dist/orchestration/config.js.map +1 -1
- package/dist/orchestration/container.d.ts.map +1 -1
- package/dist/orchestration/container.js +48 -1
- package/dist/orchestration/container.js.map +1 -1
- package/dist/orchestration/context-footprint.d.ts.map +1 -1
- package/dist/orchestration/context-footprint.js +1 -1
- package/dist/orchestration/context-footprint.js.map +1 -1
- package/dist/orchestration/delivery.d.ts.map +1 -1
- package/dist/orchestration/delivery.js +17 -8
- package/dist/orchestration/delivery.js.map +1 -1
- package/dist/orchestration/recovery.d.ts.map +1 -1
- package/dist/orchestration/recovery.js +27 -0
- package/dist/orchestration/recovery.js.map +1 -1
- package/dist/orchestration/report-promise.d.ts +9 -0
- package/dist/orchestration/report-promise.d.ts.map +1 -0
- package/dist/orchestration/report-promise.js +39 -0
- package/dist/orchestration/report-promise.js.map +1 -0
- package/dist/orchestration/restart-resume.d.ts +7 -1
- package/dist/orchestration/restart-resume.d.ts.map +1 -1
- package/dist/orchestration/restart-resume.js +22 -1
- package/dist/orchestration/restart-resume.js.map +1 -1
- package/dist/orchestration/runtime.d.ts +3 -0
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +53 -18
- package/dist/orchestration/runtime.js.map +1 -1
- package/dist/orchestration/store.d.ts +9 -0
- package/dist/orchestration/store.d.ts.map +1 -1
- package/dist/orchestration/store.js +13 -1
- package/dist/orchestration/store.js.map +1 -1
- package/dist/orchestration/tasks/driver.d.ts +1 -0
- package/dist/orchestration/tasks/driver.d.ts.map +1 -1
- package/dist/orchestration/tasks/driver.js +23 -3
- package/dist/orchestration/tasks/driver.js.map +1 -1
- package/dist/orchestration/tasks/service.d.ts +1 -3
- package/dist/orchestration/tasks/service.d.ts.map +1 -1
- package/dist/orchestration/tasks/service.js +5 -17
- package/dist/orchestration/tasks/service.js.map +1 -1
- package/dist/orchestration/telegram-speech.d.ts.map +1 -1
- package/dist/orchestration/telegram-speech.js +0 -2
- package/dist/orchestration/telegram-speech.js.map +1 -1
- package/dist/session/process.d.ts +15 -1
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +101 -15
- package/dist/session/process.js.map +1 -1
- package/dist/share/share-store.d.ts +10 -1
- package/dist/share/share-store.d.ts.map +1 -1
- package/dist/share/share-store.js +42 -1
- package/dist/share/share-store.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/voice-call-client.d.ts +27 -14
- package/dist/ui/voice-call-client.d.ts.map +1 -1
- package/dist/ui/voice-call-client.js +80 -24
- package/dist/ui/voice-call-client.js.map +1 -1
- package/dist/ui/voice-call-ui.d.ts +4 -1
- package/dist/ui/voice-call-ui.d.ts.map +1 -1
- package/dist/ui/voice-call-ui.js +65 -21
- package/dist/ui/voice-call-ui.js.map +1 -1
- package/dist/voice/errors.d.ts +1 -3
- package/dist/voice/errors.d.ts.map +1 -1
- package/dist/voice/errors.js +9 -4
- package/dist/voice/errors.js.map +1 -1
- package/dist/voice/notes.d.ts +4 -3
- package/dist/voice/notes.d.ts.map +1 -1
- package/dist/voice/notes.js +15 -11
- package/dist/voice/notes.js.map +1 -1
- package/dist/voice/telegram-avatar.d.ts +6 -2
- package/dist/voice/telegram-avatar.d.ts.map +1 -1
- package/dist/voice/telegram-avatar.js +23 -10
- package/dist/voice/telegram-avatar.js.map +1 -1
- package/dist/voice/turn-manager.d.ts.map +1 -1
- package/dist/voice/turn-manager.js +1 -1
- package/dist/voice/turn-manager.js.map +1 -1
- package/dist/voice/types.d.ts +3 -0
- package/dist/voice/types.d.ts.map +1 -1
- package/dist/voice/types.js +4 -0
- package/dist/voice/types.js.map +1 -1
- package/mcp/modules.ts +13 -1
- package/mcp/tools/api/module.ts +9 -1
- package/mcp/tools/apps/skills/create-app-yaml/SKILL.md +1 -1
- package/mcp/tools/discord/module.ts +44 -11
- package/mcp/tools/line/module.ts +11 -0
- package/mcp/tools/memory/disable-archive.test.ts +47 -0
- package/mcp/tools/memory/module.ts +2 -1
- package/mcp/tools/shared/isolate.ts +77 -0
- package/mcp/tools/shared/share-client.ts +15 -1
- package/mcp/tools/slack/module.ts +12 -5
- package/mcp/tools/telegram/attachment-log.ts +39 -0
- package/mcp/tools/telegram/module.ts +27 -11
- package/mcp/tools/telegram/receiver-server.ts +8 -0
- package/mcp/tools/wechat/module.ts +2 -0
- package/mcp/tools/whatsapp/module.ts +8 -1
- package/mcp/tools/whatsapp-cloud/module.ts +14 -7
- package/package.json +1 -1
package/dist/apps/installer.js
CHANGED
|
@@ -39,11 +39,13 @@ exports.commonAncestorDir = commonAncestorDir;
|
|
|
39
39
|
exports.parseComposePs = parseComposePs;
|
|
40
40
|
exports.mapContainerStatesToAppStatus = mapContainerStatesToAppStatus;
|
|
41
41
|
const fs = __importStar(require("node:fs"));
|
|
42
|
+
const conversation_sandbox_1 = require("./conversation-sandbox");
|
|
42
43
|
const path = __importStar(require("node:path"));
|
|
43
44
|
const os = __importStar(require("node:os"));
|
|
44
45
|
const crypto = __importStar(require("node:crypto"));
|
|
45
46
|
const node_child_process_1 = require("node:child_process");
|
|
46
47
|
const compose_generator_1 = require("./compose-generator");
|
|
48
|
+
const agent_manager_1 = require("./agent-manager");
|
|
47
49
|
const cleanup_1 = require("../history/cleanup");
|
|
48
50
|
const config_num_1 = require("../utils/config-num");
|
|
49
51
|
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
@@ -103,6 +105,20 @@ const APP_NAME_RE = /^[a-z0-9][a-z0-9-]{1,63}$/;
|
|
|
103
105
|
* scheduler at boot — config is untrusted input, so a typo must degrade to UTC,
|
|
104
106
|
* never crash the gateway.
|
|
105
107
|
*/
|
|
108
|
+
/** How app.yaml changes the app's agent registration, or null when name, path and presence all match. */
|
|
109
|
+
function agentIdentityChange(oldAgent, newAgent) {
|
|
110
|
+
if (!oldAgent && newAgent)
|
|
111
|
+
return `adds agent "${newAgent.name}"`;
|
|
112
|
+
if (oldAgent && !newAgent)
|
|
113
|
+
return `removes agent "${oldAgent.name}"`;
|
|
114
|
+
if (!oldAgent || !newAgent)
|
|
115
|
+
return null;
|
|
116
|
+
if (oldAgent.name !== newAgent.name)
|
|
117
|
+
return `renames agent "${oldAgent.name}" to "${newAgent.name}"`;
|
|
118
|
+
if (path.posix.resolve('/', oldAgent.path) !== path.posix.resolve('/', newAgent.path))
|
|
119
|
+
return `moves agent "${newAgent.name}" from ${oldAgent.path} to ${newAgent.path}`;
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
106
122
|
function isValidTimezone(tz) {
|
|
107
123
|
if (typeof tz !== 'string' || tz.length === 0)
|
|
108
124
|
return false;
|
|
@@ -454,6 +470,9 @@ class AppInstaller {
|
|
|
454
470
|
console.warn(`[apps] auto-backup before uninstall of "${appName}" failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
|
|
455
471
|
}
|
|
456
472
|
}
|
|
473
|
+
// Conversation sandboxes (#609) are not compose services, and their containers hold
|
|
474
|
+
// the agent image that `down --rmi all` removes.
|
|
475
|
+
await conversation_sandbox_1.sandboxPool.removeFor(`${appName}-agent`).catch(() => { });
|
|
457
476
|
// docker compose down --rmi all (graceful fallback if dir is already gone)
|
|
458
477
|
if (fs.existsSync(appDir)) {
|
|
459
478
|
try {
|
|
@@ -806,8 +825,12 @@ class AppInstaller {
|
|
|
806
825
|
// Restore config that carries generated secrets, so the app boots with the
|
|
807
826
|
// same credentials the volume data was created under.
|
|
808
827
|
this.copyIfExists(path.join(staging, 'config', '.env'), path.join(appDir, '.env'));
|
|
828
|
+
if (entry.agentDeclaration)
|
|
829
|
+
(0, agent_manager_1.writeAgentEnvFile)(appDir, entry.agentDeclaration);
|
|
809
830
|
log(`Starting "${appName}" on restored data`);
|
|
810
|
-
|
|
831
|
+
// Recreate: compose does not notice a changed env_file, so a plain `up`
|
|
832
|
+
// would restart the containers with the pre-restore .env/.env.agent.
|
|
833
|
+
await this.composeUp(appName, appDir, undefined, { forceRecreate: true });
|
|
811
834
|
await this.registry.updateStatus(appName, 'running').catch(() => { });
|
|
812
835
|
log(`Restore of "${backupId}" complete`);
|
|
813
836
|
return {
|
|
@@ -1555,6 +1578,7 @@ class AppInstaller {
|
|
|
1555
1578
|
if (generated.agentDeclaration && this.agentManager && agentPaths) {
|
|
1556
1579
|
await this.agentManager.injectAgentService(entry);
|
|
1557
1580
|
this.log(job, `Agent service injected for ${generated.agentDeclaration.name}`);
|
|
1581
|
+
this.logAgentEnv(job, generated.agentDeclaration);
|
|
1558
1582
|
// Pre-pull the agent base image so compose up --wait doesn't time out during pull
|
|
1559
1583
|
this.log(job, 'Pre-pulling agent base image');
|
|
1560
1584
|
try {
|
|
@@ -1726,6 +1750,7 @@ class AppInstaller {
|
|
|
1726
1750
|
};
|
|
1727
1751
|
if (generated.agentDeclaration && this.agentManager && agentPaths) {
|
|
1728
1752
|
await this.agentManager.injectAgentService(newEntry);
|
|
1753
|
+
this.logAgentEnv(job, generated.agentDeclaration);
|
|
1729
1754
|
}
|
|
1730
1755
|
// Pin the images the app is running before the build takes their tags
|
|
1731
1756
|
// over. A `build:` service's new image reuses the old tag
|
|
@@ -1763,6 +1788,7 @@ class AppInstaller {
|
|
|
1763
1788
|
// The new compose file's bind sources are anchored to finalDir. Starting
|
|
1764
1789
|
// before this swap would bind the old directory inode then delete it.
|
|
1765
1790
|
this.log(job, 'Stopping old containers');
|
|
1791
|
+
await conversation_sandbox_1.sandboxPool.removeFor(`${appName}-agent`).catch(() => { });
|
|
1766
1792
|
this.run(['docker', 'compose', '-p', appName, 'down'], entry.installPath, 120000);
|
|
1767
1793
|
this.log(job, 'Swapping app directories');
|
|
1768
1794
|
const finalDir = entry.installPath;
|
|
@@ -1994,9 +2020,10 @@ class AppInstaller {
|
|
|
1994
2020
|
/**
|
|
1995
2021
|
* Reconfigure an installed app: merge env vars and/or override host ports,
|
|
1996
2022
|
* then force-recreate the container in place. No clone, no dir swap — the app
|
|
1997
|
-
* stays at its current commit/appDir; only its .env
|
|
1998
|
-
* compose port mappings
|
|
1999
|
-
* this is an `up --force-recreate`,
|
|
2023
|
+
* stays at its current commit/appDir; only its .env, (optionally) its
|
|
2024
|
+
* compose port mappings and its agent's memory settings change. Named
|
|
2025
|
+
* volumes and their data survive because this is an `up --force-recreate`,
|
|
2026
|
+
* never a `down -v`.
|
|
2000
2027
|
*/
|
|
2001
2028
|
async runReconfigure(job, appName, options) {
|
|
2002
2029
|
job.status = 'running';
|
|
@@ -2021,11 +2048,12 @@ class AppInstaller {
|
|
|
2021
2048
|
// Snapshot the current on-disk state BEFORE any mutation so a failed
|
|
2022
2049
|
// recreate can be rolled back. Both an env-only and a port change rewrite
|
|
2023
2050
|
// .env and force-recreate the container; a port change additionally rewrites
|
|
2024
|
-
// the live compose file and swaps proxy routes
|
|
2051
|
+
// the live compose file and swaps proxy routes, and an app agent's service is
|
|
2052
|
+
// re-injected into it. If the new container never
|
|
2025
2053
|
// comes up the app would otherwise be left down (or, for a port change,
|
|
2026
2054
|
// unreachable with routes gone and compose/registry mismatched).
|
|
2027
2055
|
const envPath = path.join(appDir, '.env');
|
|
2028
|
-
const oldComposeContent =
|
|
2056
|
+
const oldComposeContent = fs.existsSync(composePath) ? fs.readFileSync(composePath, 'utf-8') : null;
|
|
2029
2057
|
const oldEnvContent = fs.existsSync(envPath) ? fs.readFileSync(envPath, 'utf-8') : null;
|
|
2030
2058
|
const oldPorts = entry.ports;
|
|
2031
2059
|
// Compute (and validate) the port metadata. Always generate to a TEMP file
|
|
@@ -2046,6 +2074,16 @@ class AppInstaller {
|
|
|
2046
2074
|
fs.rmSync(tmpCompose, { force: true });
|
|
2047
2075
|
}
|
|
2048
2076
|
}
|
|
2077
|
+
// Reconfigure applies the agent's settings but not its identity: a renamed,
|
|
2078
|
+
// moved, added or removed agent needs the deregister/re-register that only
|
|
2079
|
+
// update and install do. Refuse before anything is touched.
|
|
2080
|
+
const oldAgent = entry.agentDeclaration ?? null;
|
|
2081
|
+
const newAgent = generated.agentDeclaration;
|
|
2082
|
+
const agentChange = agentIdentityChange(oldAgent, newAgent);
|
|
2083
|
+
if (agentChange) {
|
|
2084
|
+
throw new Error(`app.yaml for "${appName}" ${agentChange} — reconfigure cannot change the agent registration; use update or reinstall instead`);
|
|
2085
|
+
}
|
|
2086
|
+
const nextEntry = newAgent ? { ...entry, agentDeclaration: newAgent } : entry;
|
|
2049
2087
|
// Host-port collision across other installed apps (only if ports changed).
|
|
2050
2088
|
// Runs before the live compose is touched, so a collision leaves nothing to
|
|
2051
2089
|
// undo on disk.
|
|
@@ -2062,14 +2100,12 @@ class AppInstaller {
|
|
|
2062
2100
|
try {
|
|
2063
2101
|
// Swap in the newly-generated compose only now that we're inside the
|
|
2064
2102
|
// guard (finding F2). Regenerating drops the injected agent service, so we
|
|
2065
|
-
// re-inject it. An env-only reconfigure
|
|
2103
|
+
// re-inject it. An env-only reconfigure re-injects it too when the agent
|
|
2104
|
+
// was injected (it has agentPaths), so an agent service from before #618
|
|
2105
|
+
// stops reading the app's full .env.
|
|
2066
2106
|
if (hasPortChange) {
|
|
2067
2107
|
this.log(job, 'Updating docker-compose.yml');
|
|
2068
2108
|
fs.writeFileSync(composePath, newComposeContent);
|
|
2069
|
-
if (generated.agentDeclaration && this.agentManager) {
|
|
2070
|
-
const agentPaths = entry.agentPaths ?? this.agentManager.detectAgentPaths();
|
|
2071
|
-
await this.agentManager.injectAgentService({ ...entry, agentPaths });
|
|
2072
|
-
}
|
|
2073
2109
|
}
|
|
2074
2110
|
// Merge the new env vars onto the existing .env: keys not supplied are
|
|
2075
2111
|
// preserved, and existing generated-secret values are carried over rather
|
|
@@ -2077,6 +2113,12 @@ class AppInstaller {
|
|
|
2077
2113
|
this.log(job, 'Writing .env');
|
|
2078
2114
|
const mergedEnv = { ...this.readEnvFile(appDir), ...(options.envVars ?? {}) };
|
|
2079
2115
|
this.writeEnvFile(appDir, appName, generated, mergedEnv);
|
|
2116
|
+
// After .env: injecting rewrites .env.agent from it.
|
|
2117
|
+
if (newAgent && this.agentManager && (hasPortChange || entry.agentPaths)) {
|
|
2118
|
+
const agentPaths = entry.agentPaths ?? this.agentManager.detectAgentPaths();
|
|
2119
|
+
await this.agentManager.injectAgentService({ ...nextEntry, agentPaths });
|
|
2120
|
+
this.logAgentEnv(job, newAgent);
|
|
2121
|
+
}
|
|
2080
2122
|
// Deregister old proxy routes before the port mapping changes (the proxy is
|
|
2081
2123
|
// bound to the old hostPort).
|
|
2082
2124
|
if (hasPortChange) {
|
|
@@ -2087,11 +2129,10 @@ class AppInstaller {
|
|
|
2087
2129
|
// `up`, not a `down -v`, so named volumes (and their data) survive.
|
|
2088
2130
|
this.log(job, 'Recreating container');
|
|
2089
2131
|
await this.composeUp(appName, appDir, job, { forceRecreate: true });
|
|
2090
|
-
|
|
2091
|
-
//
|
|
2092
|
-
//
|
|
2093
|
-
|
|
2094
|
-
const updatedEntry = { ...entry, updatedAt: new Date().toISOString() };
|
|
2132
|
+
// Persist the reconfigure: the container is up again (an app reconfigured
|
|
2133
|
+
// while stopped or errored is now running), updatedAt is bumped, and the
|
|
2134
|
+
// port mappings + proxy routes are refreshed only when a host port changed.
|
|
2135
|
+
const updatedEntry = { ...nextEntry, status: 'running', updatedAt: new Date().toISOString() };
|
|
2095
2136
|
if (hasPortChange) {
|
|
2096
2137
|
updatedEntry.ports = generated.ports.map((p) => ({
|
|
2097
2138
|
name: p.name,
|
|
@@ -2121,9 +2162,17 @@ class AppInstaller {
|
|
|
2121
2162
|
fs.writeFileSync(envPath, oldEnvContent, { mode: 0o600 });
|
|
2122
2163
|
fs.chmodSync(envPath, 0o600);
|
|
2123
2164
|
}
|
|
2124
|
-
if (
|
|
2165
|
+
if (oldComposeContent !== null) {
|
|
2125
2166
|
fs.writeFileSync(composePath, oldComposeContent);
|
|
2126
2167
|
}
|
|
2168
|
+
if (oldAgent) {
|
|
2169
|
+
try {
|
|
2170
|
+
(0, agent_manager_1.writeAgentEnvFile)(appDir, oldAgent);
|
|
2171
|
+
}
|
|
2172
|
+
catch (envErr) {
|
|
2173
|
+
this.log(job, `Could not restore .env.agent: ${envErr.message}`);
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2127
2176
|
await this.composeUp(appName, appDir, job, { forceRecreate: true });
|
|
2128
2177
|
if (hasPortChange) {
|
|
2129
2178
|
this.callbacks.registerRoutes(appName, oldPorts.map((p) => ({
|
|
@@ -2142,6 +2191,22 @@ class AppInstaller {
|
|
|
2142
2191
|
}
|
|
2143
2192
|
throw reconfErr;
|
|
2144
2193
|
}
|
|
2194
|
+
// Write the declared isolate_memory/disable_archive into the agent's
|
|
2195
|
+
// config.json entry. When they differ from what the agent runs with, the
|
|
2196
|
+
// config watcher replaces its runner once idle, as after an update.
|
|
2197
|
+
if (newAgent && this.agentManager) {
|
|
2198
|
+
let synced;
|
|
2199
|
+
try {
|
|
2200
|
+
synced = await this.agentManager.syncMemoryModes(nextEntry);
|
|
2201
|
+
}
|
|
2202
|
+
catch (err) {
|
|
2203
|
+
// apps.json already holds the new modes; gateway start applies them from there.
|
|
2204
|
+
throw new Error(`Reconfigure applied, but agent "${newAgent.name}" config entry was not updated (${err.message}) — its memory settings take effect at the next gateway start`);
|
|
2205
|
+
}
|
|
2206
|
+
this.log(job, synced
|
|
2207
|
+
? `Agent "${newAgent.name}" memory settings written — a changed isolate_memory or disable_archive applies once the agent is idle`
|
|
2208
|
+
: `Agent "${newAgent.name}" is not registered — its memory settings apply at the next gateway start`);
|
|
2209
|
+
}
|
|
2145
2210
|
const proxyUrls = {};
|
|
2146
2211
|
for (const p of generated.ports) {
|
|
2147
2212
|
proxyUrls[p.name] = `/app/${appName}/${p.name}/`;
|
|
@@ -2151,7 +2216,7 @@ class AppInstaller {
|
|
|
2151
2216
|
appName,
|
|
2152
2217
|
proxyUrls,
|
|
2153
2218
|
secretKeys: generated.secretKeys,
|
|
2154
|
-
agentDeclaration:
|
|
2219
|
+
agentDeclaration: newAgent,
|
|
2155
2220
|
};
|
|
2156
2221
|
job.updatedAt = Date.now();
|
|
2157
2222
|
this.log(job, `Reconfigure complete: ${JSON.stringify(proxyUrls)}`);
|
|
@@ -2240,6 +2305,12 @@ class AppInstaller {
|
|
|
2240
2305
|
}
|
|
2241
2306
|
return generatedNames;
|
|
2242
2307
|
}
|
|
2308
|
+
/** Say which app secrets the agent container gets: an agent from before #618 had them all. */
|
|
2309
|
+
logAgentEnv(job, declaration) {
|
|
2310
|
+
this.log(job, declaration.env?.length
|
|
2311
|
+
? `Agent container gets app secrets: ${declaration.env.join(', ')}`
|
|
2312
|
+
: 'Agent container gets no app secrets (app.yaml services.agent.env is not set)');
|
|
2313
|
+
}
|
|
2243
2314
|
/** Parse an app's existing .env into a key→value map (empty if absent). */
|
|
2244
2315
|
readEnvFile(appDir) {
|
|
2245
2316
|
const envPath = path.join(appDir, '.env');
|