@pasko70/pibo 2.4.2 → 2.4.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.
Files changed (44) hide show
  1. package/dist/agent-runtime/context-build.js +100 -11
  2. package/dist/agent-runtime/profile-validation.js +3 -0
  3. package/dist/agent-runtime/resource-service.js +16 -0
  4. package/dist/agent-runtime/routed-session.js +30 -23
  5. package/dist/agent-runtime/testing/fake-adapter.js +7 -0
  6. package/dist/agent-runtimes/pi/adapter.js +2 -0
  7. package/dist/agent-runtimes/pi/routed-session.js +42 -27
  8. package/dist/agent-runtimes/pi/runtime.js +8 -5
  9. package/dist/apps/chat/web-app.js +21 -6
  10. package/dist/apps/chat-ui/assets/{dist-Cw9po47P.js → dist-C4JGcQjh.js} +1 -1
  11. package/dist/apps/chat-ui/assets/{dist-BeqHbnGN.js → dist-CF92Lv76.js} +1 -1
  12. package/dist/apps/chat-ui/assets/{dist-DTRjeLwO.js → dist-CJ0JS-bE.js} +1 -1
  13. package/dist/apps/chat-ui/assets/{dist-3YG57JXi.js → dist-DrgKyb9n.js} +1 -1
  14. package/dist/apps/chat-ui/assets/{dist-CrDtveZB.js → dist-VoMyV-PE.js} +1 -1
  15. package/dist/apps/chat-ui/assets/index-0WZI2phJ.css +1 -0
  16. package/dist/apps/chat-ui/assets/index-DhX1_aRM.js +228 -0
  17. package/dist/apps/chat-ui/index.html +2 -2
  18. package/dist/apps/vscode-artifacts/latest.vsix +0 -0
  19. package/dist/apps/vscode-artifacts/{pibo-vscode-ext-2.4.2.vsix → pibo-vscode-ext-2.4.3.vsix} +0 -0
  20. package/dist/cli.js +16 -6
  21. package/dist/core/context-build.js +66 -6
  22. package/dist/core/model-defaults.js +11 -3
  23. package/dist/core/session-router.js +152 -69
  24. package/dist/gateway/server.js +1 -0
  25. package/dist/loops/accounting.js +80 -0
  26. package/dist/loops/service.js +51 -16
  27. package/dist/loops/store.js +50 -14
  28. package/dist/runs/lifecycle.js +26 -1
  29. package/dist/runs/registry.js +29 -47
  30. package/dist/runs/tools.js +23 -22
  31. package/dist/subagents/context.js +48 -0
  32. package/dist/subagents/runtime-selection.js +28 -0
  33. package/dist/subagents/tool.js +28 -6
  34. package/dist/tools/codex-compat.js +1 -0
  35. package/dist/tools/contract.js +10 -0
  36. package/dist/tools/mcp-bridge.js +4 -2
  37. package/dist/tools/runtime/node-backend.js +8 -2
  38. package/dist/tools/runtime/python-backend.js +8 -2
  39. package/dist/tools/runtime/tool.js +1 -0
  40. package/dist/tools/session-tool-set.js +19 -12
  41. package/npm-shrinkwrap.json +2 -2
  42. package/package.json +1 -1
  43. package/dist/apps/chat-ui/assets/index-AjnP3ci-.js +0 -228
  44. package/dist/apps/chat-ui/assets/index-BJ56TREg.css +0 -1
@@ -11,11 +11,11 @@
11
11
  <link rel="manifest" href="/apps/chat/manifest.webmanifest" />
12
12
  <link rel="apple-touch-icon" href="/apps/chat/assets/pwa-images/ios/180.png" />
13
13
  <title>Pibo Web Chat</title>
14
- <script type="module" crossorigin src="/apps/chat/assets/index-AjnP3ci-.js"></script>
14
+ <script type="module" crossorigin src="/apps/chat/assets/index-DhX1_aRM.js"></script>
15
15
  <link rel="modulepreload" crossorigin href="/apps/chat/assets/dist-CqM4On9D.js">
16
16
  <link rel="modulepreload" crossorigin href="/apps/chat/assets/dist-DLJCGrGQ.js">
17
17
  <link rel="modulepreload" crossorigin href="/apps/chat/assets/dist-S3zJGntM.js">
18
- <link rel="stylesheet" crossorigin href="/apps/chat/assets/index-BJ56TREg.css">
18
+ <link rel="stylesheet" crossorigin href="/apps/chat/assets/index-0WZI2phJ.css">
19
19
  </head>
