@eigenpal/cli 0.20.48 → 0.20.50

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/cli.js CHANGED
@@ -16814,6 +16814,14 @@ function validateWorkspaceSchema(content, _filename) {
16814
16814
  checkEigenpalTypeExtension(schema, "", errors);
16815
16815
  return { valid: errors.length === 0, errors };
16816
16816
  }
16817
+ function validateAgentSchema(content, filename) {
16818
+ try {
16819
+ const schema = JSON.parse(content);
16820
+ if (schema !== null && typeof schema === "object" && !Array.isArray(schema) && Object.keys(schema).length === 0)
16821
+ return { valid: true, errors: [] };
16822
+ } catch {}
16823
+ return validateWorkspaceSchema(content, filename);
16824
+ }
16817
16825
  function checkEigenpalTypeExtension(node, path, errors, seen = new WeakSet) {
16818
16826
  if (!node || typeof node !== "object")
16819
16827
  return;
@@ -56912,31 +56920,6 @@ var init_grammar = __esm(() => {
56912
56920
  RunTargetSchema = union([RunTargetStringSchema, RunTargetObjectSchema]);
56913
56921
  });
56914
56922
 
56915
- // ../types/src/git-source/lockfile.ts
56916
- import { createHash } from "node:crypto";
56917
- function sourceLockfileInputHash(input) {
56918
- return createHash("sha256").update(JSON.stringify(input)).digest("hex");
56919
- }
56920
- var SourceLockPackageSchema, SourceLockfileSchema;
56921
- var init_lockfile = __esm(() => {
56922
- init_zod();
56923
- init_grammar();
56924
- SourceLockPackageSchema = lazy(() => object({
56925
- packagePath: SourcePackagePathSchema,
56926
- requestedRef: SourceVersionRefSchema,
56927
- resolvedRef: string2().min(1),
56928
- resolvedTag: string2().min(1).optional(),
56929
- commit: string2().regex(SOURCE_COMMIT_SHA_PATTERN),
56930
- dependencies: array(SourceLockPackageSchema)
56931
- }));
56932
- SourceLockfileSchema = object({
56933
- lockfileVersion: literal(1),
56934
- eigenpalVersion: string2().min(1),
56935
- inputHash: string2().min(1),
56936
- root: SourceLockPackageSchema
56937
- });
56938
- });
56939
-
56940
56923
  // ../types/src/git-source/manifests.ts
56941
56924
  function workspaceDependencyNameToPackagePath(name) {
56942
56925
  const parsedName = WorkspaceDependencyNameSchema.parse(name);
@@ -57180,6 +57163,58 @@ var init_manifests = __esm(() => {
57180
57163
  SOURCE_TEMPLATE_FILE_PATTERN = /\.(?:docx|xlsx)$/i;
57181
57164
  });
57182
57165
 
57166
+ // ../types/src/git-source/agent-definition.ts
57167
+ var CompiledAgentDataSchema, CompiledAgentSnapshotSchema;
57168
+ var init_agent_definition = __esm(() => {
57169
+ init_zod();
57170
+ init_manifests();
57171
+ CompiledAgentDataSchema = strictObject({
57172
+ schemaVersion: literal(1),
57173
+ kind: literal("agent"),
57174
+ manifest: unknown().refine((value) => AgentPackageManifestSchema.safeParse(value).success, "Invalid agent manifest"),
57175
+ inputSchema: record(string2(), unknown()).optional(),
57176
+ outputSchema: record(string2(), unknown()).optional()
57177
+ });
57178
+ CompiledAgentSnapshotSchema = strictObject({
57179
+ definition: CompiledAgentDataSchema,
57180
+ sourceSha256: string2().regex(/^[a-f0-9]{64}$/),
57181
+ bundleSha256: string2().regex(/^[a-f0-9]{64}$/),
57182
+ toolchain: strictObject({
57183
+ sdkVersion: string2().min(1),
57184
+ zodVersion: string2().min(1),
57185
+ bunVersion: string2().min(1)
57186
+ })
57187
+ });
57188
+ });
57189
+
57190
+ // ../types/src/git-source/lockfile.ts
57191
+ import { createHash } from "node:crypto";
57192
+ function sourceLockfileInputHash(input) {
57193
+ return createHash("sha256").update(JSON.stringify(input)).digest("hex");
57194
+ }
57195
+ var SourceLockPackageSchema, SourceLockfileSchema;
57196
+ var init_lockfile = __esm(() => {
57197
+ init_zod();
57198
+ init_agent_definition();
57199
+ init_grammar();
57200
+ SourceLockPackageSchema = lazy(() => object({
57201
+ packagePath: SourcePackagePathSchema,
57202
+ requestedRef: SourceVersionRefSchema,
57203
+ resolvedRef: string2().min(1),
57204
+ resolvedTag: string2().min(1).optional(),
57205
+ commit: string2().regex(SOURCE_COMMIT_SHA_PATTERN),
57206
+ dependencies: array(SourceLockPackageSchema),
57207
+ compiledAgent: CompiledAgentSnapshotSchema.optional(),
57208
+ agentRuntimeConfig: record(string2(), unknown()).optional()
57209
+ }));
57210
+ SourceLockfileSchema = object({
57211
+ lockfileVersion: literal(1),
57212
+ eigenpalVersion: string2().min(1),
57213
+ inputHash: string2().min(1),
57214
+ root: SourceLockPackageSchema
57215
+ });
57216
+ });
57217
+
57183
57218
  // ../types/src/git-source/secrets.ts
57184
57219
  var SOURCE_SECRETS_FILENAME = "secrets.enc.yaml", SecretNameSchema, Base64LikeSchema, EncryptedSecretValueSchema, SourceSecretEntrySchema, SourceSecretsFileSchema;
57185
57220
  var init_secrets = __esm(() => {
@@ -57237,6 +57272,7 @@ var init_git_source = __esm(() => {
57237
57272
  init_lockfile();
57238
57273
  init_manifests();
57239
57274
  init_secrets();
57275
+ init_agent_definition();
57240
57276
  });
57241
57277
 
57242
57278
  // ../types/src/automation/triggers.ts
@@ -183331,7 +183367,7 @@ import { createRequire as __prettierCreateRequire } from "module";
183331
183367
  import { fileURLToPath as __prettierFileUrlToPath } from "url";
183332
183368
  import { dirname as __prettierDirname } from "path";
183333
183369
  import path102 from "path";
183334
- import * as path12 from "path";
183370
+ import * as path13 from "path";
183335
183371
  import * as url from "url";
183336
183372
  import path52 from "path";
183337
183373
  import * as path42 from "path";
@@ -183362,7 +183398,7 @@ import { createRequire as createRequire3 } from "module";
183362
183398
  import { equal, ok, strictEqual } from "assert";
183363
183399
  import path112 from "path";
183364
183400
  import { fileURLToPath as fileURLToPath5 } from "url";
183365
- import path13 from "path";
183401
+ import path132 from "path";
183366
183402
  import { pathToFileURL as pathToFileURL5 } from "url";
183367
183403
  import path122 from "path";
183368
183404
  import path14 from "path";
@@ -188063,11 +188099,11 @@ async function importPlugin(name, cwd) {
188063
188099
  if (isUrl(name)) {
188064
188100
  return import(name);
188065
188101
  }
188066
- if (path13.isAbsolute(name)) {
188102
+ if (path132.isAbsolute(name)) {
188067
188103
  return import(pathToFileURL5(name).href);
188068
188104
  }
188069
188105
  try {
188070
- return await import(pathToFileURL5(path13.resolve(name)).href);
188106
+ return await import(pathToFileURL5(path132.resolve(name)).href);
188071
188107
  } catch {
188072
188108
  return import_from_directory_default(name, cwd);
188073
188109
  }
@@ -188781,7 +188817,7 @@ var require3, __filename2, __dirname2, __create2, __defProp3, __getOwnPropDesc2,
188781
188817
  }
188782
188818
  }
188783
188819
  }
188784
- }, errors_exports, ConfigError, UndefinedParserError, ArgExpansionBailout, create_mockable_default, mockable, mockable_default, import_micromatch, URL_STRING_PREFIX = "file:", isUrlInstance = (value) => value instanceof URL, isUrlString = (value) => typeof value === "string" && value.startsWith(URL_STRING_PREFIX), isUrl = (urlOrPath) => isUrlInstance(urlOrPath) || isUrlString(urlOrPath), toPath = (urlOrPath) => isUrl(urlOrPath) ? url.fileURLToPath(urlOrPath) : urlOrPath, toAbsolutePath = (urlOrPath) => urlOrPath ? path12.resolve(isUrl(urlOrPath) ? url.fileURLToPath(urlOrPath) : urlOrPath) : urlOrPath, partition_default, import_editorconfig, isFile = (stats) => stats?.isFile(), isDirectory = (stats) => stats?.isDirectory(), iterate_directory_up_default, Searcher = class {
188820
+ }, errors_exports, ConfigError, UndefinedParserError, ArgExpansionBailout, create_mockable_default, mockable, mockable_default, import_micromatch, URL_STRING_PREFIX = "file:", isUrlInstance = (value) => value instanceof URL, isUrlString = (value) => typeof value === "string" && value.startsWith(URL_STRING_PREFIX), isUrl = (urlOrPath) => isUrlInstance(urlOrPath) || isUrlString(urlOrPath), toPath = (urlOrPath) => isUrl(urlOrPath) ? url.fileURLToPath(urlOrPath) : urlOrPath, toAbsolutePath = (urlOrPath) => urlOrPath ? path13.resolve(isUrl(urlOrPath) ? url.fileURLToPath(urlOrPath) : urlOrPath) : urlOrPath, partition_default, import_editorconfig, isFile = (stats) => stats?.isFile(), isDirectory = (stats) => stats?.isDirectory(), iterate_directory_up_default, Searcher = class {
188785
188821
  #stopDirectory;
188786
188822
  #cache;
188787
188823
  #resultCache = /* @__PURE__ */ new Map;
@@ -207618,363 +207654,9 @@ import path20 from "path";
207618
207654
  import { fileURLToPath as fileURLToPath8 } from "url";
207619
207655
 
207620
207656
  // src/commands/agents/index.ts
207621
- import { existsSync as existsSync12 } from "node:fs";
207657
+ import { existsSync as existsSync13 } from "node:fs";
207622
207658
  import path16 from "node:path";
207623
207659
 
207624
- // src/lib/api-paths.ts
207625
- var API_PREFIX = "/v1";
207626
- function apiPath(suffix) {
207627
- if (suffix === "/v1" || suffix.startsWith("/v1/"))
207628
- return suffix;
207629
- if (suffix === "/api/v1" || suffix.startsWith("/api/v1/")) {
207630
- return `${API_PREFIX}${suffix.slice("/api/v1".length)}`;
207631
- }
207632
- const normalized = suffix.startsWith("/") ? suffix : `/${suffix}`;
207633
- return `${API_PREFIX}${normalized}`;
207634
- }
207635
- function canonicalApiPath(path) {
207636
- if (path === "/api/v1" || path.startsWith("/api/v1/")) {
207637
- return `${API_PREFIX}${path.slice("/api/v1".length)}`;
207638
- }
207639
- return path;
207640
- }
207641
- function parseBaseUrl(baseUrl) {
207642
- return new URL(baseUrl.match(/^https?:\/\//i) ? baseUrl : `https://${baseUrl}`);
207643
- }
207644
- function endsWithApiPrefix(basePath) {
207645
- return basePath === "/api" || basePath.endsWith("/api");
207646
- }
207647
- function endsWithApiV1Prefix(basePath) {
207648
- return basePath === "/api/v1" || basePath.endsWith("/api/v1");
207649
- }
207650
- function resolveRequestUrl(baseUrl, path) {
207651
- if (/^https?:\/\//i.test(path))
207652
- return path;
207653
- const requestPath = canonicalApiPath(path);
207654
- const isCanonicalV1 = requestPath === API_PREFIX || requestPath.startsWith(`${API_PREFIX}/`);
207655
- const base = parseBaseUrl(baseUrl);
207656
- const basePath = base.pathname.replace(/\/+$/, "");
207657
- if (isCanonicalV1) {
207658
- if (endsWithApiV1Prefix(basePath)) {
207659
- const suffix = requestPath === API_PREFIX ? "" : requestPath.slice(API_PREFIX.length);
207660
- return `${base.origin}${basePath}${suffix}`;
207661
- }
207662
- if (endsWithApiPrefix(basePath)) {
207663
- return `${base.origin}${basePath}${requestPath}`;
207664
- }
207665
- return `${base.origin}${requestPath}`;
207666
- }
207667
- if (requestPath.startsWith("/api/") && (endsWithApiPrefix(basePath) || endsWithApiV1Prefix(basePath))) {
207668
- return `${base.origin}${requestPath}`;
207669
- }
207670
- if (!basePath)
207671
- return `${base.origin}${requestPath}`;
207672
- return `${base.origin}${basePath}${requestPath}`;
207673
- }
207674
-
207675
- // src/lib/fetch-body.ts
207676
- function isNodeReadableStream(body) {
207677
- return typeof body.pipe === "function";
207678
- }
207679
- function byteViewToArrayBuffer(view) {
207680
- if (view.buffer instanceof ArrayBuffer && view.byteOffset === 0 && view.byteLength === view.buffer.byteLength) {
207681
- return view.buffer;
207682
- }
207683
- const copy = new Uint8Array(view.byteLength);
207684
- copy.set(view);
207685
- return copy.buffer;
207686
- }
207687
- function toPutBody(body) {
207688
- if (isNodeReadableStream(body)) {
207689
- return body;
207690
- }
207691
- return byteViewToArrayBuffer(body);
207692
- }
207693
- // package.json
207694
- var package_default = {
207695
- name: "@eigenpal/cli",
207696
- version: "0.20.48",
207697
- description: "Eigenpal CLI — author and run document workflows from your terminal. Agent-ready.",
207698
- keywords: [
207699
- "eigenpal",
207700
- "cli",
207701
- "ai",
207702
- "agent",
207703
- "workflow",
207704
- "llm",
207705
- "evals",
207706
- "experiments",
207707
- "document",
207708
- "extraction",
207709
- "ocr"
207710
- ],
207711
- homepage: "https://github.com/eigenpal/cli#readme",
207712
- bugs: {
207713
- url: "https://github.com/eigenpal/cli/issues"
207714
- },
207715
- repository: {
207716
- type: "git",
207717
- url: "git+https://github.com/eigenpal/cli.git"
207718
- },
207719
- license: "Apache-2.0",
207720
- author: "Jedr Blaszyk <jedr@eigenpal.com> (https://eigenpal.com)",
207721
- type: "module",
207722
- main: "./src/index.ts",
207723
- types: "./src/index.ts",
207724
- bin: {
207725
- eigenpal: "dist/cli.js"
207726
- },
207727
- engines: {
207728
- node: ">=20"
207729
- },
207730
- publishConfig: {
207731
- access: "public"
207732
- },
207733
- scripts: {
207734
- dev: "bun src/cli.ts",
207735
- build: "bun run generate:skill && bun build src/cli.ts --outdir dist --target node --format esm && rm -rf dist/templates dist/skill && cp -R src/templates dist/templates && cp -R src/skill dist/skill && cp src/docs-bundle.json dist/docs-bundle.json",
207736
- generate: "bun run generate:cli-docs && bun run generate:skill && bun run generate:docs",
207737
- "generate:check": "bun run generate:cli-docs:check && bun run generate:skill:check && bun run generate:docs:check && bun test scripts/docs-bundle-completeness.test.ts",
207738
- "generate:docs": "bun scripts/generate-docs-bundle.ts",
207739
- "generate:docs:check": "bun scripts/generate-docs-bundle.ts --check",
207740
- "generate:skill": "bun scripts/generate-skill-reference.ts",
207741
- "generate:skill:check": "bun scripts/generate-skill-reference.ts --check",
207742
- "generate:cli-docs": "bun scripts/generate-cli-docs.ts",
207743
- "generate:cli-docs:check": "bun scripts/generate-cli-docs.ts --check",
207744
- "generate:logo": "bun scripts/render-logo-ascii.ts --cells 20",
207745
- test: "bun test src/ scripts/",
207746
- typecheck: "bun check"
207747
- },
207748
- dependencies: {
207749
- "@clack/prompts": "^1.3.0",
207750
- ajv: "8.20.0",
207751
- commander: "^14.0.3",
207752
- fflate: "0.8.3",
207753
- picocolors: "^1.1.1",
207754
- yaml: "2.9.1",
207755
- xlsx: "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
207756
- zod: "^4.4.3"
207757
- },
207758
- devDependencies: {
207759
- "@eigenpal/common": "workspace:*",
207760
- "@eigenpal/types": "workspace:*",
207761
- "@eigenpal/workflow-yaml": "workspace:*",
207762
- "@t3-oss/env-core": "^0.13.11",
207763
- typescript: "^7.0.2"
207764
- },
207765
- files: [
207766
- "dist",
207767
- "LICENSE",
207768
- "README.md",
207769
- "CHANGELOG.md"
207770
- ]
207771
- };
207772
-
207773
- // src/lib/telemetry.ts
207774
- var CLI_VERSION = package_default.version === "0.0.0-placeholder" ? "dev" : package_default.version;
207775
- function detectRuntime() {
207776
- const bun = globalThis.Bun;
207777
- if (bun?.version)
207778
- return `bun-${bun.version}`;
207779
- return `node-${process.versions.node}`;
207780
- }
207781
- function buildCliTelemetryHeaders() {
207782
- const runtime = detectRuntime();
207783
- const os = `${process.platform}-${process.arch}`;
207784
- return {
207785
- "X-Eigenpal-Sdk": "cli",
207786
- "X-Eigenpal-Sdk-Version": CLI_VERSION,
207787
- "X-Eigenpal-Sdk-Runtime": runtime,
207788
- "X-Eigenpal-Sdk-Os": os,
207789
- "User-Agent": `eigenpal-cli/${CLI_VERSION} (${runtime}; ${os})`
207790
- };
207791
- }
207792
-
207793
- // src/lib/client.ts
207794
- class ApiError extends Error {
207795
- status;
207796
- body;
207797
- constructor(status, body) {
207798
- const msg = typeof body === "object" && body !== null && "error" in body ? body.error : `HTTP ${status}`;
207799
- super(msg);
207800
- this.status = status;
207801
- this.body = body;
207802
- this.name = "ApiError";
207803
- }
207804
- }
207805
-
207806
- class HtmlResponseError extends Error {
207807
- resolvedUrl;
207808
- constructor(resolvedUrl) {
207809
- super(`API not reachable at ${resolvedUrl} — got HTML response (likely wrong base URL or API not running)`);
207810
- this.resolvedUrl = resolvedUrl;
207811
- this.name = "HtmlResponseError";
207812
- }
207813
- }
207814
- function assertNotHtml(res, resolvedUrl) {
207815
- const contentType = res.headers.get("content-type") ?? "";
207816
- if (contentType.toLowerCase().startsWith("text/html")) {
207817
- throw new HtmlResponseError(resolvedUrl);
207818
- }
207819
- }
207820
-
207821
- class ApiClient {
207822
- baseUrl;
207823
- apiKey;
207824
- tenantId;
207825
- constructor(config) {
207826
- this.baseUrl = config.baseUrl;
207827
- this.apiKey = config.apiKey;
207828
- this.tenantId = config.tenantId;
207829
- }
207830
- buildUrl(path) {
207831
- return resolveRequestUrl(this.baseUrl, path);
207832
- }
207833
- headers(extra = {}) {
207834
- return {
207835
- ...buildCliTelemetryHeaders(),
207836
- Authorization: `Bearer ${this.apiKey}`,
207837
- "X-Eigenpal-Trigger": "cli",
207838
- ...this.tenantId ? { "x-eigenpal-tenant-id": this.tenantId } : {},
207839
- ...extra
207840
- };
207841
- }
207842
- async handleResponse(res, resolvedUrl) {
207843
- if (res.status === 204)
207844
- return null;
207845
- assertNotHtml(res, resolvedUrl);
207846
- const contentType = res.headers.get("content-type") || "";
207847
- if (!res.ok) {
207848
- let body;
207849
- try {
207850
- body = contentType.includes("json") ? await res.json() : await res.text();
207851
- } catch {
207852
- body = `HTTP ${res.status}`;
207853
- }
207854
- throw new ApiError(res.status, body);
207855
- }
207856
- if (contentType.includes("json")) {
207857
- return res.json();
207858
- }
207859
- return res;
207860
- }
207861
- async get(path, params) {
207862
- let url = this.buildUrl(path);
207863
- if (params) {
207864
- const qs = new URLSearchParams(params).toString();
207865
- if (qs)
207866
- url += `?${qs}`;
207867
- }
207868
- const res = await fetch(url, { headers: this.headers() });
207869
- return this.handleResponse(res, url);
207870
- }
207871
- async post(path, body) {
207872
- const url = this.buildUrl(path);
207873
- const res = await fetch(url, {
207874
- method: "POST",
207875
- headers: this.headers({ "Content-Type": "application/json" }),
207876
- body: body !== undefined ? JSON.stringify(body) : undefined
207877
- });
207878
- return this.handleResponse(res, url);
207879
- }
207880
- async put(path, body) {
207881
- const url = this.buildUrl(path);
207882
- const res = await fetch(url, {
207883
- method: "PUT",
207884
- headers: this.headers({ "Content-Type": "application/json" }),
207885
- body: body !== undefined ? JSON.stringify(body) : undefined
207886
- });
207887
- return this.handleResponse(res, url);
207888
- }
207889
- async putBytes(path, body) {
207890
- const url = this.buildUrl(path);
207891
- const stream = isNodeReadableStream(body);
207892
- const init = {
207893
- method: "PUT",
207894
- headers: this.headers({ "Content-Type": "application/octet-stream" }),
207895
- body,
207896
- ...stream ? { duplex: "half" } : {}
207897
- };
207898
- const res = await fetch(url, init);
207899
- return this.handleResponse(res, url);
207900
- }
207901
- async patch(path, body) {
207902
- const url = this.buildUrl(path);
207903
- const res = await fetch(url, {
207904
- method: "PATCH",
207905
- headers: this.headers({ "Content-Type": "application/json" }),
207906
- body: JSON.stringify(body)
207907
- });
207908
- return this.handleResponse(res, url);
207909
- }
207910
- async postFormData(path, formData) {
207911
- const url = this.buildUrl(path);
207912
- const res = await fetch(url, {
207913
- method: "POST",
207914
- headers: this.headers(),
207915
- body: formData
207916
- });
207917
- return this.handleResponse(res, url);
207918
- }
207919
- async putFormData(path, formData) {
207920
- const url = this.buildUrl(path);
207921
- const res = await fetch(url, {
207922
- method: "PUT",
207923
- headers: this.headers(),
207924
- body: formData
207925
- });
207926
- return this.handleResponse(res, url);
207927
- }
207928
- async patchFormData(path, formData) {
207929
- const url = this.buildUrl(path);
207930
- const res = await fetch(url, {
207931
- method: "PATCH",
207932
- headers: this.headers(),
207933
- body: formData
207934
- });
207935
- return this.handleResponse(res, url);
207936
- }
207937
- async delete(path) {
207938
- const url = this.buildUrl(path);
207939
- const res = await fetch(url, {
207940
- method: "DELETE",
207941
- headers: this.headers()
207942
- });
207943
- return this.handleResponse(res, url);
207944
- }
207945
- async getStream(path) {
207946
- const url = this.buildUrl(path);
207947
- const res = await fetch(url, {
207948
- headers: this.headers()
207949
- });
207950
- assertNotHtml(res, url);
207951
- if (!res.ok) {
207952
- throw new ApiError(res.status, `Failed to download: HTTP ${res.status}`);
207953
- }
207954
- return res;
207955
- }
207956
- async postStream(path, body) {
207957
- const url = this.buildUrl(path);
207958
- const res = await fetch(url, {
207959
- method: "POST",
207960
- headers: this.headers({ "Content-Type": "application/json" }),
207961
- body: body !== undefined ? JSON.stringify(body) : undefined
207962
- });
207963
- assertNotHtml(res, url);
207964
- return res;
207965
- }
207966
- async postFormDataStream(path, formData) {
207967
- const url = this.buildUrl(path);
207968
- const res = await fetch(url, {
207969
- method: "POST",
207970
- headers: this.headers(),
207971
- body: formData
207972
- });
207973
- assertNotHtml(res, url);
207974
- return res;
207975
- }
207976
- }
207977
-
207978
207660
  // ../../node_modules/@t3-oss/env-core/dist/standard.js
207979
207661
  function ensureSynchronous(value, message) {
207980
207662
  if (value instanceof Promise)
@@ -208381,6 +208063,360 @@ function requireApiKey(config) {
208381
208063
  return config.apiKey;
208382
208064
  }
208383
208065
 
208066
+ // src/lib/api-paths.ts
208067
+ var API_PREFIX = "/v1";
208068
+ function apiPath(suffix) {
208069
+ if (suffix === "/v1" || suffix.startsWith("/v1/"))
208070
+ return suffix;
208071
+ if (suffix === "/api/v1" || suffix.startsWith("/api/v1/")) {
208072
+ return `${API_PREFIX}${suffix.slice("/api/v1".length)}`;
208073
+ }
208074
+ const normalized = suffix.startsWith("/") ? suffix : `/${suffix}`;
208075
+ return `${API_PREFIX}${normalized}`;
208076
+ }
208077
+ function canonicalApiPath(path) {
208078
+ if (path === "/api/v1" || path.startsWith("/api/v1/")) {
208079
+ return `${API_PREFIX}${path.slice("/api/v1".length)}`;
208080
+ }
208081
+ return path;
208082
+ }
208083
+ function parseBaseUrl(baseUrl) {
208084
+ return new URL(baseUrl.match(/^https?:\/\//i) ? baseUrl : `https://${baseUrl}`);
208085
+ }
208086
+ function endsWithApiPrefix(basePath) {
208087
+ return basePath === "/api" || basePath.endsWith("/api");
208088
+ }
208089
+ function endsWithApiV1Prefix(basePath) {
208090
+ return basePath === "/api/v1" || basePath.endsWith("/api/v1");
208091
+ }
208092
+ function resolveRequestUrl(baseUrl, path) {
208093
+ if (/^https?:\/\//i.test(path))
208094
+ return path;
208095
+ const requestPath = canonicalApiPath(path);
208096
+ const isCanonicalV1 = requestPath === API_PREFIX || requestPath.startsWith(`${API_PREFIX}/`);
208097
+ const base = parseBaseUrl(baseUrl);
208098
+ const basePath = base.pathname.replace(/\/+$/, "");
208099
+ if (isCanonicalV1) {
208100
+ if (endsWithApiV1Prefix(basePath)) {
208101
+ const suffix = requestPath === API_PREFIX ? "" : requestPath.slice(API_PREFIX.length);
208102
+ return `${base.origin}${basePath}${suffix}`;
208103
+ }
208104
+ if (endsWithApiPrefix(basePath)) {
208105
+ return `${base.origin}${basePath}${requestPath}`;
208106
+ }
208107
+ return `${base.origin}${requestPath}`;
208108
+ }
208109
+ if (requestPath.startsWith("/api/") && (endsWithApiPrefix(basePath) || endsWithApiV1Prefix(basePath))) {
208110
+ return `${base.origin}${requestPath}`;
208111
+ }
208112
+ if (!basePath)
208113
+ return `${base.origin}${requestPath}`;
208114
+ return `${base.origin}${basePath}${requestPath}`;
208115
+ }
208116
+
208117
+ // src/lib/fetch-body.ts
208118
+ function isNodeReadableStream(body) {
208119
+ return typeof body.pipe === "function";
208120
+ }
208121
+ function byteViewToArrayBuffer(view) {
208122
+ if (view.buffer instanceof ArrayBuffer && view.byteOffset === 0 && view.byteLength === view.buffer.byteLength) {
208123
+ return view.buffer;
208124
+ }
208125
+ const copy = new Uint8Array(view.byteLength);
208126
+ copy.set(view);
208127
+ return copy.buffer;
208128
+ }
208129
+ function toPutBody(body) {
208130
+ if (isNodeReadableStream(body)) {
208131
+ return body;
208132
+ }
208133
+ return byteViewToArrayBuffer(body);
208134
+ }
208135
+ // package.json
208136
+ var package_default = {
208137
+ name: "@eigenpal/cli",
208138
+ version: "0.20.50",
208139
+ description: "Eigenpal CLI — author and run document workflows from your terminal. Agent-ready.",
208140
+ keywords: [
208141
+ "eigenpal",
208142
+ "cli",
208143
+ "ai",
208144
+ "agent",
208145
+ "workflow",
208146
+ "llm",
208147
+ "evals",
208148
+ "experiments",
208149
+ "document",
208150
+ "extraction",
208151
+ "ocr"
208152
+ ],
208153
+ homepage: "https://github.com/eigenpal/cli#readme",
208154
+ bugs: {
208155
+ url: "https://github.com/eigenpal/cli/issues"
208156
+ },
208157
+ repository: {
208158
+ type: "git",
208159
+ url: "git+https://github.com/eigenpal/cli.git"
208160
+ },
208161
+ license: "Apache-2.0",
208162
+ author: "Jedr Blaszyk <jedr@eigenpal.com> (https://eigenpal.com)",
208163
+ type: "module",
208164
+ main: "./src/index.ts",
208165
+ types: "./src/index.ts",
208166
+ bin: {
208167
+ eigenpal: "dist/cli.js"
208168
+ },
208169
+ engines: {
208170
+ node: ">=20"
208171
+ },
208172
+ publishConfig: {
208173
+ access: "public"
208174
+ },
208175
+ scripts: {
208176
+ dev: "bun src/cli.ts",
208177
+ build: "bun run generate:skill && bun build src/cli.ts --outdir dist --target node --format esm && rm -rf dist/templates dist/skill && cp -R src/templates dist/templates && cp -R src/skill dist/skill && cp src/docs-bundle.json dist/docs-bundle.json",
208178
+ generate: "bun run generate:cli-docs && bun run generate:skill && bun run generate:docs",
208179
+ "generate:check": "bun run generate:cli-docs:check && bun run generate:skill:check && bun run generate:docs:check && bun test scripts/docs-bundle-completeness.test.ts",
208180
+ "generate:docs": "bun scripts/generate-docs-bundle.ts",
208181
+ "generate:docs:check": "bun scripts/generate-docs-bundle.ts --check",
208182
+ "generate:skill": "bun scripts/generate-skill-reference.ts",
208183
+ "generate:skill:check": "bun scripts/generate-skill-reference.ts --check",
208184
+ "generate:cli-docs": "bun scripts/generate-cli-docs.ts",
208185
+ "generate:cli-docs:check": "bun scripts/generate-cli-docs.ts --check",
208186
+ "generate:logo": "bun scripts/render-logo-ascii.ts --cells 20",
208187
+ test: "bun test src/ scripts/",
208188
+ typecheck: "bun check"
208189
+ },
208190
+ dependencies: {
208191
+ "@clack/prompts": "^1.3.0",
208192
+ ajv: "8.20.0",
208193
+ commander: "^14.0.3",
208194
+ fflate: "0.8.3",
208195
+ picocolors: "^1.1.1",
208196
+ yaml: "2.9.1",
208197
+ xlsx: "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
208198
+ zod: "^4.4.3"
208199
+ },
208200
+ devDependencies: {
208201
+ "@eigenpal/common": "workspace:*",
208202
+ "@eigenpal/types": "workspace:*",
208203
+ "@eigenpal/workflow-yaml": "workspace:*",
208204
+ "@t3-oss/env-core": "^0.13.11",
208205
+ typescript: "^7.0.2"
208206
+ },
208207
+ files: [
208208
+ "dist",
208209
+ "LICENSE",
208210
+ "README.md",
208211
+ "CHANGELOG.md"
208212
+ ]
208213
+ };
208214
+
208215
+ // src/lib/telemetry.ts
208216
+ var CLI_VERSION = package_default.version === "0.0.0-placeholder" ? "dev" : package_default.version;
208217
+ function detectRuntime() {
208218
+ const bun = globalThis.Bun;
208219
+ if (bun?.version)
208220
+ return `bun-${bun.version}`;
208221
+ return `node-${process.versions.node}`;
208222
+ }
208223
+ function buildCliTelemetryHeaders() {
208224
+ const runtime = detectRuntime();
208225
+ const os = `${process.platform}-${process.arch}`;
208226
+ return {
208227
+ "X-Eigenpal-Sdk": "cli",
208228
+ "X-Eigenpal-Sdk-Version": CLI_VERSION,
208229
+ "X-Eigenpal-Sdk-Runtime": runtime,
208230
+ "X-Eigenpal-Sdk-Os": os,
208231
+ "User-Agent": `eigenpal-cli/${CLI_VERSION} (${runtime}; ${os})`
208232
+ };
208233
+ }
208234
+
208235
+ // src/lib/client.ts
208236
+ class ApiError extends Error {
208237
+ status;
208238
+ body;
208239
+ constructor(status, body) {
208240
+ const msg = typeof body === "object" && body !== null && "error" in body ? body.error : `HTTP ${status}`;
208241
+ super(msg);
208242
+ this.status = status;
208243
+ this.body = body;
208244
+ this.name = "ApiError";
208245
+ }
208246
+ }
208247
+
208248
+ class HtmlResponseError extends Error {
208249
+ resolvedUrl;
208250
+ constructor(resolvedUrl) {
208251
+ super(`API not reachable at ${resolvedUrl} — got HTML response (likely wrong base URL or API not running)`);
208252
+ this.resolvedUrl = resolvedUrl;
208253
+ this.name = "HtmlResponseError";
208254
+ }
208255
+ }
208256
+ function assertNotHtml(res, resolvedUrl) {
208257
+ const contentType = res.headers.get("content-type") ?? "";
208258
+ if (contentType.toLowerCase().startsWith("text/html")) {
208259
+ throw new HtmlResponseError(resolvedUrl);
208260
+ }
208261
+ }
208262
+
208263
+ class ApiClient {
208264
+ baseUrl;
208265
+ apiKey;
208266
+ tenantId;
208267
+ constructor(config) {
208268
+ this.baseUrl = config.baseUrl;
208269
+ this.apiKey = config.apiKey;
208270
+ this.tenantId = config.tenantId;
208271
+ }
208272
+ buildUrl(path) {
208273
+ return resolveRequestUrl(this.baseUrl, path);
208274
+ }
208275
+ headers(extra = {}) {
208276
+ return {
208277
+ ...buildCliTelemetryHeaders(),
208278
+ Authorization: `Bearer ${this.apiKey}`,
208279
+ "X-Eigenpal-Trigger": "cli",
208280
+ ...this.tenantId ? { "x-eigenpal-tenant-id": this.tenantId } : {},
208281
+ ...extra
208282
+ };
208283
+ }
208284
+ async handleResponse(res, resolvedUrl) {
208285
+ if (res.status === 204)
208286
+ return null;
208287
+ assertNotHtml(res, resolvedUrl);
208288
+ const contentType = res.headers.get("content-type") || "";
208289
+ if (!res.ok) {
208290
+ let body;
208291
+ try {
208292
+ body = contentType.includes("json") ? await res.json() : await res.text();
208293
+ } catch {
208294
+ body = `HTTP ${res.status}`;
208295
+ }
208296
+ throw new ApiError(res.status, body);
208297
+ }
208298
+ if (contentType.includes("json")) {
208299
+ return res.json();
208300
+ }
208301
+ return res;
208302
+ }
208303
+ async get(path, params) {
208304
+ let url = this.buildUrl(path);
208305
+ if (params) {
208306
+ const qs = new URLSearchParams(params).toString();
208307
+ if (qs)
208308
+ url += `?${qs}`;
208309
+ }
208310
+ const res = await fetch(url, { headers: this.headers() });
208311
+ return this.handleResponse(res, url);
208312
+ }
208313
+ async post(path, body) {
208314
+ const url = this.buildUrl(path);
208315
+ const res = await fetch(url, {
208316
+ method: "POST",
208317
+ headers: this.headers({ "Content-Type": "application/json" }),
208318
+ body: body !== undefined ? JSON.stringify(body) : undefined
208319
+ });
208320
+ return this.handleResponse(res, url);
208321
+ }
208322
+ async put(path, body) {
208323
+ const url = this.buildUrl(path);
208324
+ const res = await fetch(url, {
208325
+ method: "PUT",
208326
+ headers: this.headers({ "Content-Type": "application/json" }),
208327
+ body: body !== undefined ? JSON.stringify(body) : undefined
208328
+ });
208329
+ return this.handleResponse(res, url);
208330
+ }
208331
+ async putBytes(path, body) {
208332
+ const url = this.buildUrl(path);
208333
+ const stream = isNodeReadableStream(body);
208334
+ const init = {
208335
+ method: "PUT",
208336
+ headers: this.headers({ "Content-Type": "application/octet-stream" }),
208337
+ body,
208338
+ ...stream ? { duplex: "half" } : {}
208339
+ };
208340
+ const res = await fetch(url, init);
208341
+ return this.handleResponse(res, url);
208342
+ }
208343
+ async patch(path, body) {
208344
+ const url = this.buildUrl(path);
208345
+ const res = await fetch(url, {
208346
+ method: "PATCH",
208347
+ headers: this.headers({ "Content-Type": "application/json" }),
208348
+ body: JSON.stringify(body)
208349
+ });
208350
+ return this.handleResponse(res, url);
208351
+ }
208352
+ async postFormData(path, formData) {
208353
+ const url = this.buildUrl(path);
208354
+ const res = await fetch(url, {
208355
+ method: "POST",
208356
+ headers: this.headers(),
208357
+ body: formData
208358
+ });
208359
+ return this.handleResponse(res, url);
208360
+ }
208361
+ async putFormData(path, formData) {
208362
+ const url = this.buildUrl(path);
208363
+ const res = await fetch(url, {
208364
+ method: "PUT",
208365
+ headers: this.headers(),
208366
+ body: formData
208367
+ });
208368
+ return this.handleResponse(res, url);
208369
+ }
208370
+ async patchFormData(path, formData) {
208371
+ const url = this.buildUrl(path);
208372
+ const res = await fetch(url, {
208373
+ method: "PATCH",
208374
+ headers: this.headers(),
208375
+ body: formData
208376
+ });
208377
+ return this.handleResponse(res, url);
208378
+ }
208379
+ async delete(path) {
208380
+ const url = this.buildUrl(path);
208381
+ const res = await fetch(url, {
208382
+ method: "DELETE",
208383
+ headers: this.headers()
208384
+ });
208385
+ return this.handleResponse(res, url);
208386
+ }
208387
+ async getStream(path) {
208388
+ const url = this.buildUrl(path);
208389
+ const res = await fetch(url, {
208390
+ headers: this.headers()
208391
+ });
208392
+ assertNotHtml(res, url);
208393
+ if (!res.ok) {
208394
+ throw new ApiError(res.status, `Failed to download: HTTP ${res.status}`);
208395
+ }
208396
+ return res;
208397
+ }
208398
+ async postStream(path, body) {
208399
+ const url = this.buildUrl(path);
208400
+ const res = await fetch(url, {
208401
+ method: "POST",
208402
+ headers: this.headers({ "Content-Type": "application/json" }),
208403
+ body: body !== undefined ? JSON.stringify(body) : undefined
208404
+ });
208405
+ assertNotHtml(res, url);
208406
+ return res;
208407
+ }
208408
+ async postFormDataStream(path, formData) {
208409
+ const url = this.buildUrl(path);
208410
+ const res = await fetch(url, {
208411
+ method: "POST",
208412
+ headers: this.headers(),
208413
+ body: formData
208414
+ });
208415
+ assertNotHtml(res, url);
208416
+ return res;
208417
+ }
208418
+ }
208419
+
208384
208420
  // src/lib/format-error.ts
208385
208421
  var CONNECTION_FAILURE_TOKENS = [
208386
208422
  "ECONNREFUSED",
@@ -208535,15 +208571,56 @@ async function requireTypedConfirmation(opts) {
208535
208571
  init_src();
208536
208572
  init_zod();
208537
208573
  import { spawnSync as spawnSync3 } from "node:child_process";
208538
- import { existsSync as existsSync5, mkdirSync as mkdirSync3, mkdtempSync, readFileSync as readFileSync6, rmSync, writeFileSync as writeFileSync4 } from "node:fs";
208574
+ import { existsSync as existsSync6, mkdirSync as mkdirSync3, mkdtempSync, readFileSync as readFileSync7, rmSync, writeFileSync as writeFileSync4 } from "node:fs";
208539
208575
  import { mkdtemp } from "node:fs/promises";
208540
208576
  import { tmpdir } from "node:os";
208541
- import path5 from "node:path";
208577
+ import path6 from "node:path";
208578
+
208579
+ // src/commands/git/agent-definition.ts
208580
+ init_src();
208581
+ import { existsSync as existsSync2, lstatSync, readdirSync, readFileSync as readFileSync2 } from "node:fs";
208582
+ import path from "node:path";
208583
+ function captureAgentSource(root) {
208584
+ for (const name of ["eigenpal.yaml", "eigenpal.yml", "input-schema.json", "output-schema.json"])
208585
+ if (existsSync2(path.join(root, name)))
208586
+ throw new Error("Agent package mixes TypeScript and legacy definition files");
208587
+ const files = {};
208588
+ let bytes = 0;
208589
+ const visit = (directory) => {
208590
+ for (const entry of readdirSync(directory, { withFileTypes: true })) {
208591
+ if ([".git", ".eigenpal", "eigenpal_modules", "node_modules"].includes(entry.name))
208592
+ continue;
208593
+ const absolute = path.join(directory, entry.name);
208594
+ const relative = path.relative(root, absolute).split(path.sep).join("/");
208595
+ const stat = lstatSync(absolute);
208596
+ if (stat.isDirectory()) {
208597
+ visit(absolute);
208598
+ continue;
208599
+ }
208600
+ if (!/\.(ts|js)$/.test(relative))
208601
+ continue;
208602
+ if (!stat.isFile() || !/^[a-zA-Z0-9_./-]+\.(ts|js)$/.test(relative))
208603
+ throw new Error("Agent modules must be regular package-local files");
208604
+ bytes += stat.size + Buffer.byteLength(relative);
208605
+ if (Object.keys(files).length >= 32 || bytes > 256 * 1024)
208606
+ throw new Error("Agent source exceeds the compilation limit");
208607
+ files[relative] = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(readFileSync2(absolute));
208608
+ }
208609
+ };
208610
+ visit(root);
208611
+ if (!Object.hasOwn(files, "agent.ts"))
208612
+ throw new Error("Agent entry must be a regular agent.ts file");
208613
+ return { entry: "agent.ts", files };
208614
+ }
208615
+ async function compileLocalAgent(root, config) {
208616
+ const source = captureAgentSource(root);
208617
+ return CompiledAgentSnapshotSchema.parse(await new ApiClient(config ?? resolveConfig({})).post("/v1/source/agent-definition", source));
208618
+ }
208542
208619
 
208543
208620
  // src/commands/git/init.ts
208544
208621
  init_src();
208545
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
208546
- import path2 from "node:path";
208622
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "node:fs";
208623
+ import path3 from "node:path";
208547
208624
 
208548
208625
  // node_modules/yaml/dist/index.js
208549
208626
  var composer = require_composer();
@@ -208591,24 +208668,160 @@ var $parseDocument = publicApi.parseDocument;
208591
208668
  var $stringify = publicApi.stringify;
208592
208669
  var $visit = visit.visit;
208593
208670
  var $visitAsync = visit.visitAsync;
208671
+ // ../../node_modules/zod/package.json
208672
+ var package_default2 = {
208673
+ name: "zod",
208674
+ version: "4.4.3",
208675
+ type: "module",
208676
+ license: "MIT",
208677
+ author: "Colin McDonnell <zod@colinhacks.com>",
208678
+ description: "TypeScript-first schema declaration and validation library with static type inference",
208679
+ homepage: "https://zod.dev",
208680
+ llms: "https://zod.dev/llms.txt",
208681
+ llmsFull: "https://zod.dev/llms-full.txt",
208682
+ mcpServer: "https://mcp.inkeep.com/zod/mcp",
208683
+ funding: "https://github.com/sponsors/colinhacks",
208684
+ sideEffects: false,
208685
+ files: [
208686
+ "src",
208687
+ "**/*.js",
208688
+ "**/*.mjs",
208689
+ "**/*.cjs",
208690
+ "**/*.d.ts",
208691
+ "**/*.d.mts",
208692
+ "**/*.d.cts",
208693
+ "**/package.json"
208694
+ ],
208695
+ keywords: [
208696
+ "typescript",
208697
+ "schema",
208698
+ "validation",
208699
+ "type",
208700
+ "inference"
208701
+ ],
208702
+ main: "./index.cjs",
208703
+ types: "./index.d.cts",
208704
+ module: "./index.js",
208705
+ zshy: {
208706
+ exports: {
208707
+ "./package.json": "./package.json",
208708
+ ".": "./src/index.ts",
208709
+ "./mini": "./src/mini/index.ts",
208710
+ "./locales": "./src/locales/index.ts",
208711
+ "./v3": "./src/v3/index.ts",
208712
+ "./v4": "./src/v4/index.ts",
208713
+ "./v4-mini": "./src/v4-mini/index.ts",
208714
+ "./v4/mini": "./src/v4/mini/index.ts",
208715
+ "./v4/core": "./src/v4/core/index.ts",
208716
+ "./v4/locales": "./src/v4/locales/index.ts",
208717
+ "./v4/locales/*": "./src/v4/locales/*"
208718
+ },
208719
+ conditions: {
208720
+ "@zod/source": "src"
208721
+ }
208722
+ },
208723
+ exports: {
208724
+ "./package.json": "./package.json",
208725
+ ".": {
208726
+ "@zod/source": "./src/index.ts",
208727
+ types: "./index.d.cts",
208728
+ import: "./index.js",
208729
+ require: "./index.cjs"
208730
+ },
208731
+ "./mini": {
208732
+ "@zod/source": "./src/mini/index.ts",
208733
+ types: "./mini/index.d.cts",
208734
+ import: "./mini/index.js",
208735
+ require: "./mini/index.cjs"
208736
+ },
208737
+ "./locales": {
208738
+ "@zod/source": "./src/locales/index.ts",
208739
+ types: "./locales/index.d.cts",
208740
+ import: "./locales/index.js",
208741
+ require: "./locales/index.cjs"
208742
+ },
208743
+ "./v3": {
208744
+ "@zod/source": "./src/v3/index.ts",
208745
+ types: "./v3/index.d.cts",
208746
+ import: "./v3/index.js",
208747
+ require: "./v3/index.cjs"
208748
+ },
208749
+ "./v4": {
208750
+ "@zod/source": "./src/v4/index.ts",
208751
+ types: "./v4/index.d.cts",
208752
+ import: "./v4/index.js",
208753
+ require: "./v4/index.cjs"
208754
+ },
208755
+ "./v4-mini": {
208756
+ "@zod/source": "./src/v4-mini/index.ts",
208757
+ types: "./v4-mini/index.d.cts",
208758
+ import: "./v4-mini/index.js",
208759
+ require: "./v4-mini/index.cjs"
208760
+ },
208761
+ "./v4/mini": {
208762
+ "@zod/source": "./src/v4/mini/index.ts",
208763
+ types: "./v4/mini/index.d.cts",
208764
+ import: "./v4/mini/index.js",
208765
+ require: "./v4/mini/index.cjs"
208766
+ },
208767
+ "./v4/core": {
208768
+ "@zod/source": "./src/v4/core/index.ts",
208769
+ types: "./v4/core/index.d.cts",
208770
+ import: "./v4/core/index.js",
208771
+ require: "./v4/core/index.cjs"
208772
+ },
208773
+ "./v4/locales": {
208774
+ "@zod/source": "./src/v4/locales/index.ts",
208775
+ types: "./v4/locales/index.d.cts",
208776
+ import: "./v4/locales/index.js",
208777
+ require: "./v4/locales/index.cjs"
208778
+ },
208779
+ "./v4/locales/*": {
208780
+ "@zod/source": "./src/v4/locales/*",
208781
+ types: "./v4/locales/*",
208782
+ import: "./v4/locales/*",
208783
+ require: "./v4/locales/*"
208784
+ }
208785
+ },
208786
+ repository: {
208787
+ type: "git",
208788
+ url: "git+https://github.com/colinhacks/zod.git"
208789
+ },
208790
+ bugs: {
208791
+ url: "https://github.com/colinhacks/zod/issues"
208792
+ },
208793
+ support: {
208794
+ backing: {
208795
+ "npm-funding": true
208796
+ }
208797
+ },
208798
+ scripts: {
208799
+ clean: "git clean -xdf . -e node_modules",
208800
+ build: "zshy --project tsconfig.build.json",
208801
+ postbuild: "tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .",
208802
+ "test:watch": "pnpm vitest",
208803
+ test: "pnpm vitest run",
208804
+ prepublishOnly: "tsx ../../scripts/check-versions.ts"
208805
+ }
208806
+ };
208594
208807
 
208595
208808
  // src/commands/git/source-state.ts
208596
208809
  init_src();
208597
208810
  import { spawnSync as spawnSync2 } from "node:child_process";
208598
208811
  import {
208599
- existsSync as existsSync2,
208600
- readdirSync,
208601
- readFileSync as readFileSync3,
208812
+ existsSync as existsSync3,
208813
+ readdirSync as readdirSync2,
208814
+ readFileSync as readFileSync4,
208602
208815
  realpathSync as realpathSync2,
208603
208816
  statSync,
208604
208817
  writeFileSync as writeFileSync2
208605
208818
  } from "node:fs";
208606
- import path from "node:path";
208819
+ import path2 from "node:path";
208607
208820
 
208608
208821
  // src/commands/git/source-git.ts
208609
208822
  init_zod();
208610
208823
  import { spawnSync } from "node:child_process";
208611
- import { readFileSync as readFileSync2, realpathSync } from "node:fs";
208824
+ import { readFileSync as readFileSync3, realpathSync } from "node:fs";
208612
208825
  var SourceRepositorySchema = object({
208613
208826
  gitRepositoryPath: string2(),
208614
208827
  remoteUrl: string2().url()
@@ -208805,7 +209018,7 @@ function runSourceGitCredentialHelper(operation) {
208805
209018
  const remoteUrl = gitOutput(["config", "--get", "eigenpal.gitRemoteUrl"], gitRoot) ?? gitOutput(["remote", "get-url", "origin"], gitRoot);
208806
209019
  if (!remoteUrl || !isEigenpalGitRemote(remoteUrl))
208807
209020
  return;
208808
- const fields = parseCredentialHelperInput(readFileSync2(0, "utf8"));
209021
+ const fields = parseCredentialHelperInput(readFileSync3(0, "utf8"));
208809
209022
  if (!credentialRequestMatchesRemote(fields, normalizeGitRemoteUrl(remoteUrl)))
208810
209023
  return;
208811
209024
  const pinnedProfile = gitOutput(["config", "--get", "eigenpal.profile"], gitRoot);
@@ -208856,7 +209069,7 @@ function gitOutput2(args, cwd, config, bootstrapRemoteUrl) {
208856
209069
  return result.stdout.trim();
208857
209070
  }
208858
209071
  function sourcePathFromPackageRoot(gitRoot, packageRoot) {
208859
- const relativePath = path.relative(gitRoot, packageRoot).replace(/\\/g, "/");
209072
+ const relativePath = path2.relative(gitRoot, packageRoot).replace(/\\/g, "/");
208860
209073
  const result = SourcePackagePathSchema.safeParse(relativePath);
208861
209074
  return result.success ? result.data : null;
208862
209075
  }
@@ -208869,20 +209082,20 @@ function isOrganizationSourceGitRoot(gitRoot) {
208869
209082
  return Boolean(gitOutput2(["remote", "get-url", "origin"], gitRoot)?.match(/\/orgs\/[^/]+\.git$/));
208870
209083
  }
208871
209084
  function findNearestPackageRoot(startDir, gitRoot) {
208872
- let current = path.resolve(startDir);
209085
+ let current = path2.resolve(startDir);
208873
209086
  while (true) {
208874
- if (existsSync2(path.join(current, "eigenpal.yaml")))
209087
+ if (existsSync3(path2.join(current, "eigenpal.yaml")) || existsSync3(path2.join(current, "agent.ts")))
208875
209088
  return current;
208876
209089
  if (gitRoot && current === gitRoot)
208877
209090
  return null;
208878
- const parent = path.dirname(current);
209091
+ const parent = path2.dirname(current);
208879
209092
  if (parent === current)
208880
209093
  return null;
208881
209094
  current = parent;
208882
209095
  }
208883
209096
  }
208884
209097
  function resolveGitSourceContext(opts = {}) {
208885
- const startDir = realpathSync2(path.resolve(opts.dir ?? process.cwd()));
209098
+ const startDir = realpathSync2(path2.resolve(opts.dir ?? process.cwd()));
208886
209099
  const gitRoot = resolveGitRoot2(startDir);
208887
209100
  const packageRoot = findNearestPackageRoot(startDir, gitRoot);
208888
209101
  const resolvedPackageRoot = packageRoot ? realpathSync2(packageRoot) : null;
@@ -208895,11 +209108,11 @@ function resolveGitSourceContext(opts = {}) {
208895
209108
  function listRelativeFiles(dir) {
208896
209109
  const files = [];
208897
209110
  const visit = (current) => {
208898
- for (const entry of readdirSync(current)) {
209111
+ for (const entry of readdirSync2(current)) {
208899
209112
  if (entry === ".git" || entry === "eigenpal_modules" || entry === ".eigenpal")
208900
209113
  continue;
208901
- const fullPath = path.join(current, entry);
208902
- const rel = path.relative(dir, fullPath).replace(/\\/g, "/");
209114
+ const fullPath = path2.join(current, entry);
209115
+ const rel = path2.relative(dir, fullPath).replace(/\\/g, "/");
208903
209116
  if (statSync(fullPath).isDirectory())
208904
209117
  visit(fullPath);
208905
209118
  else
@@ -208910,20 +209123,22 @@ function listRelativeFiles(dir) {
208910
209123
  return files;
208911
209124
  }
208912
209125
  function readYamlFile(filePath) {
208913
- return exports_dist.parse(readFileSync3(filePath, "utf8"));
209126
+ return exports_dist.parse(readFileSync4(filePath, "utf8"));
208914
209127
  }
208915
209128
  function writeYamlFile(filePath, value) {
208916
209129
  writeFileSync2(filePath, exports_dist.stringify(value));
208917
209130
  }
208918
209131
  function packageManifestExists(gitRoot, packagePath) {
208919
- return existsSync2(path.join(gitRoot, packagePath, "eigenpal.yaml"));
209132
+ return existsSync3(path2.join(gitRoot, packagePath, "eigenpal.yaml")) || packagePath.startsWith("agents/") && existsSync3(path2.join(gitRoot, packagePath, "agent.ts"));
208920
209133
  }
208921
209134
  function releaseTagExists(gitRoot, packagePath, version) {
208922
209135
  const tag = formatReleaseTag(pathToDottedPackageName(packagePath), version);
208923
209136
  return gitOutput2(["tag", "--list", tag], gitRoot) === tag;
208924
209137
  }
208925
- function readPackageManifest(packageRoot) {
208926
- return SourcePackageManifestSchema.parse(readYamlFile(path.join(packageRoot, "eigenpal.yaml")));
209138
+ async function readPackageManifest(packageRoot, config) {
209139
+ if (resolveGitSourceContext({ dir: packageRoot }).packagePath?.startsWith("agents/") && existsSync3(path2.join(packageRoot, "agent.ts")))
209140
+ return SourcePackageManifestSchema.parse((await compileLocalAgent(packageRoot, config)).definition.manifest);
209141
+ return SourcePackageManifestSchema.parse(readYamlFile(path2.join(packageRoot, "eigenpal.yaml")));
208927
209142
  }
208928
209143
  function requirePackageContext(opts = {}) {
208929
209144
  const context = resolveGitSourceContext(opts);
@@ -208952,8 +209167,8 @@ function validatePackageReferences(input) {
208952
209167
  const evaluatorItems = "evaluators" in input.manifest && input.manifest.evaluators && typeof input.manifest.evaluators === "object" && !Array.isArray(input.manifest.evaluators) && "items" in input.manifest.evaluators ? input.manifest.evaluators.items : [];
208953
209168
  for (const item of evaluatorItems) {
208954
209169
  if (item.use.startsWith("./")) {
208955
- const evaluatorPath = path.normalize(path.join(input.packageRoot, item.use));
208956
- if (!evaluatorPath.startsWith(`${input.packageRoot}${path.sep}`) || !existsSync2(evaluatorPath)) {
209170
+ const evaluatorPath = path2.normalize(path2.join(input.packageRoot, item.use));
209171
+ if (!evaluatorPath.startsWith(`${input.packageRoot}${path2.sep}`) || !existsSync3(evaluatorPath)) {
208957
209172
  errors.push(`Local evaluator ${item.use} does not exist.`);
208958
209173
  }
208959
209174
  continue;
@@ -208971,21 +209186,27 @@ function validatePackageReferences(input) {
208971
209186
  }
208972
209187
  return errors;
208973
209188
  }
208974
- function validatePackage(dir) {
209189
+ async function validatePackage(dir, config) {
208975
209190
  const context = resolveGitSourceContext({ dir });
208976
209191
  const errors = [];
208977
- const manifestPath = context.packageRoot ? path.join(context.packageRoot, "eigenpal.yaml") : null;
209192
+ const manifestPath = context.packageRoot ? path2.join(context.packageRoot, "eigenpal.yaml") : null;
208978
209193
  let parsedManifest = null;
208979
209194
  if (!context.gitRoot)
208980
209195
  errors.push("Not inside a Git repository.");
208981
209196
  if (!context.packageRoot || !manifestPath)
208982
209197
  errors.push("No package eigenpal.yaml found.");
208983
- if (context.packageRoot && existsSync2(path.join(context.packageRoot, "eigenpal.yml"))) {
209198
+ if (context.packageRoot && existsSync3(path2.join(context.packageRoot, "eigenpal.yml"))) {
208984
209199
  errors.push("Use eigenpal.yaml; eigenpal.yml package manifests are not supported.");
208985
209200
  }
208986
209201
  if (!context.packagePath)
208987
209202
  errors.push("Package must live under agents/, workflows/, resources/, or evaluators/.");
208988
- if (manifestPath && existsSync2(manifestPath)) {
209203
+ if (context.packagePath?.startsWith("agents/") && context.packageRoot && existsSync3(path2.join(context.packageRoot, "agent.ts"))) {
209204
+ try {
209205
+ parsedManifest = await readPackageManifest(context.packageRoot, config);
209206
+ } catch (error) {
209207
+ errors.push(error instanceof Error ? error.message : "Invalid TypeScript definition");
209208
+ }
209209
+ } else if (manifestPath && existsSync3(manifestPath)) {
208989
209210
  const filename = SourceManifestFilenameSchema.safeParse(manifestPath);
208990
209211
  if (!filename.success)
208991
209212
  errors.push(filename.error.issues.map((issue) => issue.message).join("; "));
@@ -208996,8 +209217,8 @@ function validatePackage(dir) {
208996
209217
  parsedManifest = manifest.data;
208997
209218
  }
208998
209219
  if (context.packageRoot) {
208999
- const secretsPath = path.join(context.packageRoot, SOURCE_SECRETS_FILENAME);
209000
- if (existsSync2(secretsPath)) {
209220
+ const secretsPath = path2.join(context.packageRoot, SOURCE_SECRETS_FILENAME);
209221
+ if (existsSync3(secretsPath)) {
209001
209222
  const secrets = SourceSecretsFileSchema.safeParse(readYamlFile(secretsPath));
209002
209223
  if (!secrets.success)
209003
209224
  errors.push(secrets.error.issues.map((issue) => issue.message).join("; "));
@@ -209020,8 +209241,8 @@ function validatePackage(dir) {
209020
209241
  return { valid: errors.length === 0, errors, packagePath: context.packagePath ?? undefined };
209021
209242
  }
209022
209243
  function readRootManifest(gitRoot) {
209023
- const manifestPath = path.join(gitRoot, "eigenpal.yaml");
209024
- if (!existsSync2(manifestPath))
209244
+ const manifestPath = path2.join(gitRoot, "eigenpal.yaml");
209245
+ if (!existsSync3(manifestPath))
209025
209246
  return { ok: false, error: "Root eigenpal.yaml is missing." };
209026
209247
  const parsed = RootSourceManifestSchema.safeParse(readYamlFile(manifestPath));
209027
209248
  if (!parsed.success)
@@ -209129,7 +209350,7 @@ async function doctor(opts) {
209129
209350
  detail: repoMajor === "1" ? `compatible ${root.version}` : `incompatible ${root.version}; run repository upgrade first`
209130
209351
  });
209131
209352
  }
209132
- const gitignore = existsSync2(path.join(context.gitRoot, ".gitignore")) ? readFileSync3(path.join(context.gitRoot, ".gitignore"), "utf8") : "";
209353
+ const gitignore = existsSync3(path2.join(context.gitRoot, ".gitignore")) ? readFileSync4(path2.join(context.gitRoot, ".gitignore"), "utf8") : "";
209133
209354
  for (const ignored of [".eigenpal/", "eigenpal_modules/"]) {
209134
209355
  checks.push({
209135
209356
  check: `ignore ${ignored}`,
@@ -209139,7 +209360,7 @@ async function doctor(opts) {
209139
209360
  }
209140
209361
  checks.push({
209141
209362
  check: "unsupported manifest",
209142
- status: existsSync2(path.join(context.gitRoot, "eigenpal.yml")) ? "fail" : "pass",
209363
+ status: existsSync3(path2.join(context.gitRoot, "eigenpal.yml")) ? "fail" : "pass",
209143
209364
  detail: "root eigenpal.yml must not exist"
209144
209365
  });
209145
209366
  const remoteUrl = gitOutput2(["remote", "get-url", "origin"], context.gitRoot);
@@ -209170,7 +209391,7 @@ async function doctor(opts) {
209170
209391
  }
209171
209392
  }
209172
209393
  if (context.packageRoot && context.packageRoot !== context.gitRoot) {
209173
- const result = validatePackage(context.packageRoot);
209394
+ const result = await validatePackage(context.packageRoot, resolveConfig(opts));
209174
209395
  checks.push({
209175
209396
  check: "package structure",
209176
209397
  status: result.valid ? "pass" : "fail",
@@ -209188,38 +209409,39 @@ async function doctor(opts) {
209188
209409
  if (checks.some((check) => check.status === "fail"))
209189
209410
  process.exit(1);
209190
209411
  }
209191
- function validateSourcePackage(dir) {
209412
+ async function validateSourcePackage(dir, config) {
209192
209413
  const context = resolveGitSourceContext({ dir });
209193
209414
  if (context.gitRoot)
209194
209415
  checkRepoVersion(context.gitRoot, false);
209195
- return validatePackage(dir);
209416
+ return await validatePackage(dir, config);
209196
209417
  }
209197
- function packageStatus(opts) {
209418
+ async function packageStatus(opts) {
209198
209419
  const context = resolveGitSourceContext(opts);
209199
209420
  if (context.gitRoot)
209200
209421
  checkRepoVersion(context.gitRoot, false);
209201
209422
  const isRepoRootStatus = context.gitRoot && context.packageRoot && context.gitRoot === context.packageRoot;
209202
- const validation = context.packageRoot && !isRepoRootStatus ? validatePackage(context.packageRoot) : null;
209423
+ const validation = context.packageRoot && !isRepoRootStatus ? await validatePackage(context.packageRoot, resolveConfig(opts)) : null;
209203
209424
  const gitStatusLines = context.gitRoot ? readGitStatusLines(context.gitRoot) : [];
209204
209425
  const branch = context.gitRoot ? currentBranchOrNull(context.gitRoot) : null;
209205
209426
  const upstream = context.gitRoot ? gitOutput2(["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"], context.gitRoot) : null;
209206
209427
  const head = context.gitRoot ? gitOutput2(["rev-parse", "HEAD"], context.gitRoot) : null;
209207
209428
  const aheadOfMain = context.gitRoot ? countAheadOfMain(context.gitRoot) : null;
209208
209429
  const dirtyPackages = context.gitRoot ? dirtyPackagePaths(context.gitRoot) : [];
209209
- const packages = dirtyPackages.map((packagePath) => {
209210
- const packageValidation = validatePackage(path.join(context.gitRoot, packagePath));
209211
- return {
209430
+ const packages = [];
209431
+ for (const packagePath of dirtyPackages) {
209432
+ const packageValidation = await validatePackage(path2.join(context.gitRoot, packagePath), resolveConfig(opts));
209433
+ packages.push({
209212
209434
  packagePath,
209213
209435
  clean: false,
209214
209436
  valid: packageValidation.valid,
209215
209437
  errors: packageValidation.errors
209216
- };
209217
- });
209438
+ });
209439
+ }
209218
209440
  if (context.gitRoot && context.packagePath && !packages.some((item) => item.packagePath === context.packagePath)) {
209219
209441
  packages.push({
209220
209442
  packagePath: context.packagePath,
209221
209443
  clean: readGitStatusLines(context.gitRoot, [context.packagePath]).length === 0,
209222
- valid: validation?.valid ?? validatePackage(context.packageRoot ?? opts.dir ?? process.cwd()).valid,
209444
+ valid: validation?.valid ?? (await validatePackage(context.packageRoot ?? opts.dir ?? process.cwd(), resolveConfig(opts))).valid,
209223
209445
  errors: validation?.errors ?? []
209224
209446
  });
209225
209447
  }
@@ -209248,11 +209470,11 @@ function packageStatus(opts) {
209248
209470
  ]));
209249
209471
  }
209250
209472
  }
209251
- function deps(opts) {
209473
+ async function deps(opts) {
209252
209474
  const context = resolveGitSourceContext(opts);
209253
209475
  if (!context.packageRoot)
209254
209476
  throw new Error("No package eigenpal.yaml found.");
209255
- const manifest = SourcePackageManifestSchema.parse(readYamlFile(path.join(context.packageRoot, "eigenpal.yaml")));
209477
+ const manifest = await readPackageManifest(context.packageRoot, resolveConfig(opts));
209256
209478
  const rows = Object.entries(manifest.dependencies ?? {}).map(([name, version]) => ({
209257
209479
  name,
209258
209480
  version
@@ -209309,7 +209531,7 @@ function dirtyPackagePaths(gitRoot) {
209309
209531
  const parts = file.split("/");
209310
209532
  for (let index = parts.length;index >= 2; index -= 1) {
209311
209533
  const candidate = parts.slice(0, index).join("/");
209312
- if (SourcePackagePathSchema.safeParse(candidate).success && existsSync2(path.join(gitRoot, candidate, "eigenpal.yaml"))) {
209534
+ if (SourcePackagePathSchema.safeParse(candidate).success && packageManifestExists(gitRoot, candidate)) {
209313
209535
  packagePaths.add(candidate);
209314
209536
  break;
209315
209537
  }
@@ -209318,7 +209540,12 @@ function dirtyPackagePaths(gitRoot) {
209318
209540
  return [...packagePaths].sort();
209319
209541
  }
209320
209542
  function dirtyRootFiles(gitRoot) {
209321
- return readGitStatusLines(gitRoot, ["eigenpal.yaml", ".gitignore"]).map(statusPath).filter((file) => file === "eigenpal.yaml" || file === ".gitignore");
209543
+ return readGitStatusLines(gitRoot, [
209544
+ "eigenpal.yaml",
209545
+ ".gitignore",
209546
+ "package.json",
209547
+ "package-lock.json"
209548
+ ]).map(statusPath).filter((file) => ["eigenpal.yaml", ".gitignore", "package.json", "package-lock.json"].includes(file));
209322
209549
  }
209323
209550
  function hasDirtySharedResources(gitRoot) {
209324
209551
  return readGitStatusLines(gitRoot, ["resources"]).length > 0;
@@ -209337,7 +209564,7 @@ async function commitSourceChanges(input) {
209337
209564
  throw new Error("Commit requires -m <message> when source changes are dirty.");
209338
209565
  }
209339
209566
  for (const packagePath of packagePaths) {
209340
- const validation = validatePackage(path.join(input.context.gitRoot, packagePath));
209567
+ const validation = await validatePackage(path2.join(input.context.gitRoot, packagePath), input.config);
209341
209568
  if (!validation.valid) {
209342
209569
  throw new Error(`Package validation failed for ${packagePath}: ${validation.errors.join("; ")}`);
209343
209570
  }
@@ -209384,39 +209611,44 @@ function writePackageScaffold(packageRoot, packagePath, name) {
209384
209611
  const [root, resourceKind] = packagePath.split("/");
209385
209612
  mkdirSync2(packageRoot, { recursive: true });
209386
209613
  const title = name.trim();
209387
- writeFileSync3(path2.join(packageRoot, "eigenpal.yaml"), exports_dist.stringify({ schemaVersion: 1, name: title || path2.basename(packagePath) }));
209388
209614
  if (root === "agents")
209389
- writeFileSync3(path2.join(packageRoot, "AGENT.md"), `# ${title}
209615
+ writeFileSync3(path3.join(packageRoot, "agent.ts"), `import {createAgent} from '@eigenpal/automations';
209616
+ export default createAgent(${JSON.stringify({ name: title || path3.basename(packagePath) }, null, 2)});
209617
+ `);
209618
+ else
209619
+ writeFileSync3(path3.join(packageRoot, "eigenpal.yaml"), exports_dist.stringify({ schemaVersion: 1, name: title || path3.basename(packagePath) }));
209620
+ if (root === "agents")
209621
+ writeFileSync3(path3.join(packageRoot, "AGENT.md"), `# ${title}
209390
209622
 
209391
209623
  `);
209392
209624
  if (root === "evaluators") {
209393
- writeFileSync3(path2.join(packageRoot, "evaluator.yaml"), exports_dist.stringify({ schemaVersion: 1, type: "exact-diff", config: {} }));
209625
+ writeFileSync3(path3.join(packageRoot, "evaluator.yaml"), exports_dist.stringify({ schemaVersion: 1, type: "exact-diff", config: {} }));
209394
209626
  }
209395
209627
  if (root === "resources" && resourceKind === "skills") {
209396
- writeFileSync3(path2.join(packageRoot, "SKILL.md"), `# ${title}
209628
+ writeFileSync3(path3.join(packageRoot, "SKILL.md"), `# ${title}
209397
209629
 
209398
209630
  `);
209399
209631
  }
209400
209632
  if (root === "resources" && (resourceKind === "rules" || resourceKind === "knowledge")) {
209401
- writeFileSync3(path2.join(packageRoot, "README.md"), `# ${title}
209633
+ writeFileSync3(path3.join(packageRoot, "README.md"), `# ${title}
209402
209634
 
209403
209635
  `);
209404
209636
  }
209405
209637
  }
209406
- function initPackage(name, opts) {
209407
- const startDir = path2.resolve(opts.dir ?? process.cwd());
209638
+ async function initPackage(name, opts) {
209639
+ const startDir = path3.resolve(opts.dir ?? process.cwd());
209408
209640
  const gitRoot = resolveGitRoot2(startDir) ?? startDir;
209409
209641
  mkdirSync2(gitRoot, { recursive: true });
209410
- if (!existsSync3(path2.join(gitRoot, ".git")))
209642
+ if (!existsSync4(path3.join(gitRoot, ".git")))
209411
209643
  runGit(["init", "-b", "main", gitRoot]);
209412
- if (!existsSync3(path2.join(gitRoot, "eigenpal.yaml"))) {
209413
- writeFileSync3(path2.join(gitRoot, "eigenpal.yaml"), `schemaVersion: 1
209644
+ if (!existsSync4(path3.join(gitRoot, "eigenpal.yaml"))) {
209645
+ writeFileSync3(path3.join(gitRoot, "eigenpal.yaml"), `schemaVersion: 1
209414
209646
  eigenpalVersion: 1.0.0
209415
209647
  `);
209416
209648
  }
209417
- const gitignorePath = path2.join(gitRoot, ".gitignore");
209418
- const gitignore = existsSync3(gitignorePath) ? readFileSync4(gitignorePath, "utf8") : "";
209419
- const additions = [".eigenpal/", "eigenpal_modules/"].filter((entry) => !gitignore.includes(entry));
209649
+ const gitignorePath = path3.join(gitRoot, ".gitignore");
209650
+ const gitignore = existsSync4(gitignorePath) ? readFileSync5(gitignorePath, "utf8") : "";
209651
+ const additions = [".eigenpal/", "eigenpal_modules/", "node_modules/"].filter((entry) => !gitignore.includes(entry));
209420
209652
  if (additions.length > 0)
209421
209653
  writeFileSync3(gitignorePath, `${gitignore}${gitignore.endsWith(`
209422
209654
  `) || !gitignore ? "" : `
@@ -209424,10 +209656,25 @@ eigenpalVersion: 1.0.0
209424
209656
  `)}
209425
209657
  `);
209426
209658
  const packagePath = packagePathForTemplate(opts.template, name);
209427
- const packageRoot = path2.join(gitRoot, packagePath);
209428
- if (existsSync3(packageRoot))
209659
+ const packageRoot = path3.join(gitRoot, packagePath);
209660
+ if (existsSync4(packageRoot))
209429
209661
  throw new Error(`Package already exists: ${packagePath}`);
209430
209662
  writePackageScaffold(packageRoot, packagePath, name);
209663
+ if (opts.template === "agent") {
209664
+ const toolchain = { sdkVersion: CLI_VERSION, zodVersion: package_default2.version };
209665
+ const file = path3.join(gitRoot, "package.json");
209666
+ const current = existsSync4(file) ? JSON.parse(readFileSync5(file, "utf8")) : { private: true, type: "module" };
209667
+ const additions = {};
209668
+ for (const [name, version] of Object.entries({
209669
+ "@eigenpal/automations": toolchain.sdkVersion,
209670
+ zod: toolchain.zodVersion
209671
+ }))
209672
+ if (!current.dependencies?.[name] && !current.devDependencies?.[name])
209673
+ additions[name] = version;
209674
+ if (Object.keys(additions).length > 0)
209675
+ writeFileSync3(file, JSON.stringify({ ...current, devDependencies: { ...current.devDependencies, ...additions } }, null, 2) + `
209676
+ `);
209677
+ }
209431
209678
  success(`Created ${packagePath}.`);
209432
209679
  }
209433
209680
  function parseTemplate(value) {
@@ -209441,7 +209688,7 @@ function registerSourceInitCommand(agent) {
209441
209688
  }
209442
209689
 
209443
209690
  // src/commands/git/passthrough.ts
209444
- import path3 from "node:path";
209691
+ import path4 from "node:path";
209445
209692
  function gitCommandCreatesObjects(args) {
209446
209693
  const objectCreatingCommands = new Set([
209447
209694
  "cherry-pick",
@@ -209462,7 +209709,7 @@ function gitCwdFromArgs(args) {
209462
209709
  let cwd = process.cwd();
209463
209710
  for (let i = 0;i < args.length; i += 1) {
209464
209711
  if (args[i] === "-C" && args[i + 1]) {
209465
- cwd = path3.resolve(cwd, args[i + 1]);
209712
+ cwd = path4.resolve(cwd, args[i + 1]);
209466
209713
  i += 1;
209467
209714
  }
209468
209715
  }
@@ -209522,26 +209769,26 @@ async function runGitPassthrough(args, opts) {
209522
209769
 
209523
209770
  // src/commands/git/secrets.ts
209524
209771
  init_src();
209525
- import { existsSync as existsSync4, readFileSync as readFileSync5 } from "node:fs";
209526
- import path4 from "node:path";
209772
+ import { existsSync as existsSync5, readFileSync as readFileSync6 } from "node:fs";
209773
+ import path5 from "node:path";
209527
209774
  function readSecretsFile(packageRoot) {
209528
- const filePath = path4.join(packageRoot, SOURCE_SECRETS_FILENAME);
209529
- if (!existsSync4(filePath))
209775
+ const filePath = path5.join(packageRoot, SOURCE_SECRETS_FILENAME);
209776
+ if (!existsSync5(filePath))
209530
209777
  return { schemaVersion: 1, secrets: {} };
209531
209778
  return SourceSecretsFileSchema.parse(readYamlFile(filePath));
209532
209779
  }
209533
209780
  function writeSecretsFile(packageRoot, value) {
209534
209781
  const secretsFile = SourceSecretsFileSchema.parse(value);
209535
- writeYamlFile(path4.join(packageRoot, SOURCE_SECRETS_FILENAME), secretsFile);
209782
+ writeYamlFile(path5.join(packageRoot, SOURCE_SECRETS_FILENAME), secretsFile);
209536
209783
  }
209537
209784
  async function readSecretInput(opts) {
209538
209785
  const selected = [opts.stdin, opts.valueFile].filter(Boolean).length;
209539
209786
  if (selected > 1)
209540
209787
  throw new Error("Pass only one of --stdin or --value-file.");
209541
209788
  if (opts.stdin)
209542
- return readFileSync5(0, "utf8").replace(/\n$/, "");
209789
+ return readFileSync6(0, "utf8").replace(/\n$/, "");
209543
209790
  if (opts.valueFile)
209544
- return readFileSync5(opts.valueFile, "utf8").replace(/\n$/, "");
209791
+ return readFileSync6(opts.valueFile, "utf8").replace(/\n$/, "");
209545
209792
  if (process.stdin.isTTY && process.stdout.isTTY) {
209546
209793
  await Promise.resolve().then(() => init_dist4());
209547
209794
  const answer = await Ce({ message: "Secret value" });
@@ -209597,7 +209844,7 @@ async function importSecrets(envFile, opts) {
209597
209844
  const client = new ApiClient(config);
209598
209845
  const sourcePath = `${context.packagePath}/${SOURCE_SECRETS_FILENAME}`;
209599
209846
  const entries = [];
209600
- const content = readFileSync5(envFile, "utf8");
209847
+ const content = readFileSync6(envFile, "utf8");
209601
209848
  for (const line of content.split(/\r?\n/)) {
209602
209849
  const trimmed = line.trim();
209603
209850
  if (!trimmed || trimmed.startsWith("#"))
@@ -209673,7 +209920,8 @@ var InstallLockPackageSchema = lazy(() => object({
209673
209920
  resolvedRef: string2().min(1),
209674
209921
  resolvedTag: string2().min(1).optional(),
209675
209922
  commit: CommitShaSchema,
209676
- dependencies: array(InstallLockPackageSchema)
209923
+ dependencies: array(InstallLockPackageSchema),
209924
+ compiledAgent: CompiledAgentSnapshotSchema.optional()
209677
209925
  }));
209678
209926
  var InstallLockfileSchema = object({
209679
209927
  lockfileVersion: literal(1),
@@ -209801,7 +210049,7 @@ async function resolveRemoteRefCommit(config, repository, ref) {
209801
210049
  function archivePackage(input) {
209802
210050
  rmSync(input.outDir, { recursive: true, force: true });
209803
210051
  mkdirSync3(input.outDir, { recursive: true });
209804
- const tarPath = path5.join(mkdtempSyncCompat("eigenpal-source-archive-"), "package.tar");
210052
+ const tarPath = path6.join(mkdtempSyncCompat("eigenpal-source-archive-"), "package.tar");
209805
210053
  try {
209806
210054
  runGit(["archive", "--format=tar", `--output=${tarPath}`, input.ref, input.packagePath], {
209807
210055
  cwd: input.gitRoot
@@ -209813,7 +210061,7 @@ function archivePackage(input) {
209813
210061
  if (extract.status !== 0)
209814
210062
  throw new Error(extract.stderr.trim() || "tar extraction failed");
209815
210063
  } finally {
209816
- rmSync(path5.dirname(tarPath), { recursive: true, force: true });
210064
+ rmSync(path6.dirname(tarPath), { recursive: true, force: true });
209817
210065
  }
209818
210066
  }
209819
210067
  async function tryHostedArchive(input) {
@@ -209840,7 +210088,7 @@ async function tryHostedArchive(input) {
209840
210088
  return false;
209841
210089
  rmSync(input.outDir, { recursive: true, force: true });
209842
210090
  mkdirSync3(input.outDir, { recursive: true });
209843
- const tarPath = path5.join(mkdtempSyncCompat("eigenpal-hosted-source-"), "package.tar");
210091
+ const tarPath = path6.join(mkdtempSyncCompat("eigenpal-hosted-source-"), "package.tar");
209844
210092
  try {
209845
210093
  writeFileSync4(tarPath, Buffer.from(await response.arrayBuffer()));
209846
210094
  const extract = spawnSync3("tar", ["-xf", tarPath, "--strip-components", String(input.packagePath.split("/").length)], {
@@ -209851,30 +210099,33 @@ async function tryHostedArchive(input) {
209851
210099
  throw new Error(extract.stderr.trim() || "tar extraction failed");
209852
210100
  return true;
209853
210101
  } finally {
209854
- rmSync(path5.dirname(tarPath), { recursive: true, force: true });
210102
+ rmSync(path6.dirname(tarPath), { recursive: true, force: true });
209855
210103
  }
209856
210104
  }
209857
210105
  function mkdtempSyncCompat(prefix) {
209858
- return mkdtempSync(path5.join(tmpdir(), prefix));
210106
+ return mkdtempSync(path6.join(tmpdir(), prefix));
209859
210107
  }
209860
210108
  function dependencyInstallPath(parentRoot, packagePath) {
209861
- const modulesRoot = path5.resolve(parentRoot, "eigenpal_modules");
209862
- const destination = path5.resolve(modulesRoot, packagePath);
209863
- if (destination !== modulesRoot && !destination.startsWith(`${modulesRoot}${path5.sep}`)) {
210109
+ const modulesRoot = path6.resolve(parentRoot, "eigenpal_modules");
210110
+ const destination = path6.resolve(modulesRoot, packagePath);
210111
+ if (destination !== modulesRoot && !destination.startsWith(`${modulesRoot}${path6.sep}`)) {
209864
210112
  throw new Error(`Dependency path escapes eigenpal_modules: ${packagePath}`);
209865
210113
  }
209866
210114
  return destination;
209867
210115
  }
209868
210116
  async function resolvePackageGraph(input) {
210117
+ const budget = input.budget ?? { remaining: 32 };
210118
+ if (--budget.remaining < 0)
210119
+ throw new Error("Source dependencies exceed the 32-package resolution limit");
209869
210120
  const seen = input.seen ?? [];
209870
210121
  const key = `${input.packagePath}@${input.ref}`;
209871
210122
  if (seen.includes(key)) {
209872
210123
  throw new Error(`Dependency cycle detected: ${[...seen, key].join(" -> ")}`);
209873
210124
  }
209874
210125
  const resolved = await resolvePackageRef(input);
209875
- const tempDir = await mkdtemp(path5.join(tmpdir(), "eigenpal-install-resolve-"));
210126
+ const tempDir = await mkdtemp(path6.join(tmpdir(), "eigenpal-install-resolve-"));
209876
210127
  try {
209877
- const packageRoot = path5.join(tempDir, "package");
210128
+ const packageRoot = path6.join(tempDir, "package");
209878
210129
  const ref = resolved.commit;
209879
210130
  if (input.gitRoot) {
209880
210131
  archivePackage({
@@ -209892,22 +210143,28 @@ async function resolvePackageGraph(input) {
209892
210143
  })) {
209893
210144
  throw new Error(`Hosted source export unavailable for ${input.packagePath}@${ref}.`);
209894
210145
  }
209895
- const manifest = readPackageManifest(packageRoot);
210146
+ const compiledAgent = input.packagePath.startsWith("agents/") && existsSync6(path6.join(packageRoot, "agent.ts")) ? await compileLocalAgent(packageRoot, input.config) : undefined;
210147
+ const manifest = compiledAgent ? compiledAgent.definition.manifest : await readPackageManifest(packageRoot);
209896
210148
  const dependencies = "dependencies" in manifest ? Object.entries(manifest.dependencies ?? {}) : [];
210149
+ const resolvedDependencies = [];
210150
+ for (const [dependencyName, version] of dependencies)
210151
+ resolvedDependencies.push(await resolvePackageGraph({
210152
+ config: input.config,
210153
+ gitRoot: input.gitRoot,
210154
+ repository: input.repository,
210155
+ packagePath: workspaceDependencyNameToPackagePath(dependencyName),
210156
+ ref: SourceVersionRefSchema.parse(version),
210157
+ seen: [...seen, key],
210158
+ budget
210159
+ }));
209897
210160
  return {
209898
210161
  packagePath: input.packagePath,
210162
+ ...compiledAgent ? { compiledAgent } : {},
209899
210163
  requestedRef: input.ref,
209900
210164
  resolvedRef: resolved.resolvedRef,
209901
210165
  ...resolved.resolvedTag ? { resolvedTag: resolved.resolvedTag } : {},
209902
210166
  commit: resolved.commit,
209903
- dependencies: await Promise.all(dependencies.map(([dependencyName, version]) => resolvePackageGraph({
209904
- config: input.config,
209905
- gitRoot: input.gitRoot,
209906
- repository: input.repository,
209907
- packagePath: workspaceDependencyNameToPackagePath(dependencyName),
209908
- ref: SourceVersionRefSchema.parse(version),
209909
- seen: [...seen, key]
209910
- })))
210167
+ dependencies: resolvedDependencies
209911
210168
  };
209912
210169
  } finally {
209913
210170
  rmSync(tempDir, { recursive: true, force: true });
@@ -209935,6 +210192,20 @@ async function materializeLockPackage(input) {
209935
210192
  outDir: input.outDir
209936
210193
  });
209937
210194
  }
210195
+ if (input.lockPackage.compiledAgent) {
210196
+ if (!input.lockPackage.packagePath.startsWith("agents/") || !existsSync6(path6.join(input.outDir, "agent.ts")))
210197
+ throw new Error("Compiled definition does not match installed agent package");
210198
+ const { definition } = input.lockPackage.compiledAgent;
210199
+ for (const key of ["inputSchema", "outputSchema"]) {
210200
+ const filename = key === "inputSchema" ? "input-schema.json" : "output-schema.json";
210201
+ if (existsSync6(path6.join(input.outDir, filename)) || existsSync6(path6.join(input.outDir, "eigenpal.yaml")))
210202
+ throw new Error("Installed agent mixes TypeScript and legacy definitions");
210203
+ if (definition[key] !== undefined)
210204
+ writeFileSync4(path6.join(input.outDir, filename), JSON.stringify(definition[key], null, 2), {
210205
+ flag: "wx"
210206
+ });
210207
+ }
210208
+ }
209938
210209
  const occupied = new Set;
209939
210210
  for (const dependency of input.lockPackage.dependencies) {
209940
210211
  const dependencyPath = dependencyInstallPath(input.outDir, dependency.packagePath);
@@ -209952,12 +210223,12 @@ async function materializeLockPackage(input) {
209952
210223
  }
209953
210224
  }
209954
210225
  function writeLockfile(lockfilePath, lockfile) {
209955
- mkdirSync3(path5.dirname(lockfilePath), { recursive: true });
210226
+ mkdirSync3(path6.dirname(lockfilePath), { recursive: true });
209956
210227
  writeFileSync4(lockfilePath, `${JSON.stringify(lockfile, null, 2)}
209957
210228
  `);
209958
210229
  }
209959
210230
  function readLockfile(lockfilePath) {
209960
- const parsed = InstallLockfileSchema.safeParse(JSON.parse(readFileSync6(lockfilePath, "utf8")));
210231
+ const parsed = InstallLockfileSchema.safeParse(JSON.parse(readFileSync7(lockfilePath, "utf8")));
209961
210232
  if (!parsed.success) {
209962
210233
  throw new Error(`Invalid lockfile ${lockfilePath}: ${parsed.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ")}`);
209963
210234
  }
@@ -210077,12 +210348,12 @@ async function syncLatestAutomation(client, packagePath) {
210077
210348
  async function cloneSource(opts) {
210078
210349
  const config = resolveConfig(opts);
210079
210350
  const repo = await getSourceRepository(config);
210080
- const outDir = opts.out ?? path5.basename(repo.gitRepositoryPath);
210351
+ const outDir = opts.out ?? path6.basename(repo.gitRepositoryPath);
210081
210352
  runGit(["clone", repo.remoteUrl, outDir], {
210082
210353
  config,
210083
210354
  bootstrapRemoteUrl: repo.remoteUrl
210084
210355
  });
210085
- const clonedRoot = path5.resolve(process.cwd(), outDir);
210356
+ const clonedRoot = path6.resolve(process.cwd(), outDir);
210086
210357
  await configureSourceGitRepo({
210087
210358
  gitRoot: clonedRoot,
210088
210359
  config,
@@ -210152,7 +210423,7 @@ async function release(versionOrBump, dir, opts) {
210152
210423
  };
210153
210424
  const config = resolveConfig(opts);
210154
210425
  checkRepoVersion(resolvedContext.gitRoot, true);
210155
- const validation = validatePackage(resolvedContext.packageRoot);
210426
+ const validation = await validatePackage(resolvedContext.packageRoot, config);
210156
210427
  if (!validation.valid)
210157
210428
  throw new Error(`Package validation failed: ${validation.errors.join("; ")}`);
210158
210429
  const releaseMessage = opts.message?.trim() || `Release ${resolvedContext.packagePath}`;
@@ -210254,7 +210525,7 @@ async function install(packageRef, opts) {
210254
210525
  if (expectedPackagePath && lockfile.root.packagePath !== expectedPackagePath) {
210255
210526
  throw new Error(`Lockfile root package ${lockfile.root.packagePath} does not match requested package ${expectedPackagePath}.`);
210256
210527
  }
210257
- const destination = explicitRef ? path5.resolve(opts.out ?? path5.basename(lockfile.root.packagePath)) : packageDestination;
210528
+ const destination = explicitRef ? path6.resolve(opts.out ?? path6.basename(lockfile.root.packagePath)) : packageDestination;
210258
210529
  if (!destination)
210259
210530
  throw new Error("No package context found for lockfile install.");
210260
210531
  const lockInstallGitRoot = explicitRef ? explicitGitRoot ?? sourceGitRoot : context.gitRoot;
@@ -210266,9 +210537,9 @@ async function install(packageRef, opts) {
210266
210537
  lockPackage: lockfile.root,
210267
210538
  outDir: destination
210268
210539
  });
210269
- writeLockfile(path5.join(destination, ".eigenpal", INSTALL_LOCKFILE_NAME), lockfile);
210540
+ writeLockfile(path6.join(destination, ".eigenpal", INSTALL_LOCKFILE_NAME), lockfile);
210270
210541
  } else {
210271
- rmSync(path5.join(destination, "eigenpal_modules"), { recursive: true, force: true });
210542
+ rmSync(path6.join(destination, "eigenpal_modules"), { recursive: true, force: true });
210272
210543
  for (const dependency of lockfile.root.dependencies) {
210273
210544
  await materializeLockPackage({
210274
210545
  config,
@@ -210286,12 +210557,12 @@ async function install(packageRef, opts) {
210286
210557
  const expectedPackagePath = packageRef ? parsePackageRef(packageRef).packagePath : null;
210287
210558
  const explicitGitRoot = explicitRef && expectedPackagePath && context.gitRoot ? packageManifestExists(context.gitRoot, expectedPackagePath) ? context.gitRoot : sourceGitRoot : sourceGitRoot;
210288
210559
  const repository = explicitRef && !explicitGitRoot ? await getSourceRepository(config, opts) : null;
210289
- const lockfilePath = opts.lockfile ?? path5.join(packageRef && opts.out ? path5.resolve(opts.out) : context.packageRoot ?? process.cwd(), ".eigenpal", INSTALL_LOCKFILE_NAME);
210560
+ const lockfilePath = opts.lockfile ?? path6.join(packageRef && opts.out ? path6.resolve(opts.out) : context.packageRoot ?? process.cwd(), ".eigenpal", INSTALL_LOCKFILE_NAME);
210290
210561
  if (!explicitRef) {
210291
210562
  if (!context.packageRoot || !context.packagePath) {
210292
210563
  throw new Error("Run eigenpal agents install --frozen-lockfile inside a source package or pass a package ref.");
210293
210564
  }
210294
- const manifest = readPackageManifest(context.packageRoot);
210565
+ const manifest = await readPackageManifest(context.packageRoot, config);
210295
210566
  const dependencies = "dependencies" in manifest ? Object.entries(manifest.dependencies ?? {}) : [];
210296
210567
  const inputHash = sourceLockfileInputHash({ packagePath: context.packagePath, dependencies });
210297
210568
  const existing = readLockfile(lockfilePath);
@@ -210314,9 +210585,9 @@ async function install(packageRef, opts) {
210314
210585
  const repository = explicitGitRoot ? null : await getSourceRepository(config, opts);
210315
210586
  if (parsed.ref === "main")
210316
210587
  warn("Installing @main uses draft source and is not reproducible.");
210317
- const intendedLockfile = opts.lockfile ?? path5.join(path5.resolve(opts.out ?? path5.basename(parsed.packagePath)), ".eigenpal", INSTALL_LOCKFILE_NAME);
210588
+ const intendedLockfile = opts.lockfile ?? path6.join(path6.resolve(opts.out ?? path6.basename(parsed.packagePath)), ".eigenpal", INSTALL_LOCKFILE_NAME);
210318
210589
  const inputHash = sourceLockfileInputHash({ packageRef });
210319
- if (existsSync5(intendedLockfile)) {
210590
+ if (existsSync6(intendedLockfile)) {
210320
210591
  const existing = readLockfile(intendedLockfile);
210321
210592
  if (existing.inputHash !== inputHash) {
210322
210593
  throw new Error(`Existing lockfile ${intendedLockfile} does not match requested package ref.`);
@@ -210331,7 +210602,7 @@ async function install(packageRef, opts) {
210331
210602
  packagePath: parsed.packagePath,
210332
210603
  ref: parsed.ref
210333
210604
  });
210334
- const outDir = path5.resolve(opts.out ?? path5.basename(parsed.packagePath));
210605
+ const outDir = path6.resolve(opts.out ?? path6.basename(parsed.packagePath));
210335
210606
  await materializeLockPackage({
210336
210607
  config,
210337
210608
  gitRoot: explicitGitRoot,
@@ -210355,11 +210626,11 @@ async function install(packageRef, opts) {
210355
210626
  if (!context.gitRoot) {
210356
210627
  throw new Error("Run eigenpal agents install inside an organization source repository.");
210357
210628
  }
210358
- const manifest = readPackageManifest(context.packageRoot);
210629
+ const manifest = await readPackageManifest(context.packageRoot, config);
210359
210630
  const dependencies = "dependencies" in manifest ? Object.entries(manifest.dependencies ?? {}) : [];
210360
210631
  const inputHash = sourceLockfileInputHash({ packagePath: context.packagePath, dependencies });
210361
- const intendedLockfile = opts.lockfile ?? path5.join(context.packageRoot, ".eigenpal", INSTALL_LOCKFILE_NAME);
210362
- if (existsSync5(intendedLockfile)) {
210632
+ const intendedLockfile = opts.lockfile ?? path6.join(context.packageRoot, ".eigenpal", INSTALL_LOCKFILE_NAME);
210633
+ if (existsSync6(intendedLockfile)) {
210363
210634
  const existing = readLockfile(intendedLockfile);
210364
210635
  if (existing.inputHash !== inputHash) {
210365
210636
  throw new Error(`Existing lockfile ${intendedLockfile} does not match current package inputs.`);
@@ -210379,7 +210650,7 @@ async function install(packageRef, opts) {
210379
210650
  ref: SourceVersionRefSchema.parse(version)
210380
210651
  })))
210381
210652
  };
210382
- rmSync(path5.join(context.packageRoot, "eigenpal_modules"), { recursive: true, force: true });
210653
+ rmSync(path6.join(context.packageRoot, "eigenpal_modules"), { recursive: true, force: true });
210383
210654
  for (const dependency of root.dependencies) {
210384
210655
  await materializeLockPackage({
210385
210656
  config,
@@ -210437,7 +210708,7 @@ async function upgradeSource(opts) {
210437
210708
  const context = resolveGitSourceContext({ dir: opts.dir });
210438
210709
  if (!context.gitRoot)
210439
210710
  throw new Error("Not inside a Git repository.");
210440
- const manifestPath = path5.join(context.gitRoot, "eigenpal.yaml");
210711
+ const manifestPath = path6.join(context.gitRoot, "eigenpal.yaml");
210441
210712
  const manifest = readRootManifest(context.gitRoot);
210442
210713
  if (!manifest.ok)
210443
210714
  throw new Error(manifest.error);
@@ -211155,8 +211426,8 @@ function zipSync(data, opts) {
211155
211426
  }
211156
211427
 
211157
211428
  // src/commands/agents/dataset.ts
211158
- import { existsSync as existsSync8, promises as fs3 } from "node:fs";
211159
- import path8 from "node:path";
211429
+ import { existsSync as existsSync9, promises as fs3 } from "node:fs";
211430
+ import path9 from "node:path";
211160
211431
 
211161
211432
  // src/commands/dataset-review-request.ts
211162
211433
  import { mkdir, readFile as readFile2, stat, writeFile as writeFile2 } from "node:fs/promises";
@@ -211164,8 +211435,8 @@ import { basename, dirname as dirname2, isAbsolute, join as join2, relative, res
211164
211435
 
211165
211436
  // src/commands/agents/shared.ts
211166
211437
  init_src();
211167
- import { existsSync as existsSync6, promises as fs } from "node:fs";
211168
- import path6 from "node:path";
211438
+ import { existsSync as existsSync7, promises as fs } from "node:fs";
211439
+ import path7 from "node:path";
211169
211440
  var PACKAGE_MANIFEST = "eigenpal.yaml";
211170
211441
  var DATASET_DIR = "dataset";
211171
211442
  var SCHEMA_FILENAMES = ["input-schema.json", "output-schema.json"];
@@ -211191,7 +211462,7 @@ function buildClient2(opts) {
211191
211462
  return new ApiClient(config);
211192
211463
  }
211193
211464
  async function writeBase64File(file, contentBase64) {
211194
- await fs.mkdir(path6.dirname(file), { recursive: true });
211465
+ await fs.mkdir(path7.dirname(file), { recursive: true });
211195
211466
  await fs.writeFile(file, Buffer.from(contentBase64, "base64"));
211196
211467
  }
211197
211468
  async function pollRun(client, executionId, interval, maxWait, json = false) {
@@ -211901,24 +212172,24 @@ live dataset example-by-example by hand (reviewers can err), then
211901
212172
 
211902
212173
  // src/commands/agents/validation.ts
211903
212174
  init_src();
211904
- import { existsSync as existsSync7, promises as fs2 } from "node:fs";
211905
- import path7 from "node:path";
212175
+ import { existsSync as existsSync8, promises as fs2 } from "node:fs";
212176
+ import path8 from "node:path";
211906
212177
  async function validateAgentProject(root) {
211907
212178
  const errors = [];
211908
212179
  const warnings = [];
211909
212180
  for (const [oldName] of LEGACY_LAYOUTS) {
211910
- if (existsSync7(path7.join(root, oldName))) {
212181
+ if (existsSync8(path8.join(root, oldName))) {
211911
212182
  errors.push(`Legacy layout ${oldName}/ is removed; use Git source under agents/<slug>/`);
211912
212183
  }
211913
212184
  }
211914
- if (existsSync7(path7.join(root, "agent.yaml"))) {
212185
+ if (existsSync8(path8.join(root, "agent.yaml"))) {
211915
212186
  errors.push("Legacy agent.yaml layout is removed; use eigenpal.yaml in a Git-backed package");
211916
212187
  }
211917
- if (existsSync7(path7.join(root, "agent"))) {
212188
+ if (existsSync8(path8.join(root, "agent"))) {
211918
212189
  errors.push("Legacy agent/ directory is removed; use Git source (eigenpal agents clone)");
211919
212190
  }
211920
- const manifestPath = path7.join(root, PACKAGE_MANIFEST);
211921
- if (!existsSync7(manifestPath)) {
212191
+ const manifestPath = path8.join(root, PACKAGE_MANIFEST);
212192
+ if (existsSync8(path8.join(root, "agent.ts"))) {} else if (!existsSync8(manifestPath)) {
211922
212193
  errors.push(`Missing ${PACKAGE_MANIFEST}`);
211923
212194
  } else {
211924
212195
  try {
@@ -211927,15 +212198,15 @@ async function validateAgentProject(root) {
211927
212198
  errors.push(err instanceof Error ? err.message : String(err));
211928
212199
  }
211929
212200
  }
211930
- if (!existsSync7(path7.join(root, "AGENT.md")))
212201
+ if (!existsSync8(path8.join(root, "AGENT.md")))
211931
212202
  warnings.push("Missing AGENT.md");
211932
- if (!existsSync7(path7.join(root, DATASET_DIR)))
212203
+ if (!existsSync8(path8.join(root, DATASET_DIR)))
211933
212204
  warnings.push(`Missing ${DATASET_DIR}/`);
211934
212205
  for (const filename of SCHEMA_FILENAMES) {
211935
- const schemaPath = path7.join(root, filename);
211936
- if (!existsSync7(schemaPath))
212206
+ const schemaPath = path8.join(root, filename);
212207
+ if (!existsSync8(schemaPath))
211937
212208
  continue;
211938
- const validation = validateWorkspaceSchema(await fs2.readFile(schemaPath, "utf8"), filename);
212209
+ const validation = validateAgentSchema(await fs2.readFile(schemaPath, "utf8"), filename);
211939
212210
  for (const issue of validation.errors) {
211940
212211
  errors.push(`${filename}: ${issue}`);
211941
212212
  }
@@ -211944,16 +212215,16 @@ async function validateAgentProject(root) {
211944
212215
  }
211945
212216
  async function validateDatasetDir(dir, opts = {}) {
211946
212217
  const errors = [];
211947
- if (!existsSync7(dir))
212218
+ if (!existsSync8(dir))
211948
212219
  errors.push(`Missing dataset directory: ${dir}`);
211949
212220
  for (const [oldName, newName] of LEGACY_LAYOUTS) {
211950
- if (path7.basename(dir) === oldName) {
212221
+ if (path8.basename(dir) === oldName) {
211951
212222
  errors.push(`Use ${newName}/ instead of legacy ${oldName}/`);
211952
212223
  }
211953
212224
  }
211954
212225
  if (errors.length > 0)
211955
212226
  return { valid: false, errors };
211956
- if (existsSync7(path7.join(dir, "manifest.json"))) {
212227
+ if (existsSync8(path8.join(dir, "manifest.json"))) {
211957
212228
  return {
211958
212229
  valid: false,
211959
212230
  errors: [
@@ -211961,8 +212232,8 @@ async function validateDatasetDir(dir, opts = {}) {
211961
212232
  ]
211962
212233
  };
211963
212234
  }
211964
- const examplesDir = path7.join(dir, "examples");
211965
- if (!existsSync7(examplesDir) || !(await fs2.stat(examplesDir)).isDirectory()) {
212235
+ const examplesDir = path8.join(dir, "examples");
212236
+ if (!existsSync8(examplesDir) || !(await fs2.stat(examplesDir)).isDirectory()) {
211966
212237
  errors.push("examples/: missing examples/ directory at dataset root");
211967
212238
  const flatFolders = await listImmediateDirs(dir);
211968
212239
  if (flatFolders.length > 0) {
@@ -211971,8 +212242,9 @@ async function validateDatasetDir(dir, opts = {}) {
211971
212242
  return { valid: false, errors };
211972
212243
  }
211973
212244
  const agentDir = opts.agentDir ?? process.cwd();
211974
- const inputSchema = await loadOptionalWorkspaceSchema(agentDir, "input-schema.json", errors);
211975
- const outputSchema = await loadOptionalWorkspaceSchema(agentDir, "output-schema.json", errors);
212245
+ const compiled = existsSync8(path8.join(agentDir, "agent.ts")) ? await compileLocalAgent(agentDir, opts.config) : null;
212246
+ const inputSchema = compiled ? compiled.definition.inputSchema ?? null : await loadOptionalWorkspaceSchema(agentDir, "input-schema.json", errors);
212247
+ const outputSchema = compiled ? compiled.definition.outputSchema ?? null : await loadOptionalWorkspaceSchema(agentDir, "output-schema.json", errors);
211976
212248
  if (errors.length > 0)
211977
212249
  return { valid: false, errors };
211978
212250
  const examples = (await fs2.readdir(examplesDir, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
@@ -211980,7 +212252,7 @@ async function validateDatasetDir(dir, opts = {}) {
211980
212252
  return { valid: false, errors: ["examples/: dataset contains no examples"] };
211981
212253
  }
211982
212254
  for (const example of examples) {
211983
- errors.push(...await validateDatasetExample(path7.join(examplesDir, example), example, {
212255
+ errors.push(...await validateDatasetExample(path8.join(examplesDir, example), example, {
211984
212256
  inputSchema,
211985
212257
  outputSchema
211986
212258
  }));
@@ -211995,8 +212267,8 @@ async function validateDatasetExample(exampleRoot, example, schemas) {
211995
212267
  `${label}: example folder name must be lowercase kebab/snake-case (matching ${DATASET_NAME_PATTERN})`
211996
212268
  ];
211997
212269
  }
211998
- const inputFiles = await listFilesUnder(path7.join(exampleRoot, "input"));
211999
- const expectedFiles = await listFilesUnder(path7.join(exampleRoot, "expected"));
212270
+ const inputFiles = await listFilesUnder(path8.join(exampleRoot, "input"));
212271
+ const expectedFiles = await listFilesUnder(path8.join(exampleRoot, "expected"));
212000
212272
  if (inputFiles.delete("arguments.json")) {
212001
212273
  errors.push(`${label}/input/arguments.json: legacy workflow archive path is no longer accepted; use input.json at the example root`);
212002
212274
  }
@@ -212005,8 +212277,8 @@ async function validateDatasetExample(exampleRoot, example, schemas) {
212005
212277
  errors.push(`${label}/expected/${legacy}: legacy workflow archive path is no longer accepted; use expected.json at the example root`);
212006
212278
  }
212007
212279
  }
212008
- const inputJsonPath = path7.join(exampleRoot, AGENT_EXAMPLE_INPUT_JSON);
212009
- if (!existsSync7(inputJsonPath)) {
212280
+ const inputJsonPath = path8.join(exampleRoot, AGENT_EXAMPLE_INPUT_JSON);
212281
+ if (!existsSync8(inputJsonPath)) {
212010
212282
  errors.push(`${label}/input.json: input.json is required`);
212011
212283
  return errors;
212012
212284
  }
@@ -212024,9 +212296,9 @@ async function validateDatasetExample(exampleRoot, example, schemas) {
212024
212296
  fieldPrefix: `${label}/input.json`,
212025
212297
  exampleLabel: label
212026
212298
  }));
212027
- const expectedJsonPath = path7.join(exampleRoot, AGENT_EXAMPLE_EXPECTED_JSON);
212299
+ const expectedJsonPath = path8.join(exampleRoot, AGENT_EXAMPLE_EXPECTED_JSON);
212028
212300
  let expectedOutput = null;
212029
- if (existsSync7(expectedJsonPath)) {
212301
+ if (existsSync8(expectedJsonPath)) {
212030
212302
  const expected = await readJson(expectedJsonPath, `${label}/expected.json`, errors);
212031
212303
  if (expected !== undefined) {
212032
212304
  if (isExpectedErrorRef(expected)) {
@@ -212049,8 +212321,8 @@ async function validateDatasetExample(exampleRoot, example, schemas) {
212049
212321
  errors.push(`${label}/expected/${file}: file is not referenced from expected.json (expected/ files require an expected.json with { "$file": "expected/${file}" })`);
212050
212322
  }
212051
212323
  }
212052
- const metaJsonPath = path7.join(exampleRoot, "meta.json");
212053
- if (existsSync7(metaJsonPath)) {
212324
+ const metaJsonPath = path8.join(exampleRoot, "meta.json");
212325
+ if (existsSync8(metaJsonPath)) {
212054
212326
  const meta = await readJson(metaJsonPath, `${label}/meta.json`, errors);
212055
212327
  if (meta !== undefined) {
212056
212328
  const parsed = DatasetMetaSchema.safeParse(meta);
@@ -212106,7 +212378,7 @@ function validateFileRefs(args) {
212106
212378
  }
212107
212379
  async function listFilesUnder(dir) {
212108
212380
  const out = new Set;
212109
- if (!existsSync7(dir))
212381
+ if (!existsSync8(dir))
212110
212382
  return out;
212111
212383
  async function walk(current, relPrefix) {
212112
212384
  for (const entry of await fs2.readdir(current, { withFileTypes: true })) {
@@ -212114,7 +212386,7 @@ async function listFilesUnder(dir) {
212114
212386
  continue;
212115
212387
  const relative = relPrefix ? `${relPrefix}/${entry.name}` : entry.name;
212116
212388
  if (entry.isDirectory())
212117
- await walk(path7.join(current, entry.name), relative);
212389
+ await walk(path8.join(current, entry.name), relative);
212118
212390
  else if (entry.isFile())
212119
212391
  out.add(relative);
212120
212392
  }
@@ -212140,11 +212412,11 @@ function isExpectedErrorRef(value) {
212140
212412
  return isJsonObject(value) && Object.keys(value).length === 1 && Object.prototype.hasOwnProperty.call(value, "$error");
212141
212413
  }
212142
212414
  async function loadOptionalWorkspaceSchema(agentDir, filename, errors) {
212143
- const schemaPath = path7.join(agentDir, filename);
212144
- if (!existsSync7(schemaPath))
212415
+ const schemaPath = path8.join(agentDir, filename);
212416
+ if (!existsSync8(schemaPath))
212145
212417
  return null;
212146
212418
  const raw = await fs2.readFile(schemaPath, "utf8");
212147
- const validation = validateWorkspaceSchema(raw, filename);
212419
+ const validation = validateAgentSchema(raw, filename);
212148
212420
  for (const issue of validation.errors)
212149
212421
  errors.push(`${filename}: ${issue}`);
212150
212422
  if (!validation.valid)
@@ -212287,11 +212559,11 @@ async function pushDataset(agentId, opts) {
212287
212559
  cancelledMessage: "Dataset replace aborted"
212288
212560
  });
212289
212561
  }
212290
- const resolved = path8.resolve(opts.file);
212562
+ const resolved = path9.resolve(opts.file);
212291
212563
  const stat = await fs3.stat(resolved);
212292
212564
  const archive = stat.isDirectory() ? await readDirAsZip(resolved) : new Uint8Array(await fs3.readFile(resolved));
212293
212565
  const form = new FormData;
212294
- form.set("file", new Blob([archive], { type: "application/zip" }), stat.isDirectory() ? "dataset.zip" : path8.basename(resolved));
212566
+ form.set("file", new Blob([archive], { type: "application/zip" }), stat.isDirectory() ? "dataset.zip" : path9.basename(resolved));
212295
212567
  form.set("mode", opts.mode);
212296
212568
  const client = buildClient2(opts);
212297
212569
  const payload = await client.postFormData(`/v1/automations/${encodeURIComponent(agentAutomationId(agentId))}/dataset/import`, form);
@@ -212303,14 +212575,15 @@ async function pullDataset(agentId, opts) {
212303
212575
  const client = buildClient2(opts);
212304
212576
  const res = await client.getStream(`/v1/automations/${encodeURIComponent(agentAutomationId(agentId))}/dataset/export`);
212305
212577
  const archive = Buffer.from(await res.arrayBuffer());
212306
- const out = path8.resolve(opts.out ?? DATASET_DIR);
212307
- await fs3.mkdir(path8.dirname(out), { recursive: true });
212578
+ const out = path9.resolve(opts.out ?? DATASET_DIR);
212579
+ await fs3.mkdir(path9.dirname(out), { recursive: true });
212308
212580
  await fs3.writeFile(out.endsWith(".zip") ? out : `${out}.zip`, archive);
212309
212581
  success(`Pulled dataset to ${ui.bold(out.endsWith(".zip") ? out : `${out}.zip`)}`);
212310
212582
  }
212311
212583
  async function validateDatasetCommand(dir = DATASET_DIR, opts) {
212312
- const result = await validateDatasetDir(path8.resolve(dir), {
212313
- agentDir: path8.resolve(opts.agentDir ?? ".")
212584
+ const result = await validateDatasetDir(path9.resolve(dir), {
212585
+ agentDir: path9.resolve(opts.agentDir ?? "."),
212586
+ config: resolveConfig(opts)
212314
212587
  });
212315
212588
  if (opts.json)
212316
212589
  return printJson2(result);
@@ -212321,14 +212594,14 @@ async function validateDatasetCommand(dir = DATASET_DIR, opts) {
212321
212594
  process.exit(1);
212322
212595
  }
212323
212596
  async function readDirAsZip(dir) {
212324
- if (!existsSync8(dir))
212597
+ if (!existsSync9(dir))
212325
212598
  throw new Error(`directory does not exist: ${dir}`);
212326
212599
  const files = {};
212327
212600
  async function walk(current, relPrefix) {
212328
212601
  for (const entry of await fs3.readdir(current, { withFileTypes: true })) {
212329
212602
  if (entry.name.startsWith(".") || entry.name === "node_modules")
212330
212603
  continue;
212331
- const absolute = path8.join(current, entry.name);
212604
+ const absolute = path9.join(current, entry.name);
212332
212605
  const relative = relPrefix ? `${relPrefix}/${entry.name}` : entry.name;
212333
212606
  if (entry.isDirectory())
212334
212607
  await walk(absolute, relative);
@@ -212344,8 +212617,8 @@ async function readDirAsZip(dir) {
212344
212617
 
212345
212618
  // src/commands/agents/env.ts
212346
212619
  init_src();
212347
- import { existsSync as existsSync9, promises as fs4, readFileSync as readFileSync7 } from "node:fs";
212348
- import path9 from "node:path";
212620
+ import { existsSync as existsSync10, promises as fs4, readFileSync as readFileSync8 } from "node:fs";
212621
+ import path10 from "node:path";
212349
212622
 
212350
212623
  // src/commands/agents/target.ts
212351
212624
  init_src();
@@ -212386,7 +212659,7 @@ async function pullAgentEnv(target, opts) {
212386
212659
  throw new Error("--format must be shell or dotenv");
212387
212660
  }
212388
212661
  const client = buildClient2(opts);
212389
- const requests = target ? await collectEncryptedSecretsForTarget(client, target) : await collectEncryptedSecrets(path9.resolve(opts.dir ?? "."));
212662
+ const requests = target ? await collectEncryptedSecretsForTarget(client, target) : await collectEncryptedSecrets(path10.resolve(opts.dir ?? "."));
212390
212663
  if (requests.length === 0)
212391
212664
  return;
212392
212665
  const payload = await client.post("/v1/source/secrets/decrypt", {
@@ -212449,12 +212722,12 @@ async function readOptionalSourceFile(client, query) {
212449
212722
  }
212450
212723
  }
212451
212724
  async function collectEncryptedSecrets(root) {
212452
- const roots = [root, ...await listModulePackageRoots(path9.join(root, "eigenpal_modules"))];
212725
+ const roots = [root, ...await listModulePackageRoots(path10.join(root, "eigenpal_modules"))];
212453
212726
  const seen = new Set;
212454
212727
  const requests = [];
212455
212728
  for (const packageRoot of roots) {
212456
- const secretsPath = path9.join(packageRoot, SOURCE_SECRETS_FILENAME);
212457
- if (!existsSync9(secretsPath))
212729
+ const secretsPath = path10.join(packageRoot, SOURCE_SECRETS_FILENAME);
212730
+ if (!existsSync10(secretsPath))
212458
212731
  continue;
212459
212732
  const parsed = SourceSecretsFileSchema.parse(exports_dist.parse(await fs4.readFile(secretsPath, "utf8")));
212460
212733
  const sourcePath = sourcePathForInstalledPackage(root, packageRoot);
@@ -212476,16 +212749,16 @@ async function collectEncryptedSecrets(root) {
212476
212749
  return requests;
212477
212750
  }
212478
212751
  async function listModulePackageRoots(modulesRoot) {
212479
- if (!existsSync9(modulesRoot))
212752
+ if (!existsSync10(modulesRoot))
212480
212753
  return [];
212481
212754
  const result = [];
212482
212755
  for (const type of await fs4.readdir(modulesRoot)) {
212483
- const typeRoot = path9.join(modulesRoot, type);
212756
+ const typeRoot = path10.join(modulesRoot, type);
212484
212757
  const typeStat = await fs4.stat(typeRoot).catch(() => null);
212485
212758
  if (!typeStat?.isDirectory())
212486
212759
  continue;
212487
212760
  for (const slug of await fs4.readdir(typeRoot)) {
212488
- const packageRoot = path9.join(typeRoot, slug);
212761
+ const packageRoot = path10.join(typeRoot, slug);
212489
212762
  const packageStat = await fs4.stat(packageRoot).catch(() => null);
212490
212763
  if (packageStat?.isDirectory())
212491
212764
  result.push(packageRoot);
@@ -212494,16 +212767,16 @@ async function listModulePackageRoots(modulesRoot) {
212494
212767
  return result;
212495
212768
  }
212496
212769
  function sourcePathForInstalledPackage(root, packageRoot) {
212497
- const sourceRelative = path9.relative(root, packageRoot).replace(/\\/g, "/");
212770
+ const sourceRelative = path10.relative(root, packageRoot).replace(/\\/g, "/");
212498
212771
  if (!sourceRelative.startsWith("..") && SourcePackagePathSchema.safeParse(sourceRelative).success) {
212499
212772
  return sourceRelative;
212500
212773
  }
212501
- const relative = path9.relative(path9.join(root, "eigenpal_modules"), packageRoot).replace(/\\/g, "/");
212774
+ const relative = path10.relative(path10.join(root, "eigenpal_modules"), packageRoot).replace(/\\/g, "/");
212502
212775
  if (!relative.startsWith(".."))
212503
212776
  return relative;
212504
- const lockfilePath = path9.join(root, ".eigenpal", "eigenpal.lock");
212505
- if (packageRoot === root && existsSync9(lockfilePath)) {
212506
- const lockfile = JSON.parse(readFileSync7(lockfilePath, "utf8"));
212777
+ const lockfilePath = path10.join(root, ".eigenpal", "eigenpal.lock");
212778
+ if (packageRoot === root && existsSync10(lockfilePath)) {
212779
+ const lockfile = JSON.parse(readFileSync8(lockfilePath, "utf8"));
212507
212780
  if (typeof lockfile.root?.packagePath === "string")
212508
212781
  return lockfile.root.packagePath;
212509
212782
  }
@@ -213360,7 +213633,7 @@ async function cancelExperiment(agentId, batchId, opts) {
213360
213633
  // src/commands/agents/files.ts
213361
213634
  import { createHash as createHash2 } from "node:crypto";
213362
213635
  import { promises as fs6 } from "node:fs";
213363
- import path10 from "node:path";
213636
+ import path11 from "node:path";
213364
213637
  function registerAgentFileCommands(agent) {
213365
213638
  const file = agent.command("file").description("List, download, and compare individual live agent files.").action(() => {
213366
213639
  process.stderr.write("`eigenpal agents file` requires a subcommand. Run `eigenpal agents file --help`.\n");
@@ -213389,12 +213662,12 @@ async function getAgentFile(agentId, remotePath, opts) {
213389
213662
  const payload = await readAgentFile(client, agentId, remotePath);
213390
213663
  if (opts.json)
213391
213664
  return printJson2(payload);
213392
- const out = path10.resolve(opts.out ?? payload.path);
213665
+ const out = path11.resolve(opts.out ?? payload.path);
213393
213666
  await writeBase64File(out, payload.contentBase64);
213394
213667
  success(`Downloaded ${payload.path} to ${ui.bold(out)}`);
213395
213668
  }
213396
213669
  async function diffAgentFile(agentId, remotePath, localPath, opts) {
213397
- const report = await buildAgentFileDiff(agentId, remotePath, path10.resolve(localPath), opts);
213670
+ const report = await buildAgentFileDiff(agentId, remotePath, path11.resolve(localPath), opts);
213398
213671
  if (opts.json)
213399
213672
  return printJson2(report);
213400
213673
  renderAgentFileDiff(report);
@@ -213544,7 +213817,7 @@ async function stopSession(sessionId, opts) {
213544
213817
  init_src();
213545
213818
  import { spawnSync as spawnSync4 } from "node:child_process";
213546
213819
  import { createHash as createHash4 } from "node:crypto";
213547
- import { promises as fs15, readFileSync as readFileSync12 } from "node:fs";
213820
+ import { promises as fs15, readFileSync as readFileSync13 } from "node:fs";
213548
213821
  import path15 from "node:path";
213549
213822
 
213550
213823
  // src/lib/resolve-workflow.ts
@@ -214523,7 +214796,7 @@ function assertXlsxTemplateWorkload(buffer, data, limits = xlsxTemplateRenderLim
214523
214796
  }
214524
214797
 
214525
214798
  // ../common/src/xlsx-template.js
214526
- var path11 = __require("path");
214799
+ var path12 = __require("path");
214527
214800
  var imageSize2 = (init_dist5(), __toCommonJS(exports_dist2)).imageSize;
214528
214801
  var fs7 = __require("fs");
214529
214802
  var etree = require_elementtree();
@@ -214665,17 +214938,17 @@ class Workbook {
214665
214938
  "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"
214666
214939
  ];
214667
214940
  if (needsFileCopy.indexOf(relType) !== -1) {
214668
- var sheetDirectory = path11.dirname(sheet.filename);
214669
- var sourceFilePath = path11.join(sheetDirectory, target).replace(/\\/g, "/");
214941
+ var sheetDirectory = path12.dirname(sheet.filename);
214942
+ var sourceFilePath = path12.join(sheetDirectory, target).replace(/\\/g, "/");
214670
214943
  var sourceFile = self2.archive.file(sourceFilePath);
214671
214944
  if (sourceFile) {
214672
- var fileExtension = path11.extname(target);
214673
- var fileBaseName = path11.basename(target, fileExtension);
214674
- var fileDir = path11.dirname(target);
214945
+ var fileExtension = path12.extname(target);
214946
+ var fileBaseName = path12.basename(target, fileExtension);
214947
+ var fileDir = path12.dirname(target);
214675
214948
  var baseNameWithoutNumber = fileBaseName.replace(/\d+$/, "");
214676
214949
  var newFileName = baseNameWithoutNumber + newSheetIndex + fileExtension;
214677
- var newTarget = path11.join(fileDir, newFileName).replace(/\\/g, "/");
214678
- var newFilePath = path11.join(sheetDirectory, newTarget).replace(/\\/g, "/");
214950
+ var newTarget = path12.join(fileDir, newFileName).replace(/\\/g, "/");
214951
+ var newFilePath = path12.join(sheetDirectory, newTarget).replace(/\\/g, "/");
214679
214952
  var binaryContent = sourceFile.asBinary();
214680
214953
  if (relType === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") {
214681
214954
  binaryContent = binaryContent.replace(/data="\d+"/, 'data="' + newSheetIndex + '"');
@@ -214712,8 +214985,8 @@ class Workbook {
214712
214985
  var self2 = this;
214713
214986
  var order = ["worksheet", "theme", "styles", "sharedStrings"];
214714
214987
  self2.workbookRels.findall("*").sort(function(rel1, rel2) {
214715
- var index1 = order.indexOf(path11.basename(rel1.attrib.Type));
214716
- var index2 = order.indexOf(path11.basename(rel2.attrib.Type));
214988
+ var index1 = order.indexOf(path12.basename(rel1.attrib.Type));
214989
+ var index2 = order.indexOf(path12.basename(rel2.attrib.Type));
214717
214990
  if (index1 < 0 && index2 >= 0)
214718
214991
  return 1;
214719
214992
  if (index1 >= 0 && index2 < 0)
@@ -214733,7 +215006,7 @@ class Workbook {
214733
215006
  item.attrib["r:id"] = "rId" + (index + 1);
214734
215007
  item.attrib.sheetId = (index + 1).toString();
214735
215008
  });
214736
- self2.archive.file(self2.prefix + "/" + "_rels" + "/" + path11.basename(self2.workbookPath) + ".rels", etree.tostring(self2.workbookRels));
215009
+ self2.archive.file(self2.prefix + "/" + "_rels" + "/" + path12.basename(self2.workbookPath) + ".rels", etree.tostring(self2.workbookRels));
214737
215010
  self2.archive.file(self2.workbookPath, etree.tostring(self2.workbook));
214738
215011
  self2.sheets = self2.loadSheets(self2.prefix, self2.workbook, self2.workbookRels);
214739
215012
  }
@@ -214745,9 +215018,9 @@ class Workbook {
214745
215018
  self2.archive = new zip(data, { base64: false, checkCRC32: true });
214746
215019
  var rels = etree.parse(self2.archive.file("_rels/.rels").asText()).getroot(), workbookPath = rels.find("Relationship[@Type='" + DOCUMENT_RELATIONSHIP + "']").attrib.Target;
214747
215020
  self2.workbookPath = workbookPath;
214748
- self2.prefix = path11.dirname(workbookPath);
215021
+ self2.prefix = path12.dirname(workbookPath);
214749
215022
  self2.workbook = etree.parse(self2.archive.file(workbookPath).asText()).getroot();
214750
- self2.workbookRels = etree.parse(self2.archive.file(self2.prefix + "/" + "_rels" + "/" + path11.basename(workbookPath) + ".rels").asText()).getroot();
215023
+ self2.workbookRels = etree.parse(self2.archive.file(self2.prefix + "/" + "_rels" + "/" + path12.basename(workbookPath) + ".rels").asText()).getroot();
214751
215024
  self2.sheets = self2.loadSheets(self2.prefix, self2.workbook, self2.workbookRels);
214752
215025
  self2.calChainRel = self2.workbookRels.find("Relationship[@Type='" + CALC_CHAIN_RELATIONSHIP + "']");
214753
215026
  if (self2.calChainRel) {
@@ -215027,7 +215300,7 @@ class Workbook {
215027
215300
  }
215028
215301
  loadSheetRels(sheetFilename) {
215029
215302
  var self2 = this;
215030
- var sheetDirectory = path11.dirname(sheetFilename), sheetName = path11.basename(sheetFilename), relsFilename = path11.join(sheetDirectory, "_rels", sheetName + ".rels").replace(/\\/g, "/"), relsFile = self2.archive.file(relsFilename);
215303
+ var sheetDirectory = path12.dirname(sheetFilename), sheetName = path12.basename(sheetFilename), relsFilename = path12.join(sheetDirectory, "_rels", sheetName + ".rels").replace(/\\/g, "/"), relsFile = self2.archive.file(relsFilename);
215031
215304
  if (relsFile === null) {
215032
215305
  return self2.initSheetRels(sheetFilename);
215033
215306
  }
@@ -215035,7 +215308,7 @@ class Workbook {
215035
215308
  return rels;
215036
215309
  }
215037
215310
  initSheetRels(sheetFilename) {
215038
- var sheetDirectory = path11.dirname(sheetFilename), sheetName = path11.basename(sheetFilename), relsFilename = path11.join(sheetDirectory, "_rels", sheetName + ".rels").replace(/\\/g, "/");
215311
+ var sheetDirectory = path12.dirname(sheetFilename), sheetName = path12.basename(sheetFilename), relsFilename = path12.join(sheetDirectory, "_rels", sheetName + ".rels").replace(/\\/g, "/");
215039
215312
  var element = etree.Element;
215040
215313
  var ElementTree = etree.ElementTree;
215041
215314
  var root = element("Relationships");
@@ -215046,16 +215319,16 @@ class Workbook {
215046
215319
  }
215047
215320
  loadDrawing(sheet, sheetFilename, rels) {
215048
215321
  var self2 = this;
215049
- var sheetDirectory = path11.dirname(sheetFilename), sheetName = path11.basename(sheetFilename), drawing = { filename: "", root: null };
215322
+ var sheetDirectory = path12.dirname(sheetFilename), sheetName = path12.basename(sheetFilename), drawing = { filename: "", root: null };
215050
215323
  var drawingPart = sheet.find("drawing");
215051
215324
  if (drawingPart === null) {
215052
215325
  drawing = self2.initDrawing(sheet, rels);
215053
215326
  return drawing;
215054
215327
  }
215055
- var relationshipId = drawingPart.attrib["r:id"], target = rels.find("Relationship[@Id='" + relationshipId + "']").attrib.Target, drawingFilename = path11.join(sheetDirectory, target).replace(/\\/g, "/"), drawingTree = etree.parse(self2.archive.file(drawingFilename).asText());
215328
+ var relationshipId = drawingPart.attrib["r:id"], target = rels.find("Relationship[@Id='" + relationshipId + "']").attrib.Target, drawingFilename = path12.join(sheetDirectory, target).replace(/\\/g, "/"), drawingTree = etree.parse(self2.archive.file(drawingFilename).asText());
215056
215329
  drawing.filename = drawingFilename;
215057
215330
  drawing.root = drawingTree.getroot();
215058
- drawing.relFilename = path11.dirname(drawingFilename) + "/_rels/" + path11.basename(drawingFilename) + ".rels";
215331
+ drawing.relFilename = path12.dirname(drawingFilename) + "/_rels/" + path12.basename(drawingFilename) + ".rels";
215059
215332
  var relFile = self2.archive.file(drawing.relFilename);
215060
215333
  if (relFile === null) {
215061
215334
  drawing.relRoot = etree.Element("Relationships");
@@ -215127,7 +215400,7 @@ class Workbook {
215127
215400
  }
215128
215401
  loadTables(sheet, sheetFilename) {
215129
215402
  var self2 = this;
215130
- var sheetDirectory = path11.dirname(sheetFilename), sheetName = path11.basename(sheetFilename), relsFilename = sheetDirectory + "/" + "_rels" + "/" + sheetName + ".rels", relsFile = self2.archive.file(relsFilename), tables = [];
215403
+ var sheetDirectory = path12.dirname(sheetFilename), sheetName = path12.basename(sheetFilename), relsFilename = sheetDirectory + "/" + "_rels" + "/" + sheetName + ".rels", relsFile = self2.archive.file(relsFilename), tables = [];
215131
215404
  if (relsFile === null) {
215132
215405
  return tables;
215133
215406
  }
@@ -216431,7 +216704,7 @@ function extractErrorMessage(error) {
216431
216704
  }
216432
216705
  // src/lib/xlsx-workbook.ts
216433
216706
  import { createHash as createHash3 } from "node:crypto";
216434
- import { readFileSync as readFileSync8 } from "node:fs";
216707
+ import { readFileSync as readFileSync9 } from "node:fs";
216435
216708
 
216436
216709
  // ../../node_modules/xlsx/xlsx.mjs
216437
216710
  /*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
@@ -241279,7 +241552,7 @@ function parseSheetSelectionList(raw) {
241279
241552
  }
241280
241553
  function extractXlsxComparableText(filePath) {
241281
241554
  try {
241282
- const buffer = readFileSync8(filePath);
241555
+ const buffer = readFileSync9(filePath);
241283
241556
  const result = computeXlsxWorkbookComparisonDigest(buffer);
241284
241557
  if (result.status === "ok") {
241285
241558
  return { text: result.digest };
@@ -241298,18 +241571,18 @@ function extractXlsxComparableText(filePath) {
241298
241571
  }
241299
241572
 
241300
241573
  // src/lib/execution-artifacts.ts
241301
- import { existsSync as existsSync10, mkdirSync as mkdirSync4, readdirSync as readdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "fs";
241574
+ import { existsSync as existsSync11, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync11, writeFileSync as writeFileSync6 } from "fs";
241302
241575
  import { join as join5 } from "path";
241303
241576
 
241304
241577
  // src/lib/format.ts
241305
- import { readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "fs";
241578
+ import { readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
241306
241579
  import { extname as extname2, resolve as resolve3 } from "path";
241307
241580
  var PRETTIER_EXTENSIONS = new Set([".json", ".yaml", ".yml"]);
241308
241581
  async function formatFileIfAvailable(filepath) {
241309
241582
  if (!PRETTIER_EXTENSIONS.has(extname2(filepath)))
241310
241583
  return;
241311
241584
  try {
241312
- const content = readFileSync9(filepath, "utf-8");
241585
+ const content = readFileSync10(filepath, "utf-8");
241313
241586
  const prettier = await Promise.resolve().then(() => (init_prettier(), {}));
241314
241587
  const formatted = await format2(content, {
241315
241588
  filepath: resolve3(filepath)
@@ -241482,7 +241755,7 @@ function gradeAgainstExpected(expected, actual) {
241482
241755
  }
241483
241756
 
241484
241757
  // src/lib/payload.ts
241485
- import { existsSync as existsSync11, readdirSync as readdirSync3, readFileSync as readFileSync11, statSync as statSync3 } from "fs";
241758
+ import { existsSync as existsSync12, readdirSync as readdirSync4, readFileSync as readFileSync12, statSync as statSync3 } from "fs";
241486
241759
  import { join as join7 } from "path";
241487
241760
 
241488
241761
  // src/lib/fs-helpers.ts
@@ -241497,7 +241770,7 @@ var DATASET_EXAMPLES_DIR = ["dataset", "examples"];
241497
241770
  function resolveEvalBaseDir(dir) {
241498
241771
  const candidates = [join7(dir, ...DATASET_EXAMPLES_DIR), join7(...DATASET_EXAMPLES_DIR)];
241499
241772
  for (const candidate of candidates) {
241500
- if (existsSync11(candidate))
241773
+ if (existsSync12(candidate))
241501
241774
  return candidate;
241502
241775
  }
241503
241776
  return null;
@@ -243057,7 +243330,7 @@ async function downloadStreamToFile(client, url, target) {
243057
243330
  function extractComparableText(file) {
243058
243331
  const ext = path15.extname(file).toLowerCase();
243059
243332
  if ([".txt", ".md", ".json", ".csv", ".xml"].includes(ext)) {
243060
- return { text: readFileSync12(file, "utf8") };
243333
+ return { text: readFileSync13(file, "utf8") };
243061
243334
  }
243062
243335
  if (ext === ".xlsx" || ext === ".xls") {
243063
243336
  return extractXlsxComparableText(file);
@@ -243183,8 +243456,8 @@ async function validateAgentCommand(dir = ".", opts) {
243183
243456
  const root = path16.resolve(dir);
243184
243457
  const legacy = await validateAgentProject(root);
243185
243458
  const result = { ...legacy };
243186
- if (existsSync12(path16.join(root, PACKAGE_MANIFEST))) {
243187
- const source = validateSourcePackage(root);
243459
+ if (existsSync13(path16.join(root, "agent.ts")) || existsSync13(path16.join(root, PACKAGE_MANIFEST))) {
243460
+ const source = await validateSourcePackage(root, resolveConfig(opts));
243188
243461
  result.valid = legacy.valid && source.valid;
243189
243462
  result.packagePath = source.packagePath;
243190
243463
  for (const issue of source.errors) {
@@ -243722,7 +243995,7 @@ async function completion(shell, program) {
243722
243995
  }
243723
243996
 
243724
243997
  // src/commands/docs.ts
243725
- import { existsSync as existsSync13, readFileSync as readFileSync13 } from "node:fs";
243998
+ import { existsSync as existsSync14, readFileSync as readFileSync14 } from "node:fs";
243726
243999
  var docsCache = null;
243727
244000
  function bundledDocs() {
243728
244001
  if (docsCache)
@@ -243731,11 +244004,11 @@ function bundledDocs() {
243731
244004
  new URL("./docs-bundle.json", import.meta.url),
243732
244005
  new URL("../docs-bundle.json", import.meta.url)
243733
244006
  ];
243734
- const bundleUrl = candidates.find((candidate) => existsSync13(candidate));
244007
+ const bundleUrl = candidates.find((candidate) => existsSync14(candidate));
243735
244008
  if (!bundleUrl) {
243736
244009
  throw new Error("Bundled documentation asset is missing. Reinstall the Eigenpal CLI.");
243737
244010
  }
243738
- const parsed = JSON.parse(readFileSync13(bundleUrl, "utf8"));
244011
+ const parsed = JSON.parse(readFileSync14(bundleUrl, "utf8"));
243739
244012
  if (!Array.isArray(parsed.entries)) {
243740
244013
  throw new Error("Bundled documentation asset is invalid. Reinstall the Eigenpal CLI.");
243741
244014
  }
@@ -243856,7 +244129,7 @@ function matchingSnippet(content, terms) {
243856
244129
 
243857
244130
  // src/lib/email-servers-cli.ts
243858
244131
  init_src();
243859
- import { existsSync as existsSync14, readFileSync as readFileSync14 } from "node:fs";
244132
+ import { existsSync as existsSync15, readFileSync as readFileSync15 } from "node:fs";
243860
244133
  import { resolve as resolve4 } from "node:path";
243861
244134
  var SECRET_KEYS = new Set(["apiKey", "password", "caPem", "ciphertext"]);
243862
244135
  var SMTP_UPDATE_TARGET_FIELDS = ["host", "port", "security", "fromEmail", "fromName"];
@@ -243908,7 +244181,7 @@ function readConfigObject(opts) {
243908
244181
  const filePath = opts.configFile === "-" ? undefined : resolve4(opts.configFile);
243909
244182
  let raw;
243910
244183
  try {
243911
- raw = opts.configFile === "-" ? readFileSync14(0, "utf8") : readFileSync14(filePath, "utf8");
244184
+ raw = opts.configFile === "-" ? readFileSync15(0, "utf8") : readFileSync15(filePath, "utf8");
243912
244185
  } catch (err) {
243913
244186
  const code = err && typeof err === "object" && "code" in err ? String(err.code) : "";
243914
244187
  if (code === "ENOENT") {
@@ -243942,12 +244215,12 @@ async function readSecretInput2(label, opts, required) {
243942
244215
  throw new Error(`Pass only one of --${label}-stdin or --${label}-file.`);
243943
244216
  }
243944
244217
  if (opts.stdin) {
243945
- return readFileSync14(0, "utf8").replace(/\n$/, "");
244218
+ return readFileSync15(0, "utf8").replace(/\n$/, "");
243946
244219
  }
243947
244220
  if (opts.file) {
243948
244221
  const filePath = opts.file === "-" ? undefined : resolve4(opts.file);
243949
244222
  try {
243950
- return (opts.file === "-" ? readFileSync14(0, "utf8") : readFileSync14(filePath, "utf8")).replace(/\n$/, "");
244223
+ return (opts.file === "-" ? readFileSync15(0, "utf8") : readFileSync15(filePath, "utf8")).replace(/\n$/, "");
243951
244224
  } catch (err) {
243952
244225
  const code = err && typeof err === "object" && "code" in err ? String(err.code) : "";
243953
244226
  if (code === "ENOENT") {
@@ -244299,10 +244572,10 @@ function registerEmailServersCommands(program) {
244299
244572
  init_dist4();
244300
244573
  import {
244301
244574
  copyFileSync,
244302
- existsSync as existsSync15,
244575
+ existsSync as existsSync16,
244303
244576
  mkdirSync as mkdirSync5,
244304
- readdirSync as readdirSync4,
244305
- readFileSync as readFileSync15,
244577
+ readdirSync as readdirSync5,
244578
+ readFileSync as readFileSync16,
244306
244579
  statSync as statSync4,
244307
244580
  writeFileSync as writeFileSync7
244308
244581
  } from "node:fs";
@@ -244328,10 +244601,10 @@ function isValidProjectName(name) {
244328
244601
  function resolveTemplatesRoot() {
244329
244602
  const here = dirname5(fileURLToPath6(import.meta.url));
244330
244603
  const srcCandidate = resolve5(here, "..", "..", "templates");
244331
- if (existsSync15(srcCandidate))
244604
+ if (existsSync16(srcCandidate))
244332
244605
  return srcCandidate;
244333
244606
  const distCandidate = resolve5(here, "templates");
244334
- if (existsSync15(distCandidate))
244607
+ if (existsSync16(distCandidate))
244335
244608
  return distCandidate;
244336
244609
  throw new Error(`Cannot locate bundled templates. Looked in:
244337
244610
  ${srcCandidate}
@@ -244343,7 +244616,7 @@ async function init(name, opts) {
244343
244616
  }
244344
244617
  const target = resolve5(process.cwd(), opts.dir ?? name);
244345
244618
  assertSafeTargetDir(target, opts.dir);
244346
- if (existsSync15(target) && readdirSync4(target).length > 0) {
244619
+ if (existsSync16(target) && readdirSync5(target).length > 0) {
244347
244620
  throw new Error(`Target directory ${relative3(process.cwd(), target)} exists and is not empty.`);
244348
244621
  }
244349
244622
  let template;
@@ -244358,7 +244631,7 @@ async function init(name, opts) {
244358
244631
  template = await promptForTemplate();
244359
244632
  }
244360
244633
  const sourceRoot = join8(resolveTemplatesRoot(), template);
244361
- if (!existsSync15(sourceRoot)) {
244634
+ if (!existsSync16(sourceRoot)) {
244362
244635
  throw new Error(`Template directory missing on disk: ${sourceRoot}`);
244363
244636
  }
244364
244637
  const written = copyTemplate(sourceRoot, target, name);
@@ -244400,7 +244673,7 @@ function copyTemplate(src, dst, projectName) {
244400
244673
  const stack = [src];
244401
244674
  while (stack.length > 0) {
244402
244675
  const dir = stack.pop();
244403
- for (const entry of readdirSync4(dir)) {
244676
+ for (const entry of readdirSync5(dir)) {
244404
244677
  const sourcePath = join8(dir, entry);
244405
244678
  const relativePath = relative3(src, sourcePath);
244406
244679
  const targetPath = join8(dst, relativePath);
@@ -244411,7 +244684,7 @@ function copyTemplate(src, dst, projectName) {
244411
244684
  }
244412
244685
  mkdirSync5(dirname5(targetPath), { recursive: true });
244413
244686
  if (isTextFile(sourcePath)) {
244414
- const text = readFileSync15(sourcePath, "utf-8").replaceAll(PLACEHOLDER, projectName);
244687
+ const text = readFileSync16(sourcePath, "utf-8").replaceAll(PLACEHOLDER, projectName);
244415
244688
  writeFileSync7(targetPath, text);
244416
244689
  } else {
244417
244690
  copyFileSync(sourcePath, targetPath);
@@ -245401,7 +245674,7 @@ function parseInputFileSpecs(inputFile) {
245401
245674
 
245402
245675
  // src/lib/format-eigenpal.ts
245403
245676
  import { spawnSync as spawnSync5 } from "child_process";
245404
- import { existsSync as existsSync16, readFileSync as readFileSync16 } from "fs";
245677
+ import { existsSync as existsSync17, readFileSync as readFileSync17 } from "fs";
245405
245678
  import { join as join9, resolve as resolve6 } from "path";
245406
245679
  var PRETTRC_NAMES = [
245407
245680
  ".prettierrc",
@@ -245415,14 +245688,14 @@ var PRETTRC_NAMES = [
245415
245688
  ];
245416
245689
  function hasPrettierConfig(cwd) {
245417
245690
  for (const name of PRETTRC_NAMES) {
245418
- if (existsSync16(join9(cwd, name)))
245691
+ if (existsSync17(join9(cwd, name)))
245419
245692
  return true;
245420
245693
  }
245421
245694
  try {
245422
245695
  const pkgPath = join9(cwd, "package.json");
245423
- if (!existsSync16(pkgPath))
245696
+ if (!existsSync17(pkgPath))
245424
245697
  return false;
245425
- const raw = readFileSync16(pkgPath, "utf-8");
245698
+ const raw = readFileSync17(pkgPath, "utf-8");
245426
245699
  const pkg = JSON.parse(raw);
245427
245700
  return pkg != null && typeof pkg === "object" && "prettier" in pkg;
245428
245701
  } catch {
@@ -245432,7 +245705,7 @@ function hasPrettierConfig(cwd) {
245432
245705
  function formatEigenpalDirIfAvailable(dir) {
245433
245706
  const cwd = process.cwd();
245434
245707
  const absDir = resolve6(cwd, dir);
245435
- if (!existsSync16(absDir))
245708
+ if (!existsSync17(absDir))
245436
245709
  return;
245437
245710
  if (!hasPrettierConfig(cwd))
245438
245711
  return;
@@ -245566,11 +245839,11 @@ async function rerunTarget(runId, opts) {
245566
245839
  init_dist4();
245567
245840
  import { createHash as createHash5 } from "node:crypto";
245568
245841
  import {
245569
- existsSync as existsSync17,
245570
- lstatSync,
245842
+ existsSync as existsSync18,
245843
+ lstatSync as lstatSync2,
245571
245844
  mkdirSync as mkdirSync6,
245572
- readFileSync as readFileSync17,
245573
- readdirSync as readdirSync5,
245845
+ readFileSync as readFileSync18,
245846
+ readdirSync as readdirSync6,
245574
245847
  rmSync as rmSync2,
245575
245848
  rmdirSync,
245576
245849
  unlinkSync as unlinkSync2,
@@ -245652,10 +245925,10 @@ var MANIFEST_NAME = ".eigenpal-manifest.json";
245652
245925
  function resolveSkillSource() {
245653
245926
  const here = dirname6(fileURLToPath7(import.meta.url));
245654
245927
  const srcCandidate = resolve7(here, "..", "..", "skill");
245655
- if (existsSync17(srcCandidate))
245928
+ if (existsSync18(srcCandidate))
245656
245929
  return srcCandidate;
245657
245930
  const distCandidate = resolve7(here, "skill");
245658
- if (existsSync17(distCandidate))
245931
+ if (existsSync18(distCandidate))
245659
245932
  return distCandidate;
245660
245933
  throw new Error(`Cannot locate bundled skill content. Looked in:
245661
245934
  ${srcCandidate}
@@ -245692,15 +245965,15 @@ async function installSkill(opts) {
245692
245965
  for (const relativePath of sourceFiles) {
245693
245966
  const sourcePath = join11(source, relativePath);
245694
245967
  const targetPath = join11(target, relativePath);
245695
- const sourceBytes = templateSourceFile(relativePath, readFileSync17(sourcePath), cliVersion);
245968
+ const sourceBytes = templateSourceFile(relativePath, readFileSync18(sourcePath), cliVersion);
245696
245969
  const sourceHash = sha256(sourceBytes);
245697
- if (!existsSync17(targetPath)) {
245970
+ if (!existsSync18(targetPath)) {
245698
245971
  mkdirSync6(dirname6(targetPath), { recursive: true });
245699
245972
  writeFileSync8(targetPath, sourceBytes);
245700
245973
  written += 1;
245701
245974
  continue;
245702
245975
  }
245703
- const targetBytes = readFileSync17(targetPath);
245976
+ const targetBytes = readFileSync18(targetPath);
245704
245977
  const targetHash = sha256(targetBytes);
245705
245978
  if (targetHash === sourceHash) {
245706
245979
  skipped += 1;
@@ -245732,9 +246005,9 @@ async function installSkill(opts) {
245732
246005
  const manifestEntries = [];
245733
246006
  for (const relativePath of sourceFiles) {
245734
246007
  const targetPath = join11(target, relativePath);
245735
- if (!existsSync17(targetPath))
246008
+ if (!existsSync18(targetPath))
245736
246009
  continue;
245737
- manifestEntries.push({ path: relativePath, sha256: sha256(readFileSync17(targetPath)) });
246010
+ manifestEntries.push({ path: relativePath, sha256: sha256(readFileSync18(targetPath)) });
245738
246011
  }
245739
246012
  const manifest = {
245740
246013
  cliVersion,
@@ -245775,9 +246048,9 @@ async function uninstallSkill(opts) {
245775
246048
  console.error(`Refusing to touch ${path}: manifest path escapes ${targetReal}`);
245776
246049
  continue;
245777
246050
  }
245778
- if (!existsSync17(path))
246051
+ if (!existsSync18(path))
245779
246052
  continue;
245780
- const currentHash = sha256(readFileSync17(path));
246053
+ const currentHash = sha256(readFileSync18(path));
245781
246054
  if (currentHash !== entry.sha256 && !opts.yes) {
245782
246055
  kept += 1;
245783
246056
  continue;
@@ -245978,20 +246251,20 @@ function hintFor(tool, installed, detected) {
245978
246251
  return tool.relativePath;
245979
246252
  }
245980
246253
  function isInstalled(cwd, tool) {
245981
- return existsSync17(join11(cwd, tool.relativePath, MANIFEST_NAME));
246254
+ return existsSync18(join11(cwd, tool.relativePath, MANIFEST_NAME));
245982
246255
  }
245983
246256
  function isProjectUsing(cwd, tool) {
245984
- return tool.detectPaths.some((p) => existsSync17(join11(cwd, p)));
246257
+ return tool.detectPaths.some((p) => existsSync18(join11(cwd, p)));
245985
246258
  }
245986
246259
  function listFiles(root) {
245987
246260
  const out = [];
245988
246261
  const stack = [root];
245989
246262
  while (stack.length > 0) {
245990
246263
  const dir = stack.pop();
245991
- for (const entry of readdirSync5(dir)) {
246264
+ for (const entry of readdirSync6(dir)) {
245992
246265
  const full = join11(dir, entry);
245993
246266
  const rel = relative4(root, full);
245994
- const stats = lstatSync(full);
246267
+ const stats = lstatSync2(full);
245995
246268
  if (stats.isDirectory()) {
245996
246269
  stack.push(full);
245997
246270
  continue;
@@ -246005,10 +246278,10 @@ function listFiles(root) {
246005
246278
  }
246006
246279
  function readManifest(target) {
246007
246280
  const path = join11(target, MANIFEST_NAME);
246008
- if (!existsSync17(path))
246281
+ if (!existsSync18(path))
246009
246282
  return null;
246010
246283
  try {
246011
- return JSON.parse(readFileSync17(path, "utf-8"));
246284
+ return JSON.parse(readFileSync18(path, "utf-8"));
246012
246285
  } catch {
246013
246286
  return null;
246014
246287
  }
@@ -246022,8 +246295,8 @@ function readCliVersion() {
246022
246295
  resolve7(here, "..", "package.json")
246023
246296
  ];
246024
246297
  for (const candidate of candidates) {
246025
- if (existsSync17(candidate)) {
246026
- const pkg = JSON.parse(readFileSync17(candidate, "utf-8"));
246298
+ if (existsSync18(candidate)) {
246299
+ const pkg = JSON.parse(readFileSync18(candidate, "utf-8"));
246027
246300
  if (pkg.name && pkg.name !== "@eigenpal/cli")
246028
246301
  continue;
246029
246302
  if (pkg.version)
@@ -246034,13 +246307,13 @@ function readCliVersion() {
246034
246307
  return "unknown";
246035
246308
  }
246036
246309
  function pruneEmptyDirs(root) {
246037
- if (!existsSync17(root))
246310
+ if (!existsSync18(root))
246038
246311
  return;
246039
246312
  const stack = [];
246040
246313
  const collect = (dir) => {
246041
- for (const entry of readdirSync5(dir)) {
246314
+ for (const entry of readdirSync6(dir)) {
246042
246315
  const full = join11(dir, entry);
246043
- if (lstatSync(full).isDirectory())
246316
+ if (lstatSync2(full).isDirectory())
246044
246317
  collect(full);
246045
246318
  }
246046
246319
  stack.push(dir);
@@ -246048,7 +246321,7 @@ function pruneEmptyDirs(root) {
246048
246321
  collect(root);
246049
246322
  for (const dir of stack) {
246050
246323
  try {
246051
- if (readdirSync5(dir).length === 0)
246324
+ if (readdirSync6(dir).length === 0)
246052
246325
  rmdirSync(dir);
246053
246326
  } catch {}
246054
246327
  }
@@ -246933,12 +247206,12 @@ function looksLikeFreeform(prop) {
246933
247206
  return prop.pattern !== undefined || prop.format !== undefined;
246934
247207
  }
246935
247208
  // src/commands/workflow/index.ts
246936
- import { existsSync as existsSync23, promises as fs21 } from "node:fs";
247209
+ import { existsSync as existsSync24, promises as fs21 } from "node:fs";
246937
247210
  import path19 from "node:path";
246938
247211
 
246939
247212
  // src/lib/local-templates.ts
246940
247213
  init_src();
246941
- import { existsSync as existsSync18, promises as fs18, realpathSync as realpathSync4, statSync as statSync5 } from "node:fs";
247214
+ import { existsSync as existsSync19, promises as fs18, realpathSync as realpathSync4, statSync as statSync5 } from "node:fs";
246942
247215
  import { basename as basename2, dirname as dirname7, isAbsolute as isAbsolute2, relative as relative5, resolve as resolve8, sep } from "node:path";
246943
247216
 
246944
247217
  // src/lib/office-template.ts
@@ -247181,7 +247454,7 @@ function walkTemplateSteps(steps, visit) {
247181
247454
  }
247182
247455
  function resolveWorkflowProjectRoot(workflowFile) {
247183
247456
  const abs = resolve8(workflowFile);
247184
- if (!existsSync18(abs)) {
247457
+ if (!existsSync19(abs)) {
247185
247458
  throw new Error(`Workflow file not found: ${abs}`);
247186
247459
  }
247187
247460
  return dirname7(realpathSync4(abs));
@@ -247204,7 +247477,7 @@ function resolveWorkflowTemplatePath(workflowFile, templatePath, opts = {}) {
247204
247477
  if (!opts.allowExternal) {
247205
247478
  assertInsideProject(projectRoot, templatePath, candidate);
247206
247479
  }
247207
- if (!existsSync18(candidate)) {
247480
+ if (!existsSync19(candidate)) {
247208
247481
  throw new Error(`Local template not found: ${candidate}`);
247209
247482
  }
247210
247483
  const real = realpathSync4(candidate);
@@ -247386,13 +247659,13 @@ function rewriteLocalTemplateYaml(yamlText, resolved) {
247386
247659
  }
247387
247660
 
247388
247661
  // src/commands/workflow/clear.ts
247389
- import { existsSync as existsSync19, readdirSync as readdirSync6, rmSync as rmSync3, statSync as statSync6 } from "fs";
247662
+ import { existsSync as existsSync20, readdirSync as readdirSync7, rmSync as rmSync3, statSync as statSync6 } from "fs";
247390
247663
  import { basename as basename3, join as join12 } from "path";
247391
247664
  var EMPTY_REPORT = { removed: 0, kept: 0, touched: 0 };
247392
247665
  function getDirectoryEntries(path) {
247393
- if (!existsSync19(path))
247666
+ if (!existsSync20(path))
247394
247667
  return [];
247395
- return readdirSync6(path).filter((entry) => statSync6(join12(path, entry)).isDirectory()).sort();
247668
+ return readdirSync7(path).filter((entry) => statSync6(join12(path, entry)).isDirectory()).sort();
247396
247669
  }
247397
247670
  function removeDirEntriesWithRetention(path, removeAll) {
247398
247671
  const entries = getDirectoryEntries(path);
@@ -247411,10 +247684,10 @@ function removeDirEntriesWithRetention(path, removeAll) {
247411
247684
  return { removed, kept: keepSet.size, touched: entries.length };
247412
247685
  }
247413
247686
  function removeJudgeSummaryFilesWithRetention(exampleDir, removeAll) {
247414
- if (!existsSync19(exampleDir))
247687
+ if (!existsSync20(exampleDir))
247415
247688
  return EMPTY_REPORT;
247416
247689
  const stampByFile = new Map;
247417
- for (const fileName of readdirSync6(exampleDir).sort()) {
247690
+ for (const fileName of readdirSync7(exampleDir).sort()) {
247418
247691
  const match = /^llm-judge-summary-(.+)\.(json|md)$/.exec(fileName);
247419
247692
  if (match)
247420
247693
  stampByFile.set(fileName, match[1]);
@@ -247443,7 +247716,7 @@ function getTargetExampleDirs(dir, exampleNames) {
247443
247716
  error2(`No dataset/examples directory at ${join12(dir, "dataset", "examples")}`);
247444
247717
  process.exit(1);
247445
247718
  }
247446
- const all = readdirSync6(baseDir).filter((entry) => statSync6(join12(baseDir, entry)).isDirectory());
247719
+ const all = readdirSync7(baseDir).filter((entry) => statSync6(join12(baseDir, entry)).isDirectory());
247447
247720
  if (exampleNames.length === 0)
247448
247721
  return all.map((name) => join12(baseDir, name));
247449
247722
  const matched = all.filter((name) => exampleNames.includes(name));
@@ -247483,7 +247756,7 @@ async function clearEvalOutputs(dir, exampleNames = [], options = {}) {
247483
247756
  runSection({
247484
247757
  exampleDirs,
247485
247758
  clean: (exampleDir) => removeDirEntriesWithRetention(join12(exampleDir, "executions"), removeAll),
247486
- shouldCount: (exampleDir) => existsSync19(join12(exampleDir, "executions")),
247759
+ shouldCount: (exampleDir) => existsSync20(join12(exampleDir, "executions")),
247487
247760
  successLabel: "Execution cleanup complete",
247488
247761
  scannedLabel: "examples scanned:",
247489
247762
  seenLabel: "runs seen: ",
@@ -247495,7 +247768,7 @@ async function clearEvalOutputs(dir, exampleNames = [], options = {}) {
247495
247768
  runSection({
247496
247769
  exampleDirs,
247497
247770
  clean: (exampleDir) => removeJudgeSummaryFilesWithRetention(exampleDir, removeAll),
247498
- shouldCount: (exampleDir) => existsSync19(exampleDir),
247771
+ shouldCount: (exampleDir) => existsSync20(exampleDir),
247499
247772
  successLabel: "Judge summary cleanup complete",
247500
247773
  scannedLabel: "examples scanned: ",
247501
247774
  seenLabel: "summary files seen: ",
@@ -247899,7 +248172,7 @@ function registerStepExecCommands(workflow) {
247899
248172
 
247900
248173
  // src/commands/workflow/templates.ts
247901
248174
  init_src();
247902
- import { existsSync as existsSync20, promises as fs20 } from "node:fs";
248175
+ import { existsSync as existsSync21, promises as fs20 } from "node:fs";
247903
248176
  import { basename as basename4, resolve as resolve10 } from "node:path";
247904
248177
  function buildClient5(opts) {
247905
248178
  const config = resolveConfig(opts);
@@ -248080,7 +248353,7 @@ function registerTemplateCommands(parent) {
248080
248353
  filename = downloaded.filename;
248081
248354
  } else {
248082
248355
  const filePath = resolve10(templateArg);
248083
- if (!existsSync20(filePath)) {
248356
+ if (!existsSync21(filePath)) {
248084
248357
  throw new Error(`Template file not found: ${filePath}. Pass a local .docx/.xlsx path or a tmpl_… id.`);
248085
248358
  }
248086
248359
  bytes = await fs20.readFile(filePath);
@@ -248122,12 +248395,12 @@ function registerTemplateCommands(parent) {
248122
248395
 
248123
248396
  // src/commands/workflow/validation.ts
248124
248397
  init_src();
248125
- import { existsSync as existsSync22, readdirSync as readdirSync7, readFileSync as readFileSync19, statSync as statSync7 } from "fs";
248398
+ import { existsSync as existsSync23, readdirSync as readdirSync8, readFileSync as readFileSync20, statSync as statSync7 } from "fs";
248126
248399
  import { join as join13, resolve as resolve11 } from "path";
248127
248400
 
248128
248401
  // src/lib/template-diagnostics.ts
248129
248402
  init_src();
248130
- import { existsSync as existsSync21, readFileSync as readFileSync18 } from "node:fs";
248403
+ import { existsSync as existsSync22, readFileSync as readFileSync19 } from "node:fs";
248131
248404
  function walkSteps(steps, pathPrefix, visit) {
248132
248405
  if (!Array.isArray(steps))
248133
248406
  return;
@@ -248252,7 +248525,7 @@ async function diagnoseTemplateSteps(args) {
248252
248525
  });
248253
248526
  continue;
248254
248527
  }
248255
- if (!existsSync21(absolute)) {
248528
+ if (!existsSync22(absolute)) {
248256
248529
  diagnostics.push({
248257
248530
  field: `${info.fieldPath}.template`,
248258
248531
  message: `File not found: ${absolute}`,
@@ -248261,7 +248534,7 @@ async function diagnoseTemplateSteps(args) {
248261
248534
  continue;
248262
248535
  }
248263
248536
  try {
248264
- const bytes = readFileSync18(absolute);
248537
+ const bytes = readFileSync19(absolute);
248265
248538
  const inspection = inspectOfficeTemplateBytes(bytes, absolute);
248266
248539
  diagnostics.push(...formatDiagnostics(info, inspection));
248267
248540
  } catch (err) {
@@ -248397,7 +248670,7 @@ function countInvokeWorkflowSteps(steps) {
248397
248670
  return count;
248398
248671
  }
248399
248672
  function validateWorkflowYaml(path) {
248400
- if (!existsSync22(path)) {
248673
+ if (!existsSync23(path)) {
248401
248674
  return {
248402
248675
  issues: [{ field: path, message: "File not found." }],
248403
248676
  warnings: [],
@@ -248406,7 +248679,7 @@ function validateWorkflowYaml(path) {
248406
248679
  steps: []
248407
248680
  };
248408
248681
  }
248409
- const text = readFileSync19(path, "utf-8");
248682
+ const text = readFileSync20(path, "utf-8");
248410
248683
  try {
248411
248684
  const definition = parseWorkflow(text);
248412
248685
  let warnings = [];
@@ -248507,10 +248780,10 @@ function printSchemaQualityWarnings(path, warnings) {
248507
248780
  }
248508
248781
  }
248509
248782
  function validateEvaluatorsYaml(path) {
248510
- if (!existsSync22(path)) {
248783
+ if (!existsSync23(path)) {
248511
248784
  return [{ field: path, message: "File not found." }];
248512
248785
  }
248513
- const text = readFileSync19(path, "utf-8");
248786
+ const text = readFileSync20(path, "utf-8");
248514
248787
  let parsed;
248515
248788
  try {
248516
248789
  parsed = $parse(text);
@@ -248527,21 +248800,21 @@ function validateEvaluatorsYaml(path) {
248527
248800
  }
248528
248801
  function validateDatasetFolder(root) {
248529
248802
  const issues = [];
248530
- if (!existsSync22(root)) {
248803
+ if (!existsSync23(root)) {
248531
248804
  return [{ field: root, message: "Folder not found." }];
248532
248805
  }
248533
- if (existsSync22(join13(root, "manifest.json"))) {
248806
+ if (existsSync23(join13(root, "manifest.json"))) {
248534
248807
  issues.push({
248535
248808
  field: "manifest.json",
248536
248809
  message: "Top-level manifest.json is the legacy format. Re-export the dataset using the folder convention."
248537
248810
  });
248538
248811
  }
248539
248812
  const examplesDir = join13(root, "examples");
248540
- if (!existsSync22(examplesDir)) {
248813
+ if (!existsSync23(examplesDir)) {
248541
248814
  issues.push({ field: "examples/", message: "No examples/ directory found at dataset root." });
248542
248815
  return issues;
248543
248816
  }
248544
- for (const exampleName of readdirSync7(examplesDir)) {
248817
+ for (const exampleName of readdirSync8(examplesDir)) {
248545
248818
  const exampleFolder = join13(examplesDir, exampleName);
248546
248819
  if (!isDirSafe(exampleFolder, issues, `examples/${exampleName}`))
248547
248820
  continue;
@@ -248553,7 +248826,7 @@ function validateDatasetFolder(root) {
248553
248826
  continue;
248554
248827
  }
248555
248828
  const inputJsonPath = join13(exampleFolder, "input.json");
248556
- const hasInputJson = existsSync22(inputJsonPath);
248829
+ const hasInputJson = existsSync23(inputJsonPath);
248557
248830
  if (!hasInputJson) {
248558
248831
  issues.push({
248559
248832
  field: `examples/${exampleName}/input.json`,
@@ -248563,7 +248836,7 @@ function validateDatasetFolder(root) {
248563
248836
  }
248564
248837
  let args;
248565
248838
  try {
248566
- const parsed = JSON.parse(readFileSync19(inputJsonPath, "utf-8"));
248839
+ const parsed = JSON.parse(readFileSync20(inputJsonPath, "utf-8"));
248567
248840
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
248568
248841
  issues.push({
248569
248842
  field: `examples/${exampleName}/input.json`,
@@ -248580,7 +248853,7 @@ function validateDatasetFolder(root) {
248580
248853
  continue;
248581
248854
  }
248582
248855
  const inputDir = join13(exampleFolder, "input");
248583
- if (existsSync22(join13(inputDir, "arguments.json"))) {
248856
+ if (existsSync23(join13(inputDir, "arguments.json"))) {
248584
248857
  issues.push({
248585
248858
  field: `examples/${exampleName}/input/arguments.json`,
248586
248859
  message: "Legacy input/arguments.json is no longer accepted. Use input.json instead."
@@ -248597,8 +248870,8 @@ function validateDatasetFolder(root) {
248597
248870
  }
248598
248871
  const expectedDir = join13(exampleFolder, "expected");
248599
248872
  const expectedJsonPath = join13(exampleFolder, "expected.json");
248600
- if (existsSync22(expectedDir)) {
248601
- for (const entry of readdirSync7(expectedDir)) {
248873
+ if (existsSync23(expectedDir)) {
248874
+ for (const entry of readdirSync8(expectedDir)) {
248602
248875
  if (entry === "output.json" || entry === "error.json") {
248603
248876
  issues.push({
248604
248877
  field: `examples/${exampleName}/expected/${entry}`,
@@ -248633,10 +248906,10 @@ function validateDatasetFolder(root) {
248633
248906
  }
248634
248907
  }
248635
248908
  }
248636
- if (existsSync22(expectedJsonPath)) {
248909
+ if (existsSync23(expectedJsonPath)) {
248637
248910
  let parsed;
248638
248911
  try {
248639
- parsed = JSON.parse(readFileSync19(expectedJsonPath, "utf-8"));
248912
+ parsed = JSON.parse(readFileSync20(expectedJsonPath, "utf-8"));
248640
248913
  } catch {
248641
248914
  issues.push({
248642
248915
  field: `examples/${exampleName}/expected.json`,
@@ -248719,7 +248992,7 @@ function validateFileRefs2(args) {
248719
248992
  });
248720
248993
  continue;
248721
248994
  }
248722
- if (!existsSync22(join13(args.filesRoot, relative))) {
248995
+ if (!existsSync23(join13(args.filesRoot, relative))) {
248723
248996
  issues.push({
248724
248997
  field: `${args.fieldPrefix}:${ref.jsonPath}`,
248725
248998
  message: `Referenced file does not exist: ${ref.path}.`
@@ -248751,7 +249024,7 @@ async function onlineInvokeIssues(yamlText, opts) {
248751
249024
  }
248752
249025
  function discoverWorkflowProjectRoots(rootPath) {
248753
249026
  const root = resolve11(rootPath);
248754
- if (existsSync22(join13(root, "workflow.yaml")))
249027
+ if (existsSync23(join13(root, "workflow.yaml")))
248755
249028
  return [root];
248756
249029
  const candidates = [
248757
249030
  join13(root, "eigenpal", "workflows"),
@@ -248759,9 +249032,9 @@ function discoverWorkflowProjectRoots(rootPath) {
248759
249032
  root.endsWith(join13("eigenpal", "workflows")) ? root : ""
248760
249033
  ].filter(Boolean);
248761
249034
  for (const parent of candidates) {
248762
- if (!existsSync22(parent) || !statSync7(parent).isDirectory())
249035
+ if (!existsSync23(parent) || !statSync7(parent).isDirectory())
248763
249036
  continue;
248764
- const projects = readdirSync7(parent, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.isSymbolicLink() && existsSync22(join13(parent, entry.name, "workflow.yaml"))).map((entry) => join13(parent, entry.name)).sort();
249037
+ const projects = readdirSync8(parent, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.isSymbolicLink() && existsSync23(join13(parent, entry.name, "workflow.yaml"))).map((entry) => join13(parent, entry.name)).sort();
248765
249038
  if (projects.length > 0)
248766
249039
  return projects;
248767
249040
  }
@@ -248778,10 +249051,10 @@ async function validateProjectRoot(root, opts) {
248778
249051
  }
248779
249052
  const evOk = printIssues("evaluators.yaml", relPath(root, join13(root, "evaluators.yaml")), validateEvaluatorsYaml(join13(root, "evaluators.yaml")));
248780
249053
  const dsOk = printIssues("dataset/", relPath(root, join13(root, "dataset")), validateDatasetFolder(join13(root, "dataset")));
248781
- const templateOk = wfOk && existsSync22(wfFile) ? await runTemplateDiagnostics(wfFile, wfResult.steps, opts) : true;
249054
+ const templateOk = wfOk && existsSync23(wfFile) ? await runTemplateDiagnostics(wfFile, wfResult.steps, opts) : true;
248782
249055
  let onlineOk = true;
248783
- if (wfOk && opts.online && existsSync22(wfFile)) {
248784
- onlineOk = printIssues("invoke refs (server)", wfPath, await onlineInvokeIssues(readFileSync19(wfFile, "utf-8"), opts));
249056
+ if (wfOk && opts.online && existsSync23(wfFile)) {
249057
+ onlineOk = printIssues("invoke refs (server)", wfPath, await onlineInvokeIssues(readFileSync20(wfFile, "utf-8"), opts));
248785
249058
  }
248786
249059
  return wfOk && evOk && dsOk && templateOk && onlineOk;
248787
249060
  }
@@ -248797,7 +249070,7 @@ Note
248797
249070
  ` + ` project unless you pass --allow-external-templates.
248798
249071
  `);
248799
249072
  withBaseUrl(cmd).action(action(async (path, opts) => {
248800
- if (path && (!existsSync22(resolve11(path)) || !statSync7(resolve11(path)).isDirectory())) {
249073
+ if (path && (!existsSync23(resolve11(path)) || !statSync7(resolve11(path)).isDirectory())) {
248801
249074
  const target = resolve11(path);
248802
249075
  const wfResult = validateWorkflowYaml(target);
248803
249076
  const wfOk = printIssues("workflow.yaml", target, wfResult.issues);
@@ -248808,7 +249081,7 @@ Note
248808
249081
  const templateOk = wfOk ? await runTemplateDiagnostics(target, wfResult.steps, opts) : true;
248809
249082
  let onlineOk = true;
248810
249083
  if (wfOk && opts.online) {
248811
- onlineOk = printIssues("invoke refs (server)", target, await onlineInvokeIssues(readFileSync19(target, "utf-8"), opts));
249084
+ onlineOk = printIssues("invoke refs (server)", target, await onlineInvokeIssues(readFileSync20(target, "utf-8"), opts));
248812
249085
  }
248813
249086
  if (!wfOk || !templateOk || !onlineOk)
248814
249087
  process.exit(1);
@@ -249065,7 +249338,7 @@ new uploads are deleted. The file on disk is not rewritten.
249065
249338
  defaultValue: "workflow.yaml",
249066
249339
  validate: (value) => {
249067
249340
  const p = value || "workflow.yaml";
249068
- if (!existsSync23(p))
249341
+ if (!existsSync24(p))
249069
249342
  return `Not found: ${p}`;
249070
249343
  return;
249071
249344
  }
@@ -250081,7 +250354,7 @@ Behavior:
250081
250354
  const dest = opts.pull ? opts.pullOnComplete ?? `./results-${batchId}.${opts.format}` : null;
250082
250355
  if (dest) {
250083
250356
  const dir = path19.dirname(dest);
250084
- if (!existsSync23(dir)) {
250357
+ if (!existsSync24(dir)) {
250085
250358
  error2(`Destination directory does not exist: ${dir}. Create it first or pass a path under an existing directory.`);
250086
250359
  process.exit(2);
250087
250360
  }