perstack 0.0.126 → 0.0.128

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/bin/cli.js CHANGED
@@ -21092,7 +21092,7 @@ async function expertVersionsHandler(scopeName, options) {
21092
21092
  }
21093
21093
  //#endregion
21094
21094
  //#region ../../packages/runtime/package.json
21095
- var version$1 = "0.0.137";
21095
+ var version$1 = "0.0.139";
21096
21096
  //#endregion
21097
21097
  //#region ../../packages/runtime/src/helpers/usage.ts
21098
21098
  function createEmptyUsage() {
@@ -92481,65 +92481,59 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
92481
92481
  }
92482
92482
  exports.dedent = dedent;
92483
92483
  })))();
92484
- function getEnvironmentSection(startedAt) {
92485
- const lines = [`- Current time: ${new Date(startedAt).toISOString()}`, `- Working directory: ${process.cwd()}`];
92484
+ function getEnvironmentSection() {
92485
+ const lines = [`- Platform: ${os.platform()} ${os.release()} (${os.arch()})`];
92486
92486
  if (process.env.PERSTACK_SANDBOX === "1") lines.push("- Sandbox: This is an isolated container environment (Ubuntu). You can freely install packages with `sudo apt-get install` and run arbitrary commands without affecting the host system.");
92487
92487
  return `Environment:\n${lines.join("\n")}`;
92488
92488
  }
92489
- function getDelegateMetaInstruction(startedAt) {
92489
+ function getDelegateMetaInstruction() {
92490
92490
  return import_dist.dedent`
92491
92491
  Before starting work, investigate the workspace and understand the current state. Then use the todo tool to create a plan of action. Work through the todos step by step, marking each completed as you go.
92492
92492
 
92493
92493
  When the task is complete, call attemptCompletion with a result parameter containing your final response.
92494
92494
  When you cannot help, call attemptCompletion without a result.
92495
92495
 
92496
- ${getEnvironmentSection(startedAt)}
92496
+ ${getEnvironmentSection()}
92497
92497
  `;
92498
92498
  }
92499
- function getCoordinatorMetaInstruction(startedAt) {
92499
+ function getCoordinatorMetaInstruction() {
92500
92500
  return import_dist.dedent`
92501
- Your role:
92502
- - Act as the coordinator for the given task: define the task, set goals, and delegate.
92503
- - Decompose tasks and delegate subtasks to delegate experts.
92504
- - Review and aggregate deliverables from delegates.
92505
- - Determine whether the task meets the completion criteria.
92501
+ You are a thin coordinator. Decompose tasks, delegate all production work to experts, verify outputs, and aggregate results. Never produce deliverables yourself.
92506
92502
 
92507
92503
  Rules:
92508
- - Never produce deliverables yourself. You are a thin coordinatorroute all production work to delegates.
92509
- - Always verify delegate outputs yourself. You are the gatekeeper: run code to confirm it works, read documents to confirm content quality, call APIs to confirm data was persisted, and cross-check research claims with independent sources. Never trust delegate results at face value.
92510
- - Delegates receive only the query string, not your conversation history. Use workspace files to exchange data between delegates (e.g., have delegate A write results to a file, then instruct delegate B to read that file).
92504
+ - Always verify delegate outputs. Never trust results at face value run code, read documents, check data.
92505
+ - Delegates receive only the query string, not your conversation history. Use workspace files to pass data between delegates.
92511
92506
 
92512
92507
  Workflow:
92513
92508
  1. Investigate the workspace and understand the current state.
92514
- 2. Decompose the task into fine-grained subtasks and create todos.
92515
- 3. Delegate subtasks to experts in parallel. Maximize parallelism delegate to multiple types of experts and run multiple experts of the same type concurrently.
92516
- 4. Review delegate outputs: verify deliverables exist, check consistency across outputs, and validate against the original request.
92517
- 5. If a delegate fails, assess the error and decide: retry the same delegate, delegate to a different expert, or report the failure.
92518
- 6. Aggregate results and ensure the workspace contains only clean deliverables.
92509
+ 2. Decompose the task into subtasks and create todos.
92510
+ 3. Delegate subtasks to experts. Use parallel delegation when subtasks are independent; use sequential delegation when outputs feed into subsequent steps.
92511
+ 4. Verify delegate outputs against the original request.
92512
+ 5. On failure: retry, reassign, or report.
92513
+ 6. Aggregate results and clean up the workspace.
92519
92514
 
92520
- Delegation best practices:
92521
- - Delegate experts are purpose-specialized, so they handle individual tasks better than you.
92522
- - To avoid context explosion, do not assign one large subtask to a single delegate. Instead, decompose it into fine-grained subtasks and assign them to multiple delegates.
92523
- - Higher parallelism leads to faster task completion and improved accuracy.
92524
- - Specificity: Include context, file paths, constraints, and expected output format in every delegation. No vague delegations.
92525
- - If no suitable delegate exists for a given purpose, use createExpert to create a purpose-specialized expert, then addDelegate to make it available as a delegate.
92515
+ Delegation guidelines:
92516
+ - Be specific: include context, file paths, constraints, and expected output format. No vague delegations.
92517
+ - Break large subtasks into focused units rather than overloading a single delegate.
92518
+ - If no suitable delegate exists, use createExpert to create one, then addDelegate to register it.
92526
92519
 
92527
- Task completion criteria:
92528
- - The user's request has been fully fulfilled.
92529
- - The task deliverables are confirmed to be high quality: high-quality deliverables are defined as those that are verifiable by the user, available, and professional.
92530
- - Cleanup is complete: remove temporary or scratch files that are clearly not deliverables (e.g., debug logs, scratch notes). Do NOT delete files that were explicitly created as part of the task workflow (e.g., config files, plans, reports) — when in doubt, keep the file.
92520
+ Workspace cleanup:
92521
+ - Before calling attemptCompletion, remove all files that were NOT part of the original workspace and are NOT deliverables.
92522
+ - Delete: temporary files, scratch notes, debug logs, intermediate outputs, and any files created solely for inter-delegate communication.
92523
+ - Keep: files explicitly requested by the user, final deliverables, and files that existed before the task started.
92524
+ - When in doubt whether a file is a deliverable, keep it.
92531
92525
 
92532
92526
  When the task is complete, call attemptCompletion with a result parameter containing your final response.
92533
92527
  When you cannot help, call attemptCompletion without a result.
92534
92528
 
92535
- ${getEnvironmentSection(startedAt)}
92529
+ ${getEnvironmentSection()}
92536
92530
  `;
92537
92531
  }
92538
- function createInstructionMessage(expert, startedAt) {
92532
+ function createInstructionMessage(expert) {
92539
92533
  const preamble = import_dist.dedent`
92540
92534
  You are Perstack, an AI expert that tackles tasks requested by users by utilizing all available tools.
92541
92535
 
92542
- ${isCoordinatorExpert(expert.name) ? getCoordinatorMetaInstruction(startedAt) : getDelegateMetaInstruction(startedAt)}
92536
+ ${isCoordinatorExpert(expert.name) ? getCoordinatorMetaInstruction() : getDelegateMetaInstruction()}
92543
92537
  `;
92544
92538
  const contents = [{
92545
92539
  id: createId(),
@@ -92597,7 +92591,7 @@ async function initLogic({ setting, checkpoint }) {
92597
92591
  if (!setting.model) throw new Error("Model is not resolved");
92598
92592
  return startRun(setting, checkpoint, {
92599
92593
  initialCheckpoint: checkpoint,
92600
- inputMessages: [createInstructionMessage(expert, setting.startedAt), createUserMessage([{
92594
+ inputMessages: [createInstructionMessage(expert), createUserMessage([{
92601
92595
  type: "textPart",
92602
92596
  text: setting.input.text
92603
92597
  }])],
@@ -121243,7 +121237,7 @@ function useDelegationTree() {
121243
121237
  formattedCachedInputTokens: formatTokenCount(state.jobCachedInputTokens),
121244
121238
  formattedOutputTokens: formatTokenCount(state.jobOutputTokens),
121245
121239
  providerName: state.providerName,
121246
- cacheHitRate: state.jobInputTokens + state.jobCachedInputTokens > 0 ? (state.jobCachedInputTokens / (state.jobInputTokens + state.jobCachedInputTokens) * 100).toFixed(2) : "0.00"
121240
+ cacheHitRate: state.jobInputTokens > 0 ? (state.jobCachedInputTokens / state.jobInputTokens * 100).toFixed(2) : "0.00"
121247
121241
  };
121248
121242
  }
121249
121243
  //#endregion
@@ -121441,16 +121435,17 @@ const InterfacePanel = ({ query, runStatus, onSubmit, delegationTreeState, runni
121441
121435
  dimColor: true,
121442
121436
  children: [
121443
121437
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: "Tokens: " }),
121444
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: ["In ", formattedInputTokens] }),
121445
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [" · Out ", formattedOutputTokens] }),
121446
121438
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
121447
- " ",
121448
- "· Cache ",
121439
+ "In ",
121440
+ formattedInputTokens,
121441
+ " (Cached ",
121449
121442
  formattedCachedInputTokens,
121450
- "/",
121443
+ ", Cache Hit",
121444
+ " ",
121451
121445
  cacheHitRate,
121452
- "%"
121446
+ "%)"
121453
121447
  ] }),
121448
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [" · Out ", formattedOutputTokens] }),
121454
121449
  formattedReasoningTokens !== "0" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [" · Reasoning ", formattedReasoningTokens] }) : null
121455
121450
  ]
121456
121451
  })