20
20
  <body>
21
21
  <div id="root"></div>
package/dist/cli.js CHANGED
@@ -3,18 +3,24 @@ import { Command } from "commander";
3
3
  import { PIBO_CONFIG_KEYS, getDefaultPiboConfigPath, deletePiboConfigValue, getDisplayPiboConfigValue, loadPiboConfig, redactPiboConfig, savePiboConfig, setPiboConfigValue, } from "./config/config.js";
4
4
  import { parsePiboThinkingLevel } from "./core/thinking.js";
5
5
  import { ensurePrivatePiboHome, piboHomePath } from "./core/pibo-home.js";
6
- async function createCliProfile(profileName) {
6
+ async function resolveCliProfile(profileName) {
7
7
  const { createDefaultPiboPluginRegistry, createGatewayProducerPiboProfile, createPiboProfileFromRegistryOrDefault } = await import("./plugins/builtin.js");
8
- if (profileName === "gateway-producer" || profileName === "pibo-gateway-producer") {
9
- return createGatewayProducerPiboProfile();
10
- }
11
8
  const registry = createDefaultPiboPluginRegistry();
12
9
  const chatAgentStorePath = piboHomePath("chat-agents.sqlite");
13
10
  if (existsSync(chatAgentStorePath)) {
14
11
  const { createPiboChatCustomAgentProfilesPlugin } = await import("./plugins/chat-custom-agents.js");
15
12
  registry.registerPlugin(createPiboChatCustomAgentProfilesPlugin({ agentStorePath: chatAgentStorePath }));
16
13
  }
17
- return createPiboProfileFromRegistryOrDefault(registry, profileName);
14
+ const profile = profileName === "gateway-producer" || profileName === "pibo-gateway-producer"
15
+ ? createGatewayProducerPiboProfile()
16
+ : createPiboProfileFromRegistryOrDefault(registry, profileName);
17
+ return {
18
+ profile,
19
+ resolveSubagentProfile: (targetProfile) => createPiboProfileFromRegistryOrDefault(registry, targetProfile),
20
+ };
21
+ }
22
+ async function createCliProfile(profileName) {
23
+ return (await resolveCliProfile(profileName)).profile;
18
24
  }
19
25
  function printJson(value) {
20
26
  console.log(JSON.stringify(value, null, 2));
@@ -363,7 +369,11 @@ export async function runPiboCli(argv = process.argv) {
363
369
  .addHelpText("after", "\nProfiles include built-in plugin profiles plus active saved Chat custom agents from $PIBO_HOME/chat-agents.sqlite. Archived custom agents are not exposed.\n")
364
370
  .action(async (profile) => {
365
371
  const { inspectPiboProfile } = await import("./core/runtime.js");
366
- printJson(await inspectPiboProfile({ profile: await createCliProfile(profile) }));
372
+ const resolved = await resolveCliProfile(profile);
373
+ printJson(await inspectPiboProfile({
374
+ profile: resolved.profile,
375
+ subagentProfileResolver: resolved.resolveSubagentProfile,
376
+ }));
367
377
  });
368
378
  program
369
379
  .command("tui")
@@ -1,6 +1,7 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { resolve } from "node:path";
3
3
  import { createDefaultPiboProfile } from "./default-profile.js";
4
+ import { loadPiboModelDefaults, selectRequestedModelProfile, selectRequestedThinkingLevel } from "./model-defaults.js";
4
5
  import { getMcpAgentContextFile } from "../mcp/agent-context.js";
5
6
  import { PIBO_GOAL_TOOL_NAMES } from "../loops/tools.js";
6
7
  import { getInstalledCliToolContextFile } from "../tools/registry.js";
@@ -9,8 +10,33 @@ import { buildPiboAvailableTools, buildPiboGuidelines, hasPiboSystemPromptTempla
9
10
  import { buildCodexCompatSystemPrompt } from "./codex-compat.js";
10
11
  import { readPiboBasePrompt } from "./base-prompt.js";
11
12
  import { DEFAULT_BUILTIN_TOOL_NAMES, InitialSessionContext } from "./profiles.js";
13
+ import { resolvePiboSubagentRuntimeSelections } from "../subagents/runtime-selection.js";
12
14
  import { createPiboRuntime } from "./runtime.js";
13
15
  import { getDefaultPiboWorkspace } from "./workspace.js";
16
+ export function createPiboRuntimeResolutionManifest(input) {
17
+ const modelDefaults = input.modelDefaults ?? loadPiboModelDefaults(input.cwd);
18
+ const effectiveModel = input.activeModel ?? selectRequestedModelProfile(input.profile, modelDefaults);
19
+ const effectiveThinkingLevel = input.thinkingLevel ?? selectRequestedThinkingLevel(input.profile, modelDefaults);
20
+ const delegatedAgents = resolvePiboSubagentRuntimeSelections(input.profile.subagents, input.subagentProfileResolver, modelDefaults).filter((subagent) => subagent.enabled).map(({ enabled: _enabled, ...subagent }) => subagent);
21
+ return {
22
+ version: 1,
23
+ profileName: input.profile.profileName,
24
+ runtimeInstanceId: input.profile.runtimeInstanceId,
25
+ ...(input.adapterId ? { adapterId: input.adapterId } : {}),
26
+ ...(input.piboSessionId ? { piboSessionId: input.piboSessionId } : {}),
27
+ ...(input.piboRoomId ? { piboRoomId: input.piboRoomId } : {}),
28
+ cwd: input.cwd,
29
+ ...(effectiveModel ? { effectiveModel: { ...effectiveModel } } : {}),
30
+ ...(effectiveThinkingLevel ? { effectiveThinkingLevel } : {}),
31
+ toolSurface: input.toolSurface ?? "complete",
32
+ activeToolNames: [...input.activeToolNames],
33
+ yieldableToolNames: [...(input.yieldableToolNames ?? [])],
34
+ activeToolPackages: [...(input.activeToolPackages ?? [])],
35
+ contextFilePaths: [...input.contextFilePaths],
36
+ skillNames: [...input.skillNames],
37
+ delegatedAgents,
38
+ };
39
+ }
14
40
  const SECRET_KEY_RE = /(api[_-]?key|authorization|bearer|cookie|credential|oauth|password|secret|token)/i;
15
41
  const SECRET_TEXT_PATTERNS = [
16
42
  /\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,
@@ -29,6 +55,8 @@ function jsonText(value) {
29
55
  return JSON.stringify(value, null, 2);
30
56
  }
31
57
  function estimateDirectNodeTokens(node) {
58
+ if (node.kind === "runtime_manifest")
59
+ return 0;
32
60
  let tokens = 0;
33
61
  if (node.hydratedText)
34
62
  tokens += estimateTokens(node.hydratedText);
@@ -196,9 +224,6 @@ function withoutRequestedModels(profile) {
196
224
  function resolveProfilePath(cwd, path) {
197
225
  return path.startsWith("pibo://") ? path : resolve(cwd, path);
198
226
  }
199
- function activeModelFor(profile, options) {
200
- return options.activeModel ?? profile.mainModel ?? profile.model;
201
- }
202
227
  function toolDefinitionSchema(definition, toolInfo) {
203
228
  return definition?.parameters ?? toolInfo?.parameters;
204
229
  }
@@ -218,7 +243,7 @@ function generatedOriginForTool(name, profile) {
218
243
  return undefined;
219
244
  }
220
245
  function sourceForContextFile(path, profile, cwd) {
221
- if (path === "pibo://runtime/session-context.md")
246
+ if (path === "pibo://runtime/session-context.md" || path === "pibo://runtime/delegated-agents.md")
222
247
  return "runtime";
223
248
  if (path.endsWith(".pibo/context/installed-pibo-tools.md") || path === ".pibo/context/installed-pibo-tools.md")
224
249
  return "generated";
@@ -690,7 +715,42 @@ export async function inspectPiboContextBuild(options = {}) {
690
715
  hydratedText: "Codex compatibility wraps the base system prompt and adds apply_patch/view_image tools when enabled.",
691
716
  });
692
717
  }
718
+ const runStartSchema = runtime.session.getToolDefinition("pibo_run_start")?.parameters;
719
+ const yieldableToolNames = Array.isArray(runStartSchema?.properties?.toolName?.enum)
720
+ ? runStartSchema.properties.toolName.enum.filter((name) => typeof name === "string")
721
+ : [];
722
+ const activeToolPackages = [
723
+ ...(PIBO_GOAL_TOOL_NAMES.some((name) => activeToolNames.has(name)) ? ["pibo-goal-control"] : []),
724
+ ...(activeToolNames.has("apply_patch") || activeToolNames.has("view_image") ? ["codex-compat"] : []),
725
+ ...(activeToolNames.has("pibo_run_start") ? ["pibo-run-control"] : []),
726
+ ];
727
+ const runtimeManifest = createPiboRuntimeResolutionManifest({
728
+ profile,
729
+ cwd,
730
+ adapterId: "pi",
731
+ piboSessionId: options.sessionContext?.piboSessionId,
732
+ piboRoomId: options.sessionContext?.piboRoomId,
733
+ activeModel: options.activeModel,
734
+ thinkingLevel: options.thinkingLevel,
735
+ activeToolNames: toolNames,
736
+ yieldableToolNames,
737
+ activeToolPackages,
738
+ contextFilePaths: contextChildren.flatMap((node) => node.path ? [node.path] : []),
739
+ skillNames: skillChildren.map((node) => node.title),
740
+ modelDefaults: options.modelDefaults,
741
+ subagentProfileResolver: options.subagentProfileResolver,
742
+ });
693
743
  const topLevel = [
744
+ {
745
+ id: "runtime-manifest",
746
+ kind: "runtime_manifest",
747
+ title: "Runtime Resolution Manifest",
748
+ source: "runtime",
749
+ state: "active",
750
+ badges: ["RESOLVED", "READ-ONLY"],
751
+ payloadJson: runtimeManifest,
752
+ notes: ["Resolution evidence for this inspection only. It is not a second profile configuration and is not injected into the agent prompt."],
753
+ },
694
754
  {
695
755
  id: "prompt",
696
756
  kind: "prompt_section",
@@ -698,7 +758,7 @@ export async function inspectPiboContextBuild(options = {}) {
698
758
  source: "runtime",
699
759
  state: "active",
700
760
  badges: ["ACTIVE"],
701
- metadata: { childCount: promptChildren.length, activeModel: activeModelFor(profile, options) },
761
+ metadata: { childCount: promptChildren.length, activeModel: runtimeManifest.effectiveModel },
702
762
  children: promptChildren,
703
763
  },
704
764
  {
@@ -804,7 +864,7 @@ export async function inspectPiboContextBuild(options = {}) {
804
864
  piboSessionId: options.sessionContext?.piboSessionId,
805
865
  piboRoomId: options.sessionContext?.piboRoomId,
806
866
  cwd,
807
- activeModel: activeModelFor(profile, options),
867
+ activeModel: runtimeManifest.effectiveModel,
808
868
  summary: {
809
869
  topLevelNodes: nodes.length,
810
870
  totalNodes: countNodes(nodes),
@@ -3,16 +3,24 @@ import { dirname, resolve } from "node:path";
3
3
  import { piboHomePath } from "./pibo-home.js";
4
4
  import { isPiboThinkingLevel } from "./thinking.js";
5
5
  export const DEFAULT_PIBO_MODEL_DEFAULTS_PATH = "model-defaults.json";
6
- export function selectRequestedModelProfile(profile, defaults = {}) {
6
+ export function selectRequestedSubagentModelProfile(profile, defaults = {}) {
7
7
  if (profile.model)
8
8
  return cloneModelProfile(profile.model);
9
+ return cloneModelProfile(profile.subagentModel ?? defaults.subagent);
10
+ }
11
+ export function selectRequestedModelProfile(profile, defaults = {}) {
9
12
  if (profile.parentSessionId)
10
- return cloneModelProfile(profile.subagentModel ?? defaults.subagent);
13
+ return selectRequestedSubagentModelProfile(profile, defaults);
14
+ if (profile.model)
15
+ return cloneModelProfile(profile.model);
11
16
  return cloneModelProfile(profile.mainModel ?? defaults.main);
12
17
  }
18
+ export function selectRequestedSubagentThinkingLevel(profile, defaults = {}) {
19
+ return profile.subagentThinkingLevel ?? profile.thinkingLevel ?? defaults.subagentThinking ?? defaults.thinking;
20
+ }
13
21
  export function selectRequestedThinkingLevel(profile, defaults = {}) {
14
22
  if (profile.parentSessionId)
15
- return profile.subagentThinkingLevel ?? profile.thinkingLevel ?? defaults.subagentThinking ?? defaults.thinking;
23
+ return selectRequestedSubagentThinkingLevel(profile, defaults);
16
24
  return profile.mainThinkingLevel ?? profile.thinkingLevel ?? defaults.mainThinking ?? defaults.thinking;
17
25
  }
18
26
  export function selectRequestedFastMode(profile, defaults = {}) {