botinabox 0.2.1 → 0.2.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/dist/index.d.ts CHANGED
@@ -517,6 +517,8 @@ interface EntityContextDef {
517
517
  slugColumn: string;
518
518
  files: Record<string, EntityFileSpec>;
519
519
  indexFile?: string;
520
+ /** Custom index render function. If omitted, a default listing is generated. */
521
+ indexRender?: (rows: Row[]) => string;
520
522
  protectedFiles?: string[];
521
523
  /** When true, this entity's data is never rendered into other entities' context files. */
522
524
  protected?: boolean;
@@ -970,6 +972,20 @@ declare const CORE_MIGRATIONS: Array<{
970
972
  sql: string;
971
973
  }>;
972
974
 
975
+ /**
976
+ * Define default entity context rendering for botinabox core tables.
977
+ * Call after defineCoreTables() and before or after init().
978
+ *
979
+ * Renders:
980
+ * - agents/ — per-agent context (AGENT.md, PROJECTS.md if agent_project exists)
981
+ * - users/ — per-user context (USER.md) — protected
982
+ * - skills/ — per-skill context (SKILL.md)
983
+ *
984
+ * Apps can override by calling db.defineEntityContext() with the same table name
985
+ * BEFORE calling defineCoreEntityContexts().
986
+ */
987
+ declare function defineCoreEntityContexts(db: DataStore): void;
988
+
973
989
  interface SanitizerOptions {
974
990
  fieldLengthLimits?: Record<string, number>;
975
991
  truncateSuffix?: string;
@@ -1357,4 +1373,4 @@ declare class SecretStore {
1357
1373
  private _toMeta;
1358
1374
  }
1359
1375
 
1360
- 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, DEFAULTS, DEFAULT_CONFIG, type DataConfig, DataStore, DataStoreError, EVENTS, type EntityColumnDef, type EntityConfig, type EntityContextDef, type EntityFileSpec, type EntitySource, type ExecutionAdapter, type Filter, HealthStatus, HeartbeatScheduler, HookBus, type HookHandler, type HookOptions, type HookRegistration, InboundMessage, LLMProvider, MAX_CHAIN_DEPTH, MessagePipeline, type ModelConfig, ModelInfo, ModelRouter, NdjsonLogger, NotificationQueue, type PackageMigration, type PackageUpdate, 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 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 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, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, createConfigRevision, defineCoreTables, detectCycle, discoverChannels, discoverProviders, formatText, getConfig, initConfig, interpolate, interpolateEnv, loadConfig, parseVersion, runPackageMigrations, sanitize, topologicalSort, validateConfig };
1376
+ 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, DEFAULTS, DEFAULT_CONFIG, type DataConfig, DataStore, DataStoreError, EVENTS, type EntityColumnDef, type EntityConfig, type EntityContextDef, type EntityFileSpec, type EntitySource, type ExecutionAdapter, type Filter, HealthStatus, HeartbeatScheduler, HookBus, type HookHandler, type HookOptions, type HookRegistration, InboundMessage, LLMProvider, MAX_CHAIN_DEPTH, MessagePipeline, type ModelConfig, ModelInfo, ModelRouter, NdjsonLogger, NotificationQueue, type PackageMigration, type PackageUpdate, 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 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 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, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, createConfigRevision, defineCoreEntityContexts, defineCoreTables, detectCycle, discoverChannels, discoverProviders, formatText, getConfig, initConfig, interpolate, interpolateEnv, loadConfig, parseVersion, runPackageMigrations, sanitize, topologicalSort, validateConfig };
package/dist/index.js CHANGED
@@ -1140,7 +1140,25 @@ var DataStore = class {
1140
1140
  protectedFiles: def.protectedFiles,
1141
1141
  protected: def.protected,
1142
1142
  encrypted: def.encrypted,
1143
- index: def.indexFile ? { outputFile: def.indexFile, render: (rows) => "" } : void 0
1143
+ index: def.indexFile ? {
1144
+ outputFile: def.indexFile,
1145
+ render: def.indexRender ?? ((rows) => {
1146
+ const title = def.directory.charAt(0).toUpperCase() + def.directory.slice(1);
1147
+ if (!rows.length) return `# ${title}
1148
+
1149
+ None.
1150
+ `;
1151
+ const lines = rows.map((r) => {
1152
+ const name2 = String(r.name ?? r[def.slugColumn] ?? r.id ?? "unknown");
1153
+ const status = r.status ? ` (${r.status})` : "";
1154
+ return `- **${name2}**${status}`;
1155
+ });
1156
+ return `# ${title}
1157
+
1158
+ ${lines.join("\n")}
1159
+ `;
1160
+ })
1161
+ } : void 0
1144
1162
  });
