loopengine 0.1.74 → 0.1.75
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/core/discover-agents.d.ts +0 -20
- package/dist/core/discover-agents.js +37 -12
- package/dist/core/trusted-proxy.d.ts +6 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/version.js +24 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/web/console-shell.js +24 -1
- package/dist/web/dev-ui-styles.js +5 -0
- package/dist/web/global-config-page.js +43 -1
- package/package.json +3 -1
|
@@ -5,26 +5,6 @@ export interface AgentModule {
|
|
|
5
5
|
/** Factory, not a shared instance — a fresh ModelCall per request/session. */
|
|
6
6
|
createModelCall: () => ModelCall;
|
|
7
7
|
}
|
|
8
|
-
/** Builds a lazy, memoized createModelCall from AgentConfig.model, for a
|
|
9
|
-
* module that doesn't export its own — see that field's own doc comment.
|
|
10
|
-
* The provider's SDK module is imported here, eagerly, but that's cheap
|
|
11
|
-
* and safe with no API key at all: importing model-calls/*.ts only
|
|
12
|
-
* defines functions, it never constructs a client at module top level
|
|
13
|
-
* (see e.g. createAnthropicModelCall's own body) — so this can't fail
|
|
14
|
-
* discovery the way eagerly building the actual client would. The real
|
|
15
|
-
* client is only built the first time the returned function is actually
|
|
16
|
-
* called, and reused after that, the same "don't crash the whole server
|
|
17
|
-
* over one agent's missing API key, don't rebuild per call" reasoning
|
|
18
|
-
* agents/customer-service/index.ts's own hand-written createModelCall
|
|
19
|
-
* used before this existed.
|
|
20
|
-
*
|
|
21
|
-
* Exported so a caller updating an *already-registered* agent's model
|
|
22
|
-
* (see agent-file-admin.ts's editAgentFile, applied live via
|
|
23
|
-
* core/agent-registry.ts's updateAgent) can rebuild just this one closure
|
|
24
|
-
* without re-importing the whole module — Node's ESM loader caches an
|
|
25
|
-
* already-imported module forever, so there's no supported way to
|
|
26
|
-
* re-import a changed agent file's own createModelCall directly; this is
|
|
27
|
-
* the one piece of it that's meaningfully regenerable on its own. */
|
|
28
8
|
export declare function synthesizeCreateModelCall(model: AgentModelConfig): Promise<() => ModelCall>;
|
|
29
9
|
/** Imports one agent module at `path` and resolves it to an AgentModule —
|
|
30
10
|
* the single-file version of what discoverAgents does over a whole
|
|
@@ -37,30 +37,55 @@ function isRawAgentModule(mod) {
|
|
|
37
37
|
* already-imported module forever, so there's no supported way to
|
|
38
38
|
* re-import a changed agent file's own createModelCall directly; this is
|
|
39
39
|
* the one piece of it that's meaningfully regenerable on its own. */
|
|
40
|
+
// The env var each provider's key defaults to (same names as
|
|
41
|
+
// web/global-config.ts's Models page).
|
|
42
|
+
const PROVIDER_KEY_ENV = {
|
|
43
|
+
anthropic: 'ANTHROPIC_API_KEY',
|
|
44
|
+
openai: 'OPENAI_API_KEY',
|
|
45
|
+
deepseek: 'DEEPSEEK_API_KEY',
|
|
46
|
+
kimi: 'MOONSHOT_API_KEY',
|
|
47
|
+
glm: 'GLM_API_KEY',
|
|
48
|
+
gemini: 'GEMINI_API_KEY',
|
|
49
|
+
};
|
|
40
50
|
export async function synthesizeCreateModelCall(model) {
|
|
41
|
-
let
|
|
51
|
+
let build;
|
|
42
52
|
if (model.provider === 'anthropic') {
|
|
43
53
|
const { createAnthropicModelCall } = await import('./model-calls/anthropic-model-call.js');
|
|
44
|
-
|
|
54
|
+
build = () => createAnthropicModelCall(model);
|
|
45
55
|
}
|
|
46
|
-
if (model.provider === 'openai') {
|
|
56
|
+
else if (model.provider === 'openai') {
|
|
47
57
|
const { createOpenAIModelCall } = await import('./model-calls/openai-model-call.js');
|
|
48
|
-
|
|
58
|
+
build = () => createOpenAIModelCall(model);
|
|
49
59
|
}
|
|
50
|
-
if (model.provider === 'deepseek') {
|
|
60
|
+
else if (model.provider === 'deepseek') {
|
|
51
61
|
const { createDeepSeekModelCall } = await import('./model-calls/deepseek-model-call.js');
|
|
52
|
-
|
|
62
|
+
build = () => createDeepSeekModelCall(model);
|
|
53
63
|
}
|
|
54
|
-
if (model.provider === 'kimi') {
|
|
64
|
+
else if (model.provider === 'kimi') {
|
|
55
65
|
const { createKimiModelCall } = await import('./model-calls/kimi-model-call.js');
|
|
56
|
-
|
|
66
|
+
build = () => createKimiModelCall(model);
|
|
57
67
|
}
|
|
58
|
-
if (model.provider === 'glm') {
|
|
68
|
+
else if (model.provider === 'glm') {
|
|
59
69
|
const { createGlmModelCall } = await import('./model-calls/glm-model-call.js');
|
|
60
|
-
|
|
70
|
+
build = () => createGlmModelCall(model);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const { createGeminiModelCall } = await import('./model-calls/gemini-model-call.js');
|
|
74
|
+
build = () => createGeminiModelCall(model);
|
|
61
75
|
}
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
// Rebuilt when the key it was built with changes, so a key saved or
|
|
77
|
+
// replaced on the console's Models page applies to the next call
|
|
78
|
+
// without a restart. An explicit `apiKey` in the config never changes.
|
|
79
|
+
let cached;
|
|
80
|
+
let cachedKey;
|
|
81
|
+
return () => {
|
|
82
|
+
const key = model.apiKey ?? process.env[PROVIDER_KEY_ENV[model.provider]];
|
|
83
|
+
if (!cached || key !== cachedKey) {
|
|
84
|
+
cached = build();
|
|
85
|
+
cachedKey = key;
|
|
86
|
+
}
|
|
87
|
+
return cached;
|
|
88
|
+
};
|
|
64
89
|
}
|
|
65
90
|
/** Resolves one directory entry to an agent module's path, or undefined if
|
|
66
91
|
* this entry isn't one — a `.ts`/`.js` file directly (the common case), or
|
|
@@ -4,6 +4,12 @@ export interface ProxyIdentity {
|
|
|
4
4
|
sub: string;
|
|
5
5
|
workspace?: string;
|
|
6
6
|
role: string;
|
|
7
|
+
/** The person's email, when the proxy knows it (shown in the console's
|
|
8
|
+
* sidebar). */
|
|
9
|
+
email?: string;
|
|
10
|
+
/** Where the person manages this workspace on the host, shown as the
|
|
11
|
+
* console's "Dashboard" link. */
|
|
12
|
+
dashboardUrl?: string;
|
|
7
13
|
/** Expiry, Unix seconds. */
|
|
8
14
|
exp: number;
|
|
9
15
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loopengineVersion(): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// The installed loopengine version, for the console's Settings section.
|
|
2
|
+
// package.json sits one level above core/ in this repo, and two above
|
|
3
|
+
// dist/core/ in the published package (dist/package.json is only the
|
|
4
|
+
// module-resolution stub the build writes, with no version).
|
|
5
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
6
|
+
let cached;
|
|
7
|
+
export function loopengineVersion() {
|
|
8
|
+
if (cached)
|
|
9
|
+
return cached;
|
|
10
|
+
for (const rel of ['../package.json', '../../package.json']) {
|
|
11
|
+
const url = new URL(rel, import.meta.url);
|
|
12
|
+
if (!existsSync(url))
|
|
13
|
+
continue;
|
|
14
|
+
try {
|
|
15
|
+
const pkg = JSON.parse(readFileSync(url, 'utf8'));
|
|
16
|
+
if (pkg.name === 'loopengine' && pkg.version)
|
|
17
|
+
return (cached = pkg.version);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Not loopengine's package.json; try the next.
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return (cached = 'unknown');
|
|
24
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ export type { InstalledAbilityRecord, AbilityEnvDecl, UpgradeFileResult } from '
|
|
|
78
78
|
export { searchPublicAbilities, fetchLatestAbilityVersion } from './web/abilities-admin.js';
|
|
79
79
|
export type { PublicAbilitySearchResult } from './web/abilities-admin.js';
|
|
80
80
|
export { describeModelProviders, describeGateways, setModelProviderKey, clearModelProviderKey, ModelKeyError } from './web/global-config.js';
|
|
81
|
+
export { loopengineVersion } from './core/version.js';
|
|
81
82
|
export type { ModelProviderInfo, AgentModelUsage, ModelsView, GatewayProviderInfo, GatewaysView } from './web/global-config.js';
|
|
82
83
|
export { createTrackedApprover, listApprovals, decideApproval, findApproval } from './web/web-approver.js';
|
|
83
84
|
export { scaffoldAgent, scaffoldSubagent, AgentNameError, AgentExistsError, AgentNotFoundError, AgentModelError } from './bin/cli.js';
|
package/dist/index.js
CHANGED
|
@@ -69,5 +69,6 @@ export { readActauthConfig, addActauthRule, updateActauthRule, removeActauthRule
|
|
|
69
69
|
export { installAbility, upgradeAbility, removeAbility, listInstalledAbilities, backfillDependencies, AbilityManifestError, AbilityVersionError, AbilityCollisionError, AbilityAlreadyInstalledError, AbilityNotInstalledError, } from './bin/ability-manager.js';
|
|
70
70
|
export { searchPublicAbilities, fetchLatestAbilityVersion } from './web/abilities-admin.js';
|
|
71
71
|
export { describeModelProviders, describeGateways, setModelProviderKey, clearModelProviderKey, ModelKeyError } from './web/global-config.js';
|
|
72
|
+
export { loopengineVersion } from './core/version.js';
|
|
72
73
|
export { createTrackedApprover, listApprovals, decideApproval, findApproval } from './web/web-approver.js';
|
|
73
74
|
export { scaffoldAgent, scaffoldSubagent, AgentNameError, AgentExistsError, AgentNotFoundError, AgentModelError } from './bin/cli.js';
|
|
@@ -25,6 +25,8 @@ export const consoleSidebarHtml = `<aside class="le-sidebar" aria-label="Console
|
|
|
25
25
|
<nav class="le-foot" aria-label="Settings">
|
|
26
26
|
<a href="/config?section=models" data-le-nav="models">Models</a>
|
|
27
27
|
<a href="/config?section=gateways" data-le-nav="integrations">Integrations</a>
|
|
28
|
+
<a href="/config?section=settings" data-le-nav="settings">Settings</a>
|
|
29
|
+
<div class="le-who" id="leWho" hidden></div>
|
|
28
30
|
</nav>
|
|
29
31
|
</aside>`;
|
|
30
32
|
export const consoleShellScript = `<script>
|
|
@@ -156,12 +158,33 @@ export const consoleShellScript = `<script>
|
|
|
156
158
|
renderList();
|
|
157
159
|
}
|
|
158
160
|
|
|
159
|
-
var
|
|
161
|
+
var section = params.get('section');
|
|
162
|
+
var foot = page === 'config' ? (section === 'gateways' ? 'integrations' : section === 'settings' ? 'settings' : 'models') : '';
|
|
160
163
|
var footLinks = document.querySelectorAll('[data-le-nav]');
|
|
161
164
|
for (var i = 0; i < footLinks.length; i++) {
|
|
162
165
|
if (footLinks[i].getAttribute('data-le-nav') === foot) footLinks[i].setAttribute('aria-current', 'page');
|
|
163
166
|
}
|
|
164
167
|
|
|
168
|
+
// Who is signed in: the email and a link back to the dashboard when a
|
|
169
|
+
// hosting router signs requests, otherwise how this server is protected.
|
|
170
|
+
var who = document.getElementById('leWho');
|
|
171
|
+
if (who) {
|
|
172
|
+
fetch('/config/settings')
|
|
173
|
+
.then(function (r) { return r.ok ? r.json() : null; })
|
|
174
|
+
.then(function (s) {
|
|
175
|
+
if (!s || !s.signIn) return;
|
|
176
|
+
var si = s.signIn;
|
|
177
|
+
if (si.mode === 'hosted') {
|
|
178
|
+
who.innerHTML = '<span class="le-who-name" title="' + esc(si.email || '') + '">' + esc(si.email || 'Signed in') + '</span>' +
|
|
179
|
+
(si.dashboardUrl ? '<a href="' + esc(si.dashboardUrl) + '">Dashboard</a>' : '');
|
|
180
|
+
} else {
|
|
181
|
+
who.innerHTML = '<span class="le-who-name">' + (si.mode === 'basic' ? 'Signed in with Basic Auth' : 'No sign-in configured') + '</span>';
|
|
182
|
+
}
|
|
183
|
+
who.hidden = false;
|
|
184
|
+
})
|
|
185
|
+
.catch(function () {});
|
|
186
|
+
}
|
|
187
|
+
|
|
165
188
|
document.addEventListener('click', function (ev) {
|
|
166
189
|
if (!app) return;
|
|
167
190
|
if (ev.target.closest('[data-le-menu]')) { app.classList.toggle('nav-open'); return; }
|
|
@@ -130,6 +130,11 @@ export const devUiCss = `
|
|
|
130
130
|
.le-foot a { padding: 7px 8px; border-radius: 6px; color: var(--ink-muted); text-decoration: none; }
|
|
131
131
|
.le-foot a:hover { background: var(--surface-2); color: var(--ink); }
|
|
132
132
|
.le-foot a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); }
|
|
133
|
+
.le-who { padding: 10px 8px 4px; font-size: 12px; color: var(--ink-faint); display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
|
|
134
|
+
.le-who[hidden] { display: none; }
|
|
135
|
+
.le-who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
|
136
|
+
.le-foot .le-who a { padding: 0; flex: none; color: var(--accent-ink); }
|
|
137
|
+
.le-foot .le-who a:hover { background: none; text-decoration: underline; }
|
|
133
138
|
.le-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
|
|
134
139
|
.le-scroll { flex: 1; min-height: 0; overflow-y: auto; }
|
|
135
140
|
.le-page { padding: 24px; max-width: 1100px; display: grid; gap: 24px; }
|
|
@@ -83,6 +83,11 @@ ${consoleSidebarHtml}
|
|
|
83
83
|
<div><h1>Integrations</h1><p>Outside tool sources (such as Composio) that agents can add tools from.</p></div></div></div>
|
|
84
84
|
<div class="le-scroll"><div class="le-page" style="display:block"><div id="gatewaysContent"><p class="hint">Loading…</p></div></div></div>
|
|
85
85
|
</div>
|
|
86
|
+
<div class="section-panel" data-section-panel="settings" style="display:none">
|
|
87
|
+
<div class="le-head plain"><div class="le-title"><button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">☰</button>
|
|
88
|
+
<div><h1>Settings</h1><p>How this server is set up. These come from its deployment, not from this page.</p></div></div></div>
|
|
89
|
+
<div class="le-scroll"><div class="le-page" style="display:block"><div id="settingsContent"><p class="hint">Loading…</p></div></div></div>
|
|
90
|
+
</div>
|
|
86
91
|
</main>
|
|
87
92
|
</div>
|
|
88
93
|
${consoleShellScript}
|
|
@@ -277,6 +282,42 @@ ${consoleShellScript}
|
|
|
277
282
|
});
|
|
278
283
|
}
|
|
279
284
|
|
|
285
|
+
// ---- Settings section ----
|
|
286
|
+
|
|
287
|
+
function renderSettings(d) {
|
|
288
|
+
var si = d.signIn || {};
|
|
289
|
+
var signIn = si.mode === 'hosted'
|
|
290
|
+
? 'Managed by your LoopEngine Cloud account' + (si.email ? ' (' + escapeHtml(si.email) + ')' : '') +
|
|
291
|
+
(si.dashboardUrl ? ' · <a href="' + escapeHtml(si.dashboardUrl) + '">Dashboard</a>' : '')
|
|
292
|
+
: si.mode === 'basic'
|
|
293
|
+
? 'Basic Auth (<code>LOOPENGINE_ADMIN_AUTH</code>)'
|
|
294
|
+
: '<span class="error">None: anyone who can reach this server can use it. Set <code>LOOPENGINE_ADMIN_AUTH</code>.</span>';
|
|
295
|
+
var rows = [
|
|
296
|
+
['Admin sign-in', signIn],
|
|
297
|
+
['LoopEngine version', '<code>' + escapeHtml(d.version) + '</code>'],
|
|
298
|
+
['Environment name', '<code>' + escapeHtml(d.environment) + '</code> <span class="hint">(LOOPENGINE_ENV)</span>'],
|
|
299
|
+
['Public address', d.publicUrl ? '<code>' + escapeHtml(d.publicUrl) + '</code>' : '<span class="hint">Not set (LOOPENGINE_PUBLIC_URL); links in notifications use the address saved with each notifier</span>'],
|
|
300
|
+
['Scheduled tasks', d.scheduler === 'off' ? 'Off on this server (LOOPENGINE_SCHEDULER=off)' : 'Run by this server'],
|
|
301
|
+
['Theme', 'Follows your system'],
|
|
302
|
+
];
|
|
303
|
+
return '<section><table><thead><tr><th>Setting</th><th>Value</th></tr></thead><tbody>' +
|
|
304
|
+
rows.map(function (r) { return '<tr><td>' + r[0] + '</td><td>' + r[1] + '</td></tr>'; }).join('') +
|
|
305
|
+
'</tbody></table></section>';
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function loadSettings() {
|
|
309
|
+
var content = document.getElementById('settingsContent');
|
|
310
|
+
fetch('/config/settings')
|
|
311
|
+
.then(function (r) { return r.json(); })
|
|
312
|
+
.then(function (d) {
|
|
313
|
+
content.innerHTML = renderSettings(d);
|
|
314
|
+
loadedSections.settings = true;
|
|
315
|
+
})
|
|
316
|
+
.catch(function (err) {
|
|
317
|
+
content.innerHTML = '<p class="error">Could not load settings: ' + escapeHtml(err.message) + '</p>';
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
280
321
|
// ---- Section switching ----
|
|
281
322
|
|
|
282
323
|
function switchSection(section) {
|
|
@@ -290,6 +331,7 @@ ${consoleShellScript}
|
|
|
290
331
|
}
|
|
291
332
|
if (section === 'models' && !loadedSections.models) loadModels();
|
|
292
333
|
if (section === 'gateways' && !loadedSections.gateways) loadGateways();
|
|
334
|
+
if (section === 'settings' && !loadedSections.settings) loadSettings();
|
|
293
335
|
}
|
|
294
336
|
|
|
295
337
|
for (var i = 0; i < sectionButtons.length; i++) {
|
|
@@ -301,7 +343,7 @@ ${consoleShellScript}
|
|
|
301
343
|
// real section, same "trust the query param only if it's valid"
|
|
302
344
|
// caution playground.ts's own ?agent= handling already uses.
|
|
303
345
|
var requestedSection = new URLSearchParams(location.search).get('section');
|
|
304
|
-
var initialSection = requestedSection === 'gateways' || requestedSection === 'models' ? requestedSection : currentSection;
|
|
346
|
+
var initialSection = requestedSection === 'gateways' || requestedSection === 'models' || requestedSection === 'settings' ? requestedSection : currentSection;
|
|
305
347
|
switchSection(initialSection);
|
|
306
348
|
})();
|
|
307
349
|
</script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loopengine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.75",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Runtime for tool-using AI agents with a transparent ReAct loop.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"dist/bin/ability-manager.js",
|
|
27
27
|
"dist/bin/ability-manager.d.ts",
|
|
28
28
|
"dist/core/run-agent.js",
|
|
29
|
+
"dist/core/version.js",
|
|
30
|
+
"dist/core/version.d.ts",
|
|
29
31
|
"dist/core/run-agent.d.ts",
|
|
30
32
|
"dist/core/known-urls.js",
|
|
31
33
|
"dist/core/known-urls.d.ts",
|