bopodev-api 0.1.31 → 0.1.33
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/package.json +10 -4
- package/src/app.ts +2 -0
- package/src/lib/agent-config.ts +58 -10
- package/src/lib/builtin-bopo-skills/bopodev-control-plane.md +123 -0
- package/src/lib/builtin-bopo-skills/bopodev-create-agent.md +90 -0
- package/src/lib/builtin-bopo-skills/index.ts +36 -0
- package/src/lib/builtin-bopo-skills/para-memory-files.md +48 -0
- package/src/lib/instance-paths.ts +5 -0
- package/src/routes/agents.ts +21 -7
- package/src/routes/assistant.ts +109 -0
- package/src/routes/companies.ts +112 -1
- package/src/routes/observability.ts +299 -1
- package/src/services/company-assistant-brain.ts +50 -0
- package/src/services/company-assistant-cli.ts +388 -0
- package/src/services/company-assistant-context-snapshot.ts +287 -0
- package/src/services/company-assistant-llm.ts +375 -0
- package/src/services/company-assistant-service.ts +1012 -0
- package/src/services/company-file-archive-service.ts +445 -0
- package/src/services/company-file-import-service.ts +279 -0
- package/src/services/company-skill-file-service.ts +558 -0
- package/src/services/governance-service.ts +11 -3
- package/src/services/heartbeat-service/heartbeat-run.ts +45 -8
- package/src/services/memory-file-service.ts +70 -0
- package/src/services/template-catalog.ts +19 -6
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
ControlPlaneRequestHeadersSchema,
|
|
10
10
|
ControlPlaneRuntimeEnvSchema,
|
|
11
11
|
ExecutionOutcomeSchema,
|
|
12
|
+
mergeBuiltinSkillIdsForInjection,
|
|
12
13
|
type ExecutionOutcome,
|
|
13
14
|
type RunArtifact,
|
|
14
15
|
type RunCompletionReason,
|
|
@@ -59,6 +60,7 @@ import { createHeartbeatRunsRealtimeEvent, loadHeartbeatRunsRealtimeSnapshot } f
|
|
|
59
60
|
import { publishAttentionSnapshot } from "../../realtime/attention";
|
|
60
61
|
import { publishOfficeOccupantForAgent } from "../../realtime/office-space";
|
|
61
62
|
import { appendProjectBudgetUsage, checkAgentBudget, checkProjectBudget } from "../budget-service";
|
|
63
|
+
import { materializeLinkedSkillsForRuntime } from "../company-skill-file-service";
|
|
62
64
|
import { appendDurableFact, loadAgentMemoryContext, persistHeartbeatMemory } from "../memory-file-service";
|
|
63
65
|
import { calculateModelPricedUsdCost } from "../model-pricing";
|
|
64
66
|
import { runPluginHook } from "../plugin-runtime";
|
|
@@ -527,6 +529,7 @@ export async function runHeartbeatForAgent(
|
|
|
527
529
|
let transcriptLiveHighSignalCount = 0;
|
|
528
530
|
let transcriptPersistFailureReported = false;
|
|
529
531
|
let pluginFailureSummary: string[] = [];
|
|
532
|
+
let linkedSkillsMaterializationCleanup: (() => Promise<void>) | null = null;
|
|
530
533
|
const seenResultMessages = new Set<string>();
|
|
531
534
|
const runDigestSignals: RunDigestSignal[] = [];
|
|
532
535
|
|
|
@@ -706,13 +709,24 @@ export async function runHeartbeatForAgent(
|
|
|
706
709
|
if (runMode === "redo") {
|
|
707
710
|
state = clearResumeState(state);
|
|
708
711
|
}
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
712
|
+
const mergedSkillIds = mergeRuntimeForExecution(
|
|
713
|
+
{ enabledSkillIds: persistedRuntime.enabledSkillIds },
|
|
714
|
+
state.runtime
|
|
715
|
+
).enabledSkillIds;
|
|
716
|
+
const linkedMaterialized = await materializeLinkedSkillsForRuntime(companyId, {
|
|
717
|
+
enabledSkillIds: mergedSkillIds
|
|
715
718
|
});
|
|
719
|
+
linkedSkillsMaterializationCleanup = linkedMaterialized.cleanup;
|
|
720
|
+
const heartbeatRuntimeEnv: Record<string, string> = {
|
|
721
|
+
...buildHeartbeatRuntimeEnv({
|
|
722
|
+
companyId,
|
|
723
|
+
agentId: agent.id,
|
|
724
|
+
heartbeatRunId: runId,
|
|
725
|
+
canHireAgents: agent.canHireAgents,
|
|
726
|
+
wakeContext: options?.wakeContext
|
|
727
|
+
}),
|
|
728
|
+
...(linkedMaterialized.root ? { BOPODEV_MATERIALIZED_LINKED_SKILLS_ROOT: linkedMaterialized.root } : {})
|
|
729
|
+
};
|
|
716
730
|
const runtimeFromConfig = {
|
|
717
731
|
command: persistedRuntime.runtimeCommand,
|
|
718
732
|
args: persistedRuntime.runtimeArgs,
|
|
@@ -745,15 +759,27 @@ export async function runHeartbeatForAgent(
|
|
|
745
759
|
thinkingEffort: persistedRuntime.runtimeThinkingEffort,
|
|
746
760
|
bootstrapPrompt: persistedRuntime.bootstrapPrompt,
|
|
747
761
|
interruptGraceSec: persistedRuntime.interruptGraceSec,
|
|
748
|
-
runPolicy: persistedRuntime.runPolicy
|
|
762
|
+
runPolicy: persistedRuntime.runPolicy,
|
|
763
|
+
enabledSkillIds: persistedRuntime.enabledSkillIds
|
|
749
764
|
};
|
|
750
765
|
const mergedRuntime = mergeRuntimeForExecution(runtimeFromConfig, state.runtime);
|
|
766
|
+
const runtimeForWorkspace = {
|
|
767
|
+
...mergedRuntime,
|
|
768
|
+
env: {
|
|
769
|
+
...(mergedRuntime.env ?? {}),
|
|
770
|
+
...(mergedRuntime.enabledSkillIds !== undefined
|
|
771
|
+
? {
|
|
772
|
+
BOPODEV_ENABLED_SKILL_IDS: mergeBuiltinSkillIdsForInjection(mergedRuntime.enabledSkillIds)!.join(",")
|
|
773
|
+
}
|
|
774
|
+
: {})
|
|
775
|
+
}
|
|
776
|
+
};
|
|
751
777
|
const workspaceResolution = await resolveRuntimeWorkspaceForWorkItems(
|
|
752
778
|
db,
|
|
753
779
|
companyId,
|
|
754
780
|
agent.id,
|
|
755
781
|
contextWorkItems,
|
|
756
|
-
|
|
782
|
+
runtimeForWorkspace
|
|
757
783
|
);
|
|
758
784
|
await mkdir(join(resolveAgentFallbackWorkspace(companyId, agent.id), "operating"), { recursive: true });
|
|
759
785
|
state = {
|
|
@@ -1735,6 +1761,14 @@ export async function runHeartbeatForAgent(
|
|
|
1735
1761
|
});
|
|
1736
1762
|
}
|
|
1737
1763
|
} finally {
|
|
1764
|
+
if (linkedSkillsMaterializationCleanup) {
|
|
1765
|
+
try {
|
|
1766
|
+
await linkedSkillsMaterializationCleanup();
|
|
1767
|
+
} catch {
|
|
1768
|
+
// Best effort: linked skill temp dir cleanup should not mask heartbeat teardown.
|
|
1769
|
+
}
|
|
1770
|
+
linkedSkillsMaterializationCleanup = null;
|
|
1771
|
+
}
|
|
1738
1772
|
await transcriptWriteQueue;
|
|
1739
1773
|
if (discardIdleNoWorkRunAfterFlush) {
|
|
1740
1774
|
try {
|
|
@@ -3380,6 +3414,7 @@ function parseAgentState(stateBlob: string | null) {
|
|
|
3380
3414
|
model?: string;
|
|
3381
3415
|
thinkingEffort?: "auto" | "low" | "medium" | "high";
|
|
3382
3416
|
bootstrapPrompt?: string;
|
|
3417
|
+
enabledSkillIds?: string[];
|
|
3383
3418
|
runPolicy?: {
|
|
3384
3419
|
sandboxMode?: "workspace_write" | "full_access";
|
|
3385
3420
|
allowWebSearch?: boolean;
|
|
@@ -3924,6 +3959,7 @@ function mergeRuntimeForExecution(
|
|
|
3924
3959
|
model?: string;
|
|
3925
3960
|
thinkingEffort?: "auto" | "low" | "medium" | "high";
|
|
3926
3961
|
bootstrapPrompt?: string;
|
|
3962
|
+
enabledSkillIds?: string[];
|
|
3927
3963
|
runPolicy?: {
|
|
3928
3964
|
sandboxMode?: "workspace_write" | "full_access";
|
|
3929
3965
|
allowWebSearch?: boolean;
|
|
@@ -3943,6 +3979,7 @@ function mergeRuntimeForExecution(
|
|
|
3943
3979
|
model?: string;
|
|
3944
3980
|
thinkingEffort?: "auto" | "low" | "medium" | "high";
|
|
3945
3981
|
bootstrapPrompt?: string;
|
|
3982
|
+
enabledSkillIds?: string[];
|
|
3946
3983
|
runPolicy?: {
|
|
3947
3984
|
sandboxMode?: "workspace_write" | "full_access";
|
|
3948
3985
|
allowWebSearch?: boolean;
|
|
@@ -184,6 +184,76 @@ export async function appendDurableFact(input: {
|
|
|
184
184
|
return targetFile;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
export async function listCompanyMemoryFiles(input: { companyId: string; maxFiles?: number }) {
|
|
188
|
+
const root = resolveCompanyMemoryRootPath(input.companyId);
|
|
189
|
+
await mkdir(root, { recursive: true });
|
|
190
|
+
const maxFiles = Math.max(1, Math.min(MAX_OBSERVABILITY_FILES, input.maxFiles ?? 100));
|
|
191
|
+
const files = await walkFiles(root, maxFiles);
|
|
192
|
+
return files.map((filePath) => ({
|
|
193
|
+
path: filePath,
|
|
194
|
+
relativePath: relative(root, filePath),
|
|
195
|
+
memoryRoot: root
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export async function readCompanyMemoryFile(input: { companyId: string; relativePath: string }) {
|
|
200
|
+
const root = resolveCompanyMemoryRootPath(input.companyId);
|
|
201
|
+
await mkdir(root, { recursive: true });
|
|
202
|
+
const candidate = resolve(root, input.relativePath);
|
|
203
|
+
if (!isInsidePath(root, candidate)) {
|
|
204
|
+
throw new Error("Requested memory path is outside of memory root.");
|
|
205
|
+
}
|
|
206
|
+
const info = await stat(candidate);
|
|
207
|
+
if (!info.isFile()) {
|
|
208
|
+
throw new Error("Requested memory path is not a file.");
|
|
209
|
+
}
|
|
210
|
+
if (info.size > MAX_OBSERVABILITY_FILE_BYTES) {
|
|
211
|
+
throw new Error("Requested memory file exceeds size limit.");
|
|
212
|
+
}
|
|
213
|
+
const content = await readFile(candidate, "utf8");
|
|
214
|
+
return {
|
|
215
|
+
path: candidate,
|
|
216
|
+
relativePath: relative(root, candidate),
|
|
217
|
+
content,
|
|
218
|
+
sizeBytes: info.size
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export async function listProjectMemoryFiles(input: { companyId: string; projectId: string; maxFiles?: number }) {
|
|
223
|
+
const root = resolveProjectMemoryRootPath(input.companyId, input.projectId);
|
|
224
|
+
await mkdir(root, { recursive: true });
|
|
225
|
+
const maxFiles = Math.max(1, Math.min(MAX_OBSERVABILITY_FILES, input.maxFiles ?? 100));
|
|
226
|
+
const files = await walkFiles(root, maxFiles);
|
|
227
|
+
return files.map((filePath) => ({
|
|
228
|
+
path: filePath,
|
|
229
|
+
relativePath: relative(root, filePath),
|
|
230
|
+
memoryRoot: root
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export async function readProjectMemoryFile(input: { companyId: string; projectId: string; relativePath: string }) {
|
|
235
|
+
const root = resolveProjectMemoryRootPath(input.companyId, input.projectId);
|
|
236
|
+
await mkdir(root, { recursive: true });
|
|
237
|
+
const candidate = resolve(root, input.relativePath);
|
|
238
|
+
if (!isInsidePath(root, candidate)) {
|
|
239
|
+
throw new Error("Requested memory path is outside of memory root.");
|
|
240
|
+
}
|
|
241
|
+
const info = await stat(candidate);
|
|
242
|
+
if (!info.isFile()) {
|
|
243
|
+
throw new Error("Requested memory path is not a file.");
|
|
244
|
+
}
|
|
245
|
+
if (info.size > MAX_OBSERVABILITY_FILE_BYTES) {
|
|
246
|
+
throw new Error("Requested memory file exceeds size limit.");
|
|
247
|
+
}
|
|
248
|
+
const content = await readFile(candidate, "utf8");
|
|
249
|
+
return {
|
|
250
|
+
path: candidate,
|
|
251
|
+
relativePath: relative(root, candidate),
|
|
252
|
+
content,
|
|
253
|
+
sizeBytes: info.size
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
187
257
|
export async function listAgentMemoryFiles(input: {
|
|
188
258
|
companyId: string;
|
|
189
259
|
agentId: string;
|
|
@@ -28,8 +28,9 @@ const builtinTemplateDefinitions: BuiltinTemplateDefinition[] = [
|
|
|
28
28
|
{
|
|
29
29
|
slug: "founder-startup-basic",
|
|
30
30
|
name: "Founder Startup Basic",
|
|
31
|
-
description:
|
|
32
|
-
|
|
31
|
+
description:
|
|
32
|
+
"Baseline operating company for solo founders launching and shipping with AI agents. Aligns with Bopo company file export (.bopo.yaml, projects/, agents/, tasks/) so operators can download a zip, edit markdown in git, and import a new company from the archive.",
|
|
33
|
+
version: "1.0.2",
|
|
33
34
|
status: "published",
|
|
34
35
|
visibility: "company",
|
|
35
36
|
variables: [
|
|
@@ -117,7 +118,11 @@ const builtinTemplateDefinitions: BuiltinTemplateDefinition[] = [
|
|
|
117
118
|
"",
|
|
118
119
|
"Quality bar:",
|
|
119
120
|
"- Be concise, specific, and execution-ready.",
|
|
120
|
-
"- Do not produce generic plans without owners, dates, and measurable outcomes."
|
|
121
|
+
"- Do not produce generic plans without owners, dates, and measurable outcomes.",
|
|
122
|
+
"",
|
|
123
|
+
"Portable company files:",
|
|
124
|
+
"- Under workspace Templates → Export, the app can produce a zip with .bopo.yaml and per-agent markdown under agents/<slug>/.",
|
|
125
|
+
"- That tree can be edited in git and re-imported to create another company; keep those files consistent with how you actually run."
|
|
121
126
|
].join("\n")
|
|
122
127
|
}
|
|
123
128
|
},
|
|
@@ -237,8 +242,9 @@ const builtinTemplateDefinitions: BuiltinTemplateDefinition[] = [
|
|
|
237
242
|
{
|
|
238
243
|
slug: "marketing-content-engine",
|
|
239
244
|
name: "Marketing Content Engine",
|
|
240
|
-
description:
|
|
241
|
-
|
|
245
|
+
description:
|
|
246
|
+
"Content marketing operating template for publishing, distribution, and analytics loops. Uses the same Bopo company zip layout as file export/import so marketing orgs can be versioned in git and cloned via archive import.",
|
|
247
|
+
version: "1.0.2",
|
|
242
248
|
status: "published",
|
|
243
249
|
visibility: "company",
|
|
244
250
|
variables: [
|
|
@@ -318,7 +324,11 @@ const builtinTemplateDefinitions: BuiltinTemplateDefinition[] = [
|
|
|
318
324
|
"",
|
|
319
325
|
"Escalation:",
|
|
320
326
|
"- Escalate major brand/positioning shifts, compliance-sensitive claims, or budget overrun risks.",
|
|
321
|
-
"- If dependencies block publication, create unblock issues within 24h."
|
|
327
|
+
"- If dependencies block publication, create unblock issues within 24h.",
|
|
328
|
+
"",
|
|
329
|
+
"Portable company files:",
|
|
330
|
+
"- Under workspace Templates → Export, leaders can download a zip with .bopo.yaml and agent markdown under agents/<slug>/.",
|
|
331
|
+
"- That folder tree can be edited in git and re-imported to stand up a new company; keep exported docs aligned with campaigns you actually ship."
|
|
322
332
|
].join("\n")
|
|
323
333
|
}
|
|
324
334
|
},
|
|
@@ -514,6 +524,9 @@ export async function ensureCompanyBuiltinTemplateDefaults(db: BopoDb, companyId
|
|
|
514
524
|
await updateTemplate(db, {
|
|
515
525
|
companyId,
|
|
516
526
|
id: template.id,
|
|
527
|
+
name: definition.name,
|
|
528
|
+
description: definition.description,
|
|
529
|
+
variablesJson: JSON.stringify(variables),
|
|
517
530
|
currentVersion: definition.version
|
|
518
531
|
});
|
|
519
532
|
}
|