@pasko70/pibo 1.7.6 → 1.7.7

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.
@@ -1,5 +1,6 @@
1
1
  import { createDefaultPiboPlugins } from "../plugins/builtin.js";
2
2
  import { createPiboBetterAuthPlugin } from "../plugins/better-auth.js";
3
+ import { createPiboChatCustomAgentProfilesPlugin } from "../plugins/chat-custom-agents.js";
3
4
  import { createPiboChatWebPlugin } from "../plugins/chat-web.js";
4
5
  import { createPiboChatVscodeWebPlugin } from "../plugins/chat-vscode-web.js";
5
6
  import { createPiboContextFilesPlugin } from "../plugins/context-files.js";
@@ -144,6 +145,7 @@ export function createWebPiboPluginRegistry(options = {}) {
144
145
  useDevAuth ? createPiboDevAuthPlugin() : createPiboBetterAuthPlugin(resolvedOptions.auth),
145
146
  createPiboWebHostPlugin({ announce: false, canonicalBaseURL: useDevAuth ? undefined : authBaseURL(resolvedOptions), gatewayMode: webGatewayMode(resolvedOptions, useDevAuth), ...resolvedOptions.web }),
146
147
  createPiboCronPlugin({ cronStorePath: resolvedOptions.chat?.cronStorePath, dataStorePath: resolvedOptions.chat?.dataStorePath, dataPayloadRootDir: resolvedOptions.chat?.dataPayloadRootDir }),
148
+ createPiboChatCustomAgentProfilesPlugin({ agentStorePath: resolvedOptions.chat?.agentStorePath }),
147
149
  createPiboRalphPlugin({ ralphStorePath: resolvedOptions.chat?.ralphStorePath, dataStorePath: resolvedOptions.chat?.dataStorePath, dataPayloadRootDir: resolvedOptions.chat?.dataPayloadRootDir }),
148
150
  createPiboContextFilesPlugin(resolvedOptions.contextFiles),
149
151
  createPiboChatWebPlugin(resolvedOptions.chat),
@@ -0,0 +1,20 @@
1
+ import { createCustomAgentProfileDefinition } from "../apps/chat/agent-profiles.js";
2
+ import { CustomAgentStore, createDefaultCustomAgentStore } from "../apps/chat/agent-store.js";
3
+ import { definePiboPlugin } from "./registry.js";
4
+ export function createPiboChatCustomAgentProfilesPlugin(options = {}) {
5
+ return definePiboPlugin({
6
+ id: "pibo.chat-custom-agent-profiles",
7
+ name: "Pibo Chat Custom Agent Profiles",
8
+ register(api) {
9
+ const store = options.agentStorePath ? new CustomAgentStore(options.agentStorePath) : createDefaultCustomAgentStore();
10
+ try {
11
+ for (const agent of store.list()) {
12
+ api.upsertProfile(createCustomAgentProfileDefinition(agent));
13
+ }
14
+ }
15
+ finally {
16
+ store.close();
17
+ }
18
+ },
19
+ });
20
+ }
@@ -349,6 +349,7 @@ export class PiboPluginRegistry {
349
349
  upsertContextFile: (contextFile) => this.upsertContextFile(withPluginContext(contextFile)),
350
350
  removeContextFile: (key) => this.removeContextFile(key),
351
351
  registerProfile: (profile) => this.registerProfile(profile),
352
+ upsertProfile: (profile) => this.upsertProfile(profile),
352
353
  registerGatewayAction: (action) => this.registerGatewayAction(action),
353
354
  registerChannel: (channel) => this.registerChannel(channel),
354
355
  registerAuthService: (service) => this.registerAuthService(service),
@@ -10,6 +10,7 @@ import { createDefaultPiboRalphStore } from './store.js';
10
10
  import { createBuiltInRalphStopConditions, evaluateRalphStopPolicy } from './stopping.js';
11
11
  const CHAT_WEB_CHANNEL = 'pibo.chat-web';
12
12
  function errorMessage(error) { return error instanceof Error ? error.message : String(error); }
13
+ function isUnknownProfileErrorMessage(message) { return /^Unknown profile "[^"]+"/.test(message); }
13
14
  function buildRalphPrompt(job) { return ['You are running a continuous Pibo Ralph job.', `Job: ${job.name}`, `Target: ${job.target.kind}`, '', 'Complete the task below. Return the result in this session. When this session finishes, Ralph may start a fresh session with the same task unless a configured stop condition is satisfied.', 'Important: if this job uses a promise-complete stop condition, do not quote, negate, explain, or mention its literal completion marker unless the task is fully complete and you intend to stop the job.', '', 'Task:', job.prompt].join('\n'); }
14
15
  function isJsonObject(value) { return !!value && typeof value === 'object' && !Array.isArray(value); }
15
16
  function mergeRunResources(jobResources, runResources) {
@@ -134,9 +135,11 @@ export class PiboRalphService {
134
135
  }
135
136
  catch (error) {
136
137
  const cancelled = this.cancelledRuns.delete(run.id);
137
- const outcome = { status: cancelled ? 'cancelled' : 'error', error: cancelled ? undefined : errorMessage(error) };
138
+ const message = errorMessage(error);
139
+ const fatalProfileError = !cancelled && isUnknownProfileErrorMessage(message);
140
+ const outcome = { status: cancelled ? 'cancelled' : 'error', error: cancelled ? undefined : message };
138
141
  const { evaluation, conditionStates } = await this.evaluateStopPolicy(this.store.getJob(job.id) ?? job, 'after-run', run, outcome);
139
- this.store.completeRun({ jobId: job.id, runId: run.id, status: outcome.status, error: outcome.error, reason: cancelled ? 'cancelled' : evaluation.reason, stopAfterRun: evaluation.finalAction !== 'continue', stopEvaluation: evaluation, conditionStates });
142
+ this.store.completeRun({ jobId: job.id, runId: run.id, status: outcome.status, error: outcome.error, reason: cancelled ? 'cancelled' : fatalProfileError ? 'unknown-profile' : evaluation.reason, stopAfterRun: fatalProfileError || evaluation.finalAction !== 'continue', stopEvaluation: evaluation, conditionStates });
140
143
  await this.cleanupRunResources(job, run);
141
144
  if (!cancelled)
142
145
  console.error(`[ralph] job ${job.id} failed`, error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pasko70/pibo",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "vscode": "./src/apps/chat-vscode/extension/src/vscode-shim.js"