@@ -121946,8 +121941,7 @@ function statusColor$3(status) {
121946
121941
  }
121947
121942
  function JobInfoContent({ job }) {
121948
121943
  const duration = formatDuration$1(job.startedAt, job.finishedAt);
121949
- const totalInput = job.usage.inputTokens + (job.usage.cachedInputTokens ?? 0);
121950
- const cacheRate = totalInput > 0 ? (job.usage.cachedInputTokens ?? 0) / totalInput * 100 : 0;
121944
+ const cacheRate = job.usage.inputTokens > 0 ? (job.usage.cachedInputTokens ?? 0) / job.usage.inputTokens * 100 : 0;
121951
121945
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
121952
121946
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
121953
121947
  wrap: "truncate",
@@ -121989,16 +121983,17 @@ function JobInfoContent({ job }) {
121989
121983
  children: [
121990
121984
  "Tokens: In ",
121991
121985
  formatTokenCount(job.usage.inputTokens),
121992
- " · Out",
121993
- " ",
121994
- formatTokenCount(job.usage.outputTokens),
121995
121986
  (job.usage.cachedInputTokens ?? 0) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
121996
- " · Cache ",
121987
+ " ",
121988
+ "(Cached ",
121997
121989
  formatTokenCount(job.usage.cachedInputTokens ?? 0),
121998
- "/",
121990
+ ", Cache Hit",
121991
+ " ",
121999
121992
  cacheRate.toFixed(2),
122000
- "%"
122001
- ] }) : null
121993
+ "%)"
121994
+ ] }) : null,
121995
+ " · Out ",
121996
+ formatTokenCount(job.usage.outputTokens)
122002
121997
  ]
122003
121998
  })
122004
121999
  ] });
@@ -122038,16 +122033,17 @@ function RunInfoContent({ run, treeNode, providerName, checkpointCount, eventCou
122038
122033
  children: [
122039
122034
  "Tokens: In ",
122040
122035
  formatTokenCount(treeNode.inputTokens),
122041
- " · Out",
122042
- " ",
122043
- formatTokenCount(treeNode.outputTokens),
122044
122036
  treeNode.cachedInputTokens > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
122045
- " · Cache ",
122037
+ " ",
122038
+ "(Cached ",
122046
122039
  formatTokenCount(treeNode.cachedInputTokens),
122047
- "/",
122048
- (treeNode.cachedInputTokens / (treeNode.inputTokens + treeNode.cachedInputTokens) * 100).toFixed(2),
122049
- "%"
122050
- ] }) : null
122040
+ ", Cache Hit",
122041
+ " ",
122042
+ (treeNode.inputTokens > 0 ? treeNode.cachedInputTokens / treeNode.inputTokens * 100 : 0).toFixed(2),
122043
+ "%)"
122044
+ ] }) : null,
122045
+ " · Out ",
122046
+ formatTokenCount(treeNode.outputTokens)
122051
122047
  ]
122052
122048
  }) : null
122053
122049
  ] });
@@ -124513,7 +124509,7 @@ async function startHandler(expertKey, query, options, handlerOptions) {
124513
124509
  //#endregion
124514
124510
  //#region package.json
124515
124511
  var name = "perstack";
124516
- var version = "0.0.126";
124512
+ var version = "0.0.128";
124517
124513
  var description = "PerStack CLI";
124518
124514
  //#endregion
124519
124515
  //#region bin/cli.ts