1145
1163
  }
1146
1164
  async init(opts) {
@@ -1570,6 +1588,86 @@ var CORE_MIGRATIONS = [
1570
1588
  }
1571
1589
  ];
1572
1590
 
1591
+ // src/core/data/core-entity-contexts.ts
1592
+ function defineCoreEntityContexts(db) {
1593
+ db.defineEntityContext("agents", {
1594
+ table: "agents",
1595
+ directory: "agents",
1596
+ slugColumn: "slug",
1597
+ indexFile: "agents/AGENTS.md",
1598
+ files: {
1599
+ "AGENT.md": {
1600
+ source: { type: "self" },
1601
+ render: (rows) => {
1602
+ const a = rows[0];
1603
+ if (!a) return "";
1604
+ return [
1605
+ `# ${a.name}`,
1606
+ "",
1607
+ a.role ? `**Role:** ${a.role}` : null,
1608
+ a.status ? `**Status:** ${a.status}` : null,
1609
+ a.cwd ? `**Working Directory:** ${a.cwd}` : null,
1610
+ a.reports_to ? `**Reports To:** ${a.reports_to}` : null,
1611
+ ""
1612
+ ].filter(Boolean).join("\n");
1613
+ }
1614
+ }
1615
+ }
1616
+ });
1617
+ db.defineEntityContext("users", {
1618
+ table: "users",
1619
+ directory: "users",
1620
+ slugColumn: "name",
1621
+ protected: true,
1622
+ indexFile: "users/USERS.md",
1623
+ files: {
1624
+ "USER.md": {
1625
+ source: { type: "self" },
1626
+ render: (rows) => {
1627
+ const u = rows[0];
1628
+ if (!u) return "";
1629
+ return [
1630
+ `# ${u.name}`,
1631
+ "",
1632
+ u.role ? `**Role:** ${u.role}` : null,
1633
+ u.title ? `**Title:** ${u.title}` : null,
1634
+ u.email ? `**Email:** ${u.email}` : null,
1635
+ u.timezone ? `**Timezone:** ${u.timezone}` : null,
1636
+ ""
1637
+ ].filter(Boolean).join("\n");
1638
+ }
1639
+ }
1640
+ }
1641
+ });
1642
+ db.defineEntityContext("skills", {
1643
+ table: "skills",
1644
+ directory: "skills",
1645
+ slugColumn: "slug",
1646
+ indexFile: "skills/SKILLS.md",
1647
+ files: {
1648
+ "SKILL.md": {
1649
+ source: { type: "self" },
1650
+ render: (rows) => {
1651
+ const s = rows[0];
1652
+ if (!s) return "";
1653
+ return [
1654
+ `# ${s.name}`,
1655
+ "",
1656
+ s.category ? `**Category:** ${s.category}` : null,
1657
+ s.description ? `
1658
+ ${s.description}` : null,
1659
+ s.definition ? `
1660
+ ## Definition
1661
+
1662
+ ${s.definition}` : null,
1663
+ ""
1664
+ ].filter(Boolean).join("\n");
1665
+ }
1666
+ }
1667
+ }
1668
+ });
1669
+ }
1670
+
1573
1671
  // src/core/security/sanitizer.ts
1574
1672
  import { Buffer as Buffer2 } from "buffer";
1575
1673
  var DEFAULT_FIELD_LIMIT = 65535;
@@ -3179,6 +3277,7 @@ export {
3179
3277
  classifyUpdate,
3180
3278
  compareVersions,
3181
3279
  createConfigRevision,
3280
+ defineCoreEntityContexts,
3182
3281
  defineCoreTables,
3183
3282
  detectCycle,
3184
3283
  discoverChannels,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botinabox",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Bot in a Box — framework for building multi-agent bots",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",