@liy/agent-runner 0.2.2 → 0.2.4

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.js CHANGED
@@ -15637,7 +15637,6 @@ var driverOwnedPiFlags = /* @__PURE__ */ new Set([
15637
15637
  "--provider",
15638
15638
  "--model",
15639
15639
  "--thinking",
15640
- "--no-extensions",
15641
15640
  "--no-prompt-templates",
15642
15641
  "--no-themes"
15643
15642
  ]);
@@ -15683,7 +15682,6 @@ function buildPiRpcArgs(harness) {
15683
15682
  "--thinking",
15684
15683
  thinking,
15685
15684
  "--no-session",
15686
- "--no-extensions",
15687
15685
  "--no-prompt-templates",
15688
15686
  "--no-themes",
15689
15687
  ...extraArgs
@@ -15846,6 +15844,9 @@ function validateExtraPiArgs(args) {
15846
15844
  if (driverOwnedPiFlags.has(flag)) {
15847
15845
  throw new Error(`pi-rpc harness args cannot include driver-owned Pi flag: ${flag}`);
15848
15846
  }
15847
+ if (flag === "--no-extensions") {
15848
+ throw new Error("pi-rpc harness args cannot disable Pi extensions");
15849
+ }
15849
15850
  if (blockedPiFlags.has(flag)) {
15850
15851
  throw new Error(`pi-rpc harness args cannot include unsupported Pi flag: ${flag}`);
15851
15852
  }
@@ -15868,6 +15869,52 @@ function formatPiRpcError(parsed, redactText) {
15868
15869
  return "unknown error";
15869
15870
  }
15870
15871
 
15872
+ // src/prompt.ts
15873
+ import { existsSync, readFileSync } from "node:fs";
15874
+ var harnessPromptTemplateFileName = "execute-task.md";
15875
+ function buildHarnessPrompt(spec) {
15876
+ return renderHarnessPromptTemplate({
15877
+ template: loadDefaultHarnessPromptTemplate(),
15878
+ values: {
15879
+ workspaceDir: spec.workspaceDir,
15880
+ completionFile: `${spec.workspaceDir}/state/completion.json`,
15881
+ artifactRoot: `${spec.workspaceDir}/artifacts`,
15882
+ taskTitle: spec.task.title,
15883
+ taskContext: spec.task.context,
15884
+ intentJson: JSON.stringify(spec.intent, null, 2),
15885
+ userQueryJson: JSON.stringify(spec.userQuery, null, 2),
15886
+ approvedToolsJson: JSON.stringify(spec.toolProvisioning.tools, null, 2)
15887
+ }
15888
+ });
15889
+ }
15890
+ function resolveAgentRunnerPromptDir(importUrl = import.meta.url) {
15891
+ const candidates = [
15892
+ new URL("../prompts/", importUrl),
15893
+ new URL("./prompts/", importUrl)
15894
+ ];
15895
+ return candidates.find(hasHarnessPromptTemplate) ?? candidates[0];
15896
+ }
15897
+ function hasHarnessPromptTemplate(promptDir) {
15898
+ return existsSync(new URL(harnessPromptTemplateFileName, promptDir));
15899
+ }
15900
+ function loadDefaultHarnessPromptTemplate() {
15901
+ return readFileSync(new URL(harnessPromptTemplateFileName, resolveAgentRunnerPromptDir()), "utf8");
15902
+ }
15903
+ function renderHarnessPromptTemplate(input) {
15904
+ let rendered = input.template;
15905
+ const placeholders = new Set(
15906
+ Array.from(input.template.matchAll(/{{([a-zA-Z0-9_]+)}}/g), (match) => match[1])
15907
+ );
15908
+ for (const placeholder of placeholders) {
15909
+ const value = input.values[placeholder];
15910
+ if (value === void 0) {
15911
+ throw new Error(`missing harness prompt template value: ${placeholder}`);
15912
+ }
15913
+ rendered = rendered.replaceAll(`{{${placeholder}}}`, value);
15914
+ }
15915
+ return rendered.trimEnd();
15916
+ }
15917
+
15871
15918
  // src/runner.ts
15872
15919
  var forbiddenSecretKeyPattern = /(API[_-]?KEY|ACCESS[_-]?KEY|SECRET|TOKEN|PASSWORD|POSTGRES|DATABASE_URL|SPRITES|OSS|ALIYUN)/i;
15873
15920
  var allowedHarnessEnvKeys = /* @__PURE__ */ new Set([
@@ -15975,36 +16022,6 @@ function createHarnessEnvironment(input) {
15975
16022
  assertNoForbiddenHarnessEnv(harnessEnv, allowedForbiddenKeys);
15976
16023
  return harnessEnv;
15977
16024
  }
15978
- function buildHarnessPrompt(spec) {
15979
- return [
15980
- "You are the Mote execute_task Task Agent.",
15981
- "",
15982
- "Use only the configured model and tool endpoints. A direct provider token may be present temporarily; never log it, persist it, print it, or write it to artifacts.",
15983
- `Workspace: ${spec.workspaceDir}`,
15984
- `State file: ${spec.workspaceDir}/state/completion.json`,
15985
- `Artifact root: ${spec.workspaceDir}/artifacts`,
15986
- "",
15987
- "Task",
15988
- `Title: ${spec.task.title}`,
15989
- spec.task.context,
15990
- "",
15991
- "Intent",
15992
- JSON.stringify(spec.intent, null, 2),
15993
- "",
15994
- "User Query",
15995
- JSON.stringify(spec.userQuery, null, 2),
15996
- "",
15997
- "Approved Tools",
15998
- JSON.stringify(spec.toolProvisioning.tools, null, 2),
15999
- "",
16000
- "Artifact contract",
16001
- "- Allocate a UUID directory under artifacts for each artifact.",
16002
- "- Write artifact.json in that directory using the TaskArtifactDraft contract.",
16003
- "- Dataset artifacts must put schema and preview rows in artifact.json and the full CSV in data.csv.",
16004
- "- Write terminal status to state/completion.json with status, summary, and artifactIds.",
16005
- "- Never include secrets, tokens, provider keys, DB credentials, or OSS credentials in artifacts, logs, or completion."
16006
- ].join("\n");
16007
- }
16008
16025
  async function readTaskRunnerSpec(path) {
16009
16026
  return JSON.parse(await readFile3(path, "utf8"));
16010
16027
  }