botinabox 1.1.0 → 1.2.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/index.d.ts +22 -1
- package/dist/index.js +71 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1212,6 +1212,27 @@ interface PackageMigration {
|
|
|
1212
1212
|
*/
|
|
1213
1213
|
declare function runPackageMigrations(db: DataStore, migrations: PackageMigration[]): Promise<void>;
|
|
1214
1214
|
|
|
1215
|
+
interface UpdateResult {
|
|
1216
|
+
updated: boolean;
|
|
1217
|
+
packages: Array<{
|
|
1218
|
+
name: string;
|
|
1219
|
+
from: string;
|
|
1220
|
+
to: string;
|
|
1221
|
+
}>;
|
|
1222
|
+
restartRequired: boolean;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Check npm for newer versions of framework packages and install them.
|
|
1226
|
+
* Returns what was updated. Safe to call on every startup — skips if
|
|
1227
|
+
* already on latest.
|
|
1228
|
+
*
|
|
1229
|
+
* @param packages - Package names to check (default: botinabox + latticesql)
|
|
1230
|
+
* @param opts.quiet - Suppress console output (default: false)
|
|
1231
|
+
*/
|
|
1232
|
+
declare function autoUpdate(packages?: string[], opts?: {
|
|
1233
|
+
quiet?: boolean;
|
|
1234
|
+
}): Promise<UpdateResult>;
|
|
1235
|
+
|
|
1215
1236
|
declare class RunManager {
|
|
1216
1237
|
private db;
|
|
1217
1238
|
private hooks;
|
|
@@ -1567,4 +1588,4 @@ declare function isLoginRequired(stdout: string): boolean;
|
|
|
1567
1588
|
/** Rewrite local image paths to prevent CLI auto-embedding as vision content. */
|
|
1568
1589
|
declare function deactivateLocalImagePaths(prompt: string): string;
|
|
1569
1590
|
|
|
1570
|
-
export { AGENT_STATUSES, type AgentConfig, type AgentDefinition, type AgentFilter, type AgentRecord, AgentRegistry, type AgentStatus, ApiExecutionAdapter, AuditEmitter, type AuditEvent, BackupManager, type BotConfig, type BudgetCheck, type BudgetConfig, BudgetController, CORE_MIGRATIONS, ChannelAdapter, ChannelRegistry, ChannelRegistryError, ChatMessage, ChatSessionManager, CliExecutionAdapter, type ColumnValidator, ColumnValidatorImpl, type ConfigLoadError, type ConfigLoadResult, ConnectorConfig, DEFAULTS, DEFAULT_CONFIG, type DataConfig, DataStore, DataStoreError, type DomainEntityContextOptions, type DomainSchemaOptions, EVENTS, type EntityColumnDef, type EntityConfig, type EntityContextDef, type EntityFileSpec, type EntitySource, type ExecutionAdapter, type Filter, HealthStatus, HookBus, type HookHandler, type HookOptions, type HookRegistration, InboundMessage, LLMProvider, MAX_CHAIN_DEPTH, MessagePipeline, type ModelConfig, ModelInfo, ModelRouter, NdjsonLogger, NotificationQueue, type PackageMigration, type PackageUpdate, type ParsedStream, type PkLookup, ProviderRegistry, type QueryOptions, RUN_STATUSES, type RelationDef, type RenderConfig, ResolvedModel, type RetryPolicy, type Row, type RunContext, RunManager, type RunResult, type RunStatus, type SanitizerOptions, type Schedule, type ScheduleDef, Scheduler, type SchemaError, type SecretInput, type SecretMeta, SecretStore, type SecurityConfig, type SeedItem, SessionKey, SessionManager, type SqliteAdapter, type StepRef, TASK_STATUSES, type TableDefinition, type TableInfoRow, type TaskDefinition, TaskQueue, type TaskRecord, type TaskStatus, TokenUsage, type Unsubscribe, UpdateChecker, type UpdateConfig, UpdateManager, type UpdateManifest, type UsageSummary, type User, type UserInput, UserRegistry, WakeupQueue, type WorkflowConfigEntry, type WorkflowDefinition$1 as WorkflowDefinition, WorkflowEngine, type WorkflowRunRecord, type WorkflowRunStatus, type WorkflowStep$1 as WorkflowStep, type WorkflowStepConfig, type WorkflowTrigger, _resetConfig, areDependenciesMet, buildAgentBindings, buildChainOrigin, buildProcessEnv, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, createConfigRevision, deactivateLocalImagePaths, defineCoreEntityContexts, defineCoreTables, defineDomainEntityContexts, defineDomainTables, detectCycle, discoverChannels, discoverProviders, formatText, getConfig, initConfig, interpolate, interpolateEnv, isLoginRequired, isMaxTurns, loadConfig, parseClaudeStream, parseVersion, runPackageMigrations, sanitize, topologicalSort, truncateAtWord, validateConfig };
|
|
1591
|
+
export { AGENT_STATUSES, type AgentConfig, type AgentDefinition, type AgentFilter, type AgentRecord, AgentRegistry, type AgentStatus, ApiExecutionAdapter, AuditEmitter, type AuditEvent, BackupManager, type BotConfig, type BudgetCheck, type BudgetConfig, BudgetController, CORE_MIGRATIONS, ChannelAdapter, ChannelRegistry, ChannelRegistryError, ChatMessage, ChatSessionManager, CliExecutionAdapter, type ColumnValidator, ColumnValidatorImpl, type ConfigLoadError, type ConfigLoadResult, ConnectorConfig, DEFAULTS, DEFAULT_CONFIG, type DataConfig, DataStore, DataStoreError, type DomainEntityContextOptions, type DomainSchemaOptions, EVENTS, type EntityColumnDef, type EntityConfig, type EntityContextDef, type EntityFileSpec, type EntitySource, type ExecutionAdapter, type Filter, HealthStatus, HookBus, type HookHandler, type HookOptions, type HookRegistration, InboundMessage, LLMProvider, MAX_CHAIN_DEPTH, MessagePipeline, type ModelConfig, ModelInfo, ModelRouter, NdjsonLogger, NotificationQueue, type PackageMigration, type PackageUpdate, type ParsedStream, type PkLookup, ProviderRegistry, type QueryOptions, RUN_STATUSES, type RelationDef, type RenderConfig, ResolvedModel, type RetryPolicy, type Row, type RunContext, RunManager, type RunResult, type RunStatus, type SanitizerOptions, type Schedule, type ScheduleDef, Scheduler, type SchemaError, type SecretInput, type SecretMeta, SecretStore, type SecurityConfig, type SeedItem, SessionKey, SessionManager, type SqliteAdapter, type StepRef, TASK_STATUSES, type TableDefinition, type TableInfoRow, type TaskDefinition, TaskQueue, type TaskRecord, type TaskStatus, TokenUsage, type Unsubscribe, UpdateChecker, type UpdateConfig, UpdateManager, type UpdateManifest, type UsageSummary, type User, type UserInput, UserRegistry, WakeupQueue, type WorkflowConfigEntry, type WorkflowDefinition$1 as WorkflowDefinition, WorkflowEngine, type WorkflowRunRecord, type WorkflowRunStatus, type WorkflowStep$1 as WorkflowStep, type WorkflowStepConfig, type WorkflowTrigger, _resetConfig, areDependenciesMet, autoUpdate, buildAgentBindings, buildChainOrigin, buildProcessEnv, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, createConfigRevision, deactivateLocalImagePaths, defineCoreEntityContexts, defineCoreTables, defineDomainEntityContexts, defineDomainTables, detectCycle, discoverChannels, discoverProviders, formatText, getConfig, initConfig, interpolate, interpolateEnv, isLoginRequired, isMaxTurns, loadConfig, parseClaudeStream, parseVersion, runPackageMigrations, sanitize, topologicalSort, truncateAtWord, validateConfig };
|
package/dist/index.js
CHANGED
|
@@ -2727,6 +2727,73 @@ async function runPackageMigrations(db, migrations) {
|
|
|
2727
2727
|
);
|
|
2728
2728
|
}
|
|
2729
2729
|
|
|
2730
|
+
// src/core/update/auto-update.ts
|
|
2731
|
+
import { execSync as execSync2 } from "child_process";
|
|
2732
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
2733
|
+
import { join as join5 } from "path";
|
|
2734
|
+
function getInstalledVersion(pkgName) {
|
|
2735
|
+
try {
|
|
2736
|
+
const pkgPath = join5(process.cwd(), "node_modules", pkgName, "package.json");
|
|
2737
|
+
const pkg = JSON.parse(readFileSync3(pkgPath, "utf-8"));
|
|
2738
|
+
return pkg.version;
|
|
2739
|
+
} catch {
|
|
2740
|
+
return null;
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
async function getLatestVersion(pkgName) {
|
|
2744
|
+
try {
|
|
2745
|
+
const res = await fetch(`https://registry.npmjs.org/${pkgName}/latest`, {
|
|
2746
|
+
headers: { accept: "application/json" },
|
|
2747
|
+
signal: AbortSignal.timeout(5e3)
|
|
2748
|
+
});
|
|
2749
|
+
if (!res.ok) return null;
|
|
2750
|
+
const data = await res.json();
|
|
2751
|
+
return data.version;
|
|
2752
|
+
} catch {
|
|
2753
|
+
return null;
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
function isNewer(latest, current) {
|
|
2757
|
+
const a = latest.split(".").map(Number);
|
|
2758
|
+
const b = current.split(".").map(Number);
|
|
2759
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
2760
|
+
if ((a[i] ?? 0) > (b[i] ?? 0)) return true;
|
|
2761
|
+
if ((a[i] ?? 0) < (b[i] ?? 0)) return false;
|
|
2762
|
+
}
|
|
2763
|
+
return false;
|
|
2764
|
+
}
|
|
2765
|
+
async function autoUpdate(packages = ["botinabox", "latticesql"], opts) {
|
|
2766
|
+
const log = opts?.quiet ? () => {
|
|
2767
|
+
} : console.log;
|
|
2768
|
+
const result = { updated: false, packages: [], restartRequired: false };
|
|
2769
|
+
const toInstall = [];
|
|
2770
|
+
for (const pkg of packages) {
|
|
2771
|
+
const installed = getInstalledVersion(pkg);
|
|
2772
|
+
if (!installed) continue;
|
|
2773
|
+
const latest = await getLatestVersion(pkg);
|
|
2774
|
+
if (!latest) continue;
|
|
2775
|
+
if (isNewer(latest, installed)) {
|
|
2776
|
+
toInstall.push(`${pkg}@${latest}`);
|
|
2777
|
+
result.packages.push({ name: pkg, from: installed, to: latest });
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
if (toInstall.length === 0) return result;
|
|
2781
|
+
log(`[autoUpdate] Updating: ${toInstall.join(", ")}`);
|
|
2782
|
+
try {
|
|
2783
|
+
execSync2(`npm install ${toInstall.join(" ")}`, {
|
|
2784
|
+
cwd: process.cwd(),
|
|
2785
|
+
stdio: opts?.quiet ? "ignore" : "inherit",
|
|
2786
|
+
timeout: 6e4
|
|
2787
|
+
});
|
|
2788
|
+
result.updated = true;
|
|
2789
|
+
result.restartRequired = true;
|
|
2790
|
+
log(`[autoUpdate] Updated successfully. Restart required for changes to take effect.`);
|
|
2791
|
+
} catch (err) {
|
|
2792
|
+
console.error("[autoUpdate] Failed to install updates:", err);
|
|
2793
|
+
}
|
|
2794
|
+
return result;
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2730
2797
|
// src/core/orchestrator/config-revisions.ts
|
|
2731
2798
|
async function createConfigRevision(db, agentId, before, after) {
|
|
2732
2799
|
const existing = await db.query("config_revisions", {
|
|
@@ -3689,7 +3756,7 @@ var Scheduler = class {
|
|
|
3689
3756
|
};
|
|
3690
3757
|
|
|
3691
3758
|
// src/core/orchestrator/adapters/api-adapter.ts
|
|
3692
|
-
import { readFileSync as
|
|
3759
|
+
import { readFileSync as readFileSync4, existsSync as existsSync2 } from "fs";
|
|
3693
3760
|
|
|
3694
3761
|
// src/core/orchestrator/adapters/tool-loop.ts
|
|
3695
3762
|
async function* toolLoop(params, callLLM, executeTool) {
|
|
@@ -3776,7 +3843,7 @@ var ApiExecutionAdapter = class {
|
|
|
3776
3843
|
const fileContents = [];
|
|
3777
3844
|
for (const filePath of ctx.contextFiles) {
|
|
3778
3845
|
if (existsSync2(filePath)) {
|
|
3779
|
-
const content =
|
|
3846
|
+
const content = readFileSync4(filePath, "utf8");
|
|
3780
3847
|
fileContents.push(`<file path="${filePath}">
|
|
3781
3848
|
${content}
|
|
3782
3849
|
</file>`);
|
|
@@ -3892,7 +3959,7 @@ function killProcessGroup(pid, signal = "SIGTERM") {
|
|
|
3892
3959
|
}
|
|
3893
3960
|
|
|
3894
3961
|
// src/core/orchestrator/adapters/output-extractor.ts
|
|
3895
|
-
import { readFileSync as
|
|
3962
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
3896
3963
|
var MAX_OUTPUT_BYTES = 4 * 1024 * 1024;
|
|
3897
3964
|
function extractOutput(ndjsonContent) {
|
|
3898
3965
|
const lines = ndjsonContent.split("\n").filter((l) => l.trim().length > 0);
|
|
@@ -4314,6 +4381,7 @@ export {
|
|
|
4314
4381
|
WorkflowEngine,
|
|
4315
4382
|
_resetConfig,
|
|
4316
4383
|
areDependenciesMet,
|
|
4384
|
+
autoUpdate,
|
|
4317
4385
|
buildAgentBindings,
|
|
4318
4386
|
buildChainOrigin,
|
|
4319
4387
|
buildProcessEnv,
|