@moda-ai/cli 1.55.27 → 1.55.29
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/{agent-vp9prdma.js → agent-0w9rtdsw.js} +22 -16
- package/dist/cli-3n0gz4d0.js +17971 -0
- package/dist/{cli-q9nsvqqg.js → cli-3retgh64.js} +85 -1165
- package/dist/{cli-ccjfwzqx.js → cli-97jew729.js} +1 -1
- package/dist/{cli-r5pp7qny.js → cli-99p2jh28.js} +42 -456
- package/dist/{cli-0pkc8jhg.js → cli-9bgk5jeh.js} +8 -6
- package/dist/{cli-hmjdgxrn.js → cli-9bgnvth2.js} +5 -3
- package/dist/cli-9kfxkxmk.js +6994 -0
- package/dist/cli-cesds766.js +1516 -0
- package/dist/{cli-v8q7sd7g.js → cli-dr6x0zv7.js} +1 -1
- package/dist/{cli-pg5qfmqc.js → cli-e23g9ywa.js} +1 -1
- package/dist/{cli-vdkwkkp5.js → cli-fwpqghgc.js} +4 -2
- package/dist/cli-k4tqwah4.js +89 -0
- package/dist/{cli-6et4z504.js → cli-mg5zv4s6.js} +15 -13
- package/dist/{cli-wzds257x.js → cli-n2hng3gv.js} +6 -4
- package/dist/cli-ns5fcnkz.js +341 -0
- package/dist/{cli-4h0ave0f.js → cli-ny48a8de.js} +12 -9
- package/dist/{cli-qwgct6x7.js → cli-qpq84eee.js} +5220 -32716
- package/dist/cli-xq45etg1.js +1098 -0
- package/dist/cli-yf39avhh.js +754 -0
- package/dist/cli-yz8xcpyk.js +12 -0
- package/dist/cli.js +435 -192
- package/dist/doctor-k3ta6h2y.js +24 -0
- package/dist/{fix-75s9s0d6.js → fix-w5z02wt4.js} +8 -9
- package/dist/{harness-a7tb9a23.js → harness-7azmzytc.js} +15 -7
- package/dist/{harness-github-actions-6v4wydb8.js → harness-github-actions-bv2qrnqb.js} +11 -5
- package/dist/harness-report-rd9c4e9v.js +54 -0
- package/dist/{index-91bpc8g8.js → index-d1z50dsq.js} +41 -33
- package/dist/{production-intelligence-7nqddd4f.js → production-intelligence-wvsgjxth.js} +9 -6
- package/dist/{profile-commands-49yn02yg.js → profile-commands-h8evz9x0.js} +7 -4
- package/dist/prompt-attribution-1nytc9wj.js +148 -0
- package/dist/prompt-source-mcp.js +14 -7
- package/dist/prompt-sources-07tczyqa.js +19 -0
- package/dist/{prompts-17wyrst6.js → prompts-6y9wfq5z.js} +8 -7
- package/dist/prompts-ab-ezrd63sk.js +70 -0
- package/dist/prompts-propose-2k3enm2q.js +255 -0
- package/dist/{provision-bc3h68e1.js → provision-y5bdbh4y.js} +9 -6
- package/dist/{registry-fpzhjznj.js → registry-96aze5wp.js} +7 -4
- package/dist/{skills-ccdbqghj.js → skills-j8865009.js} +7 -5
- package/dist/{sync-hkxce5zh.js → sync-ew7yvy0e.js} +16 -10
- package/package.json +1 -1
- package/skills/integration/index.json +2 -2
- package/dist/doctor-wmre3mr7.js +0 -22
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CliAccessError,
|
|
3
|
+
CliAuthError,
|
|
4
|
+
CliCancellationError,
|
|
5
|
+
CliInputError,
|
|
6
|
+
CliInputRequiredError,
|
|
7
|
+
CliNotFoundError,
|
|
8
|
+
apiErrorStatus,
|
|
9
|
+
inputDetailsOf,
|
|
10
|
+
isApiLikeError,
|
|
11
|
+
isNetworkLikeError
|
|
12
|
+
} from "./cli-k4tqwah4.js";
|
|
13
|
+
import {
|
|
14
|
+
redactDeep
|
|
15
|
+
} from "./cli-ns5fcnkz.js";
|
|
16
|
+
|
|
1
17
|
// src/profiles.ts
|
|
2
18
|
import {
|
|
3
19
|
chmodSync,
|
|
@@ -539,94 +555,6 @@ function writeSecretJsonFile(path, value) {
|
|
|
539
555
|
} catch {}
|
|
540
556
|
}
|
|
541
557
|
|
|
542
|
-
// src/errors.ts
|
|
543
|
-
class CliInputError extends Error {
|
|
544
|
-
usage;
|
|
545
|
-
reason;
|
|
546
|
-
details;
|
|
547
|
-
constructor(message, usage, reason, details) {
|
|
548
|
-
super(message);
|
|
549
|
-
this.usage = usage;
|
|
550
|
-
this.reason = reason;
|
|
551
|
-
this.details = details;
|
|
552
|
-
this.name = "CliInputError";
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
var inputDetails = new WeakMap;
|
|
556
|
-
function attachInputDetails(error, details) {
|
|
557
|
-
inputDetails.set(error, details);
|
|
558
|
-
}
|
|
559
|
-
function inputDetailsOf(error) {
|
|
560
|
-
if (error instanceof CliInputError && error.details)
|
|
561
|
-
return error.details;
|
|
562
|
-
return error !== null && typeof error === "object" ? inputDetails.get(error) : undefined;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
class CliAccessError extends Error {
|
|
566
|
-
guidance;
|
|
567
|
-
constructor(message, options = {}) {
|
|
568
|
-
super(message);
|
|
569
|
-
this.name = "CliAccessError";
|
|
570
|
-
this.guidance = options.guidance;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
class CliInputRequiredError extends Error {
|
|
575
|
-
input_request;
|
|
576
|
-
constructor(message, input_request, usage) {
|
|
577
|
-
super(message);
|
|
578
|
-
this.input_request = input_request;
|
|
579
|
-
this.name = "CliInputRequiredError";
|
|
580
|
-
if (usage)
|
|
581
|
-
this.usage = usage;
|
|
582
|
-
}
|
|
583
|
-
usage;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
class CliAuthError extends Error {
|
|
587
|
-
auth;
|
|
588
|
-
constructor(message, auth, usage) {
|
|
589
|
-
super(message);
|
|
590
|
-
this.auth = auth;
|
|
591
|
-
this.name = "CliAuthError";
|
|
592
|
-
if (usage)
|
|
593
|
-
this.usage = usage;
|
|
594
|
-
}
|
|
595
|
-
usage;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
class CliNotFoundError extends Error {
|
|
599
|
-
entity;
|
|
600
|
-
id;
|
|
601
|
-
usage;
|
|
602
|
-
constructor(entity, id, message, usage) {
|
|
603
|
-
super(message ?? `No ${entity} found for id "${id}" in this tenant.`);
|
|
604
|
-
this.entity = entity;
|
|
605
|
-
this.id = id;
|
|
606
|
-
this.usage = usage;
|
|
607
|
-
this.name = "CliNotFoundError";
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
class CliCancellationError extends Error {
|
|
612
|
-
constructor(message) {
|
|
613
|
-
super(message);
|
|
614
|
-
this.name = "CliCancellationError";
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
function isNetworkLikeError(error) {
|
|
618
|
-
return error instanceof Error && (error.message.startsWith("Network error:") || error.message.startsWith("Request timed out") || error.name === "AbortError" || /(?:ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|socket hang up)/i.test(error.message));
|
|
619
|
-
}
|
|
620
|
-
function isApiLikeError(error) {
|
|
621
|
-
return error instanceof Error && (error.name === "ApiError" || ("statusCode" in error) && typeof error.statusCode === "number");
|
|
622
|
-
}
|
|
623
|
-
function apiErrorStatus(error) {
|
|
624
|
-
if (!isApiLikeError(error))
|
|
625
|
-
return;
|
|
626
|
-
const status = error.statusCode;
|
|
627
|
-
return typeof status === "number" ? status : undefined;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
558
|
// src/config.ts
|
|
631
559
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
632
560
|
var pkg = JSON.parse(readFileSync2(new URL("../package.json", import.meta.url), "utf8"));
|
|
@@ -671,8 +599,6 @@ function resolveApiTenantId(options = {}) {
|
|
|
671
599
|
const apiKey = resolveApiKey(options);
|
|
672
600
|
return (apiKey ? embeddedTenantIdFromApiKey(apiKey) : undefined) || resolveTenantId(options);
|
|
673
601
|
}
|
|
674
|
-
var MODA_API_KEY = process.env.MODA_API_KEY;
|
|
675
|
-
var MODA_INGEST_URL = process.env.MODA_INGEST_URL || DEFAULT_INGEST_URL;
|
|
676
602
|
function resolveModaBaseUrl(options = {}) {
|
|
677
603
|
return resolveBaseUrl(options) || PROD_BASE_URL;
|
|
678
604
|
}
|
|
@@ -688,6 +614,31 @@ function validateConfig() {
|
|
|
688
614
|
}
|
|
689
615
|
}
|
|
690
616
|
|
|
617
|
+
// src/api-key-headers.ts
|
|
618
|
+
var PLATFORM_API_KEY_PREFIX = "moda_pk_";
|
|
619
|
+
var TENANT_HEADER = "x-moda-tenant-id";
|
|
620
|
+
function isPlatformApiKey(key) {
|
|
621
|
+
return Boolean(key?.startsWith(PLATFORM_API_KEY_PREFIX));
|
|
622
|
+
}
|
|
623
|
+
var platformTenantOverride;
|
|
624
|
+
function setPlatformTenantOverride(tenantId) {
|
|
625
|
+
platformTenantOverride = tenantId;
|
|
626
|
+
}
|
|
627
|
+
var TENANT_PATH = /\/tenants\/([^/?#]+)/;
|
|
628
|
+
function tenantFromUrl(url) {
|
|
629
|
+
const match = url ? TENANT_PATH.exec(url) : null;
|
|
630
|
+
return match ? decodeURIComponent(match[1]) : undefined;
|
|
631
|
+
}
|
|
632
|
+
function apiKeyHeaders(key, options = {}, url) {
|
|
633
|
+
const headers = { "x-api-key": key };
|
|
634
|
+
if (isPlatformApiKey(key)) {
|
|
635
|
+
const tenantId = tenantFromUrl(url) || platformTenantOverride || resolveTenantId(options);
|
|
636
|
+
if (tenantId)
|
|
637
|
+
headers[TENANT_HEADER] = tenantId;
|
|
638
|
+
}
|
|
639
|
+
return headers;
|
|
640
|
+
}
|
|
641
|
+
|
|
691
642
|
// src/api-request-count.ts
|
|
692
643
|
var apiRequestCount = 0;
|
|
693
644
|
function recordApiRequest() {
|
|
@@ -700,346 +651,6 @@ function resetApiRequestCount() {
|
|
|
700
651
|
apiRequestCount = 0;
|
|
701
652
|
}
|
|
702
653
|
|
|
703
|
-
// ../../packages/harness-snapshot/src/policy.ts
|
|
704
|
-
var MAX_SCANNED_FILE_BYTES = 512 * 1024;
|
|
705
|
-
var DEFAULT_MAX_INVENTORY_FILES = 12000;
|
|
706
|
-
var DEFAULT_MAX_INVENTORY_TEXT_BYTES = 48 * 1024 * 1024;
|
|
707
|
-
var MAX_SNAPSHOT_BODY_BYTES = 4500000;
|
|
708
|
-
var MAX_RECORDED_SKIPS = 1000;
|
|
709
|
-
var SKIPPED_DIRS = new Set([
|
|
710
|
-
".angular",
|
|
711
|
-
".cache",
|
|
712
|
-
".expo",
|
|
713
|
-
".git",
|
|
714
|
-
".hg",
|
|
715
|
-
".idea",
|
|
716
|
-
".svn",
|
|
717
|
-
".next",
|
|
718
|
-
".nuxt",
|
|
719
|
-
".output",
|
|
720
|
-
".parcel-cache",
|
|
721
|
-
".pytest_cache",
|
|
722
|
-
".ruff_cache",
|
|
723
|
-
".serverless",
|
|
724
|
-
".sst",
|
|
725
|
-
".turbo",
|
|
726
|
-
".wrangler",
|
|
727
|
-
".wrangler-shared",
|
|
728
|
-
".moda",
|
|
729
|
-
".moda-test",
|
|
730
|
-
".moda-test-home",
|
|
731
|
-
".moda-cli-workspaces",
|
|
732
|
-
".moda-cli-benchmarks",
|
|
733
|
-
"node_modules",
|
|
734
|
-
"dist",
|
|
735
|
-
"build",
|
|
736
|
-
"coverage",
|
|
737
|
-
"out",
|
|
738
|
-
"target",
|
|
739
|
-
"logs",
|
|
740
|
-
"tmp",
|
|
741
|
-
"temp",
|
|
742
|
-
"__pycache__",
|
|
743
|
-
".venv",
|
|
744
|
-
"venv"
|
|
745
|
-
]);
|
|
746
|
-
var SKIPPED_PATH_PREFIXES = [
|
|
747
|
-
".claude/worktrees",
|
|
748
|
-
".codex/environments"
|
|
749
|
-
];
|
|
750
|
-
function posixNormalize(path) {
|
|
751
|
-
const absolute = path.startsWith("/");
|
|
752
|
-
const parts = path.split("/").filter((part) => part !== "" && part !== ".");
|
|
753
|
-
const normalized = parts.join("/");
|
|
754
|
-
return absolute ? `/${normalized}` : normalized;
|
|
755
|
-
}
|
|
756
|
-
function basename(path) {
|
|
757
|
-
const normalized = posixNormalize(path);
|
|
758
|
-
const index = normalized.lastIndexOf("/");
|
|
759
|
-
return index === -1 ? normalized : normalized.slice(index + 1);
|
|
760
|
-
}
|
|
761
|
-
function extname(path) {
|
|
762
|
-
const name = basename(path);
|
|
763
|
-
const index = name.lastIndexOf(".");
|
|
764
|
-
return index <= 0 ? "" : name.slice(index);
|
|
765
|
-
}
|
|
766
|
-
function isSkippedDir(path) {
|
|
767
|
-
return SKIPPED_DIRS.has(basename(path));
|
|
768
|
-
}
|
|
769
|
-
function isSkippedPathPrefix(path) {
|
|
770
|
-
const normalized = posixNormalize(path);
|
|
771
|
-
return SKIPPED_PATH_PREFIXES.some((prefix) => normalized === prefix || normalized.startsWith(`${prefix}/`));
|
|
772
|
-
}
|
|
773
|
-
function isSourceFile(path) {
|
|
774
|
-
return /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(path);
|
|
775
|
-
}
|
|
776
|
-
function isPackageOrLockfile(path) {
|
|
777
|
-
return path === "package.json" || path === "pyproject.toml" || path === "bun.lock" || path === "bun.lockb" || path === "pnpm-lock.yaml" || path === "yarn.lock";
|
|
778
|
-
}
|
|
779
|
-
function isPromptLikePath(path) {
|
|
780
|
-
return /(^|\/)prompts?\//i.test(path) && /\.(prompt\.)?(md|json|ya?ml)$/i.test(path);
|
|
781
|
-
}
|
|
782
|
-
function isSkillLikePath(path) {
|
|
783
|
-
return /(^|\/)(\.claude\/skills|\.cursor\/rules|skills?)\//i.test(path) && /\.(md|mdc)$/i.test(path);
|
|
784
|
-
}
|
|
785
|
-
function isEvalLikePath(path) {
|
|
786
|
-
return /(^|\/)(evals?|tests?|__tests__)\//i.test(path) && /\.(ts|tsx|js|mjs|py|json|ya?ml)$/i.test(path);
|
|
787
|
-
}
|
|
788
|
-
function isDeploymentLikePath(path) {
|
|
789
|
-
return /(^|\/)(wrangler\.toml|vercel\.json|render\.ya?ml|railway\.json|Dockerfile|docker-compose\.ya?ml)$/i.test(path) || /^\.github\/workflows\/[^/]+\.ya?ml$/i.test(path);
|
|
790
|
-
}
|
|
791
|
-
function isDeveloperAgentConfigPath(path) {
|
|
792
|
-
return path === ".claude/settings.json" || path === ".codex/hooks.json" || path === ".cursor/hooks.json";
|
|
793
|
-
}
|
|
794
|
-
function isReadmeOrAgents(path) {
|
|
795
|
-
const name = basename(path);
|
|
796
|
-
return name === "README.md" || name === "AGENTS.md";
|
|
797
|
-
}
|
|
798
|
-
function shouldInventoryFile(path) {
|
|
799
|
-
const normalized = posixNormalize(path);
|
|
800
|
-
const name = basename(normalized);
|
|
801
|
-
const extension = extname(normalized).toLowerCase();
|
|
802
|
-
if (isSourceFile(normalized))
|
|
803
|
-
return true;
|
|
804
|
-
if (isPackageOrLockfile(normalized))
|
|
805
|
-
return true;
|
|
806
|
-
if (isPromptLikePath(normalized))
|
|
807
|
-
return true;
|
|
808
|
-
if (isSkillLikePath(normalized))
|
|
809
|
-
return true;
|
|
810
|
-
if (isEvalLikePath(normalized))
|
|
811
|
-
return true;
|
|
812
|
-
if (isDeploymentLikePath(normalized))
|
|
813
|
-
return true;
|
|
814
|
-
if (isDeveloperAgentConfigPath(normalized))
|
|
815
|
-
return true;
|
|
816
|
-
if (isReadmeOrAgents(normalized))
|
|
817
|
-
return true;
|
|
818
|
-
return extension === ".toml" && (name === "pyproject.toml" || name === "wrangler.toml");
|
|
819
|
-
}
|
|
820
|
-
function isTextFile(path) {
|
|
821
|
-
const extension = extname(path).toLowerCase();
|
|
822
|
-
return [
|
|
823
|
-
"",
|
|
824
|
-
".cjs",
|
|
825
|
-
".js",
|
|
826
|
-
".json",
|
|
827
|
-
".jsx",
|
|
828
|
-
".md",
|
|
829
|
-
".mdc",
|
|
830
|
-
".mjs",
|
|
831
|
-
".py",
|
|
832
|
-
".toml",
|
|
833
|
-
".ts",
|
|
834
|
-
".tsx",
|
|
835
|
-
".txt",
|
|
836
|
-
".yaml",
|
|
837
|
-
".yml"
|
|
838
|
-
].includes(extension);
|
|
839
|
-
}
|
|
840
|
-
function isSecretishPath(path) {
|
|
841
|
-
const name = basename(path).toLowerCase();
|
|
842
|
-
return name === ".env" || name.startsWith(".env.") || name.includes("secret") || name.includes("private-key") || name.endsWith(".pem");
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
// ../../packages/harness-snapshot/src/redact.ts
|
|
846
|
-
var REDACTED = "[REDACTED]";
|
|
847
|
-
var MAX_DEPTH = 256;
|
|
848
|
-
var SECRET_KEYS = new Set([
|
|
849
|
-
"api_key",
|
|
850
|
-
"apikey",
|
|
851
|
-
"token",
|
|
852
|
-
"access_token",
|
|
853
|
-
"authorization",
|
|
854
|
-
"secret",
|
|
855
|
-
"password",
|
|
856
|
-
"cli_token"
|
|
857
|
-
]);
|
|
858
|
-
var SECRET_PATTERNS = [
|
|
859
|
-
{ pattern: /\bmoda_sk_[A-Za-z0-9_-]+\b/g, prefixLength: 8 },
|
|
860
|
-
{ pattern: /\bmoda_pk_[A-Za-z0-9_-]+\b/g, prefixLength: 8 },
|
|
861
|
-
{ pattern: /\bmoda_ct_[A-Za-z0-9_-]+\b/g, prefixLength: 8 },
|
|
862
|
-
{ pattern: /\bBearer\s+([A-Za-z0-9._~+/-]+=*)\b/gi, prefixLength: 8 },
|
|
863
|
-
{ pattern: /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g, prefixLength: 8 },
|
|
864
|
-
{ pattern: /\bsk-ant-api\d{2}-[A-Za-z0-9_-]{20,}\b/g, prefixLength: 12 },
|
|
865
|
-
{ pattern: /\bsk-(?:proj-|svcacct-)?[A-Za-z0-9_-]{20,}\b/g, prefixLength: 8 },
|
|
866
|
-
{ pattern: /\bAKIA[A-Z0-9]{16}\b/g, prefixLength: 8 },
|
|
867
|
-
{ pattern: /\bAIza[A-Za-z0-9_-]{35}\b/g, prefixLength: 8 },
|
|
868
|
-
{ pattern: /\bgh[pousr]_[A-Za-z0-9]{36,}\b/g, prefixLength: 8 },
|
|
869
|
-
{ pattern: /\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g, prefixLength: 8 }
|
|
870
|
-
];
|
|
871
|
-
function redactDeep(value) {
|
|
872
|
-
return redactValue(value, 0, new WeakSet);
|
|
873
|
-
}
|
|
874
|
-
function redactValue(value, depth, seen) {
|
|
875
|
-
if (typeof value === "string")
|
|
876
|
-
return redactString(value);
|
|
877
|
-
if (value === null || typeof value !== "object")
|
|
878
|
-
return value;
|
|
879
|
-
if (depth >= MAX_DEPTH)
|
|
880
|
-
return "[MaxDepth]";
|
|
881
|
-
if (seen.has(value))
|
|
882
|
-
return "[Circular]";
|
|
883
|
-
seen.add(value);
|
|
884
|
-
if (Array.isArray(value)) {
|
|
885
|
-
try {
|
|
886
|
-
return value.map((item) => redactValue(item, depth + 1, seen));
|
|
887
|
-
} finally {
|
|
888
|
-
seen.delete(value);
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
const out = {};
|
|
892
|
-
try {
|
|
893
|
-
for (const [key, item] of Object.entries(value)) {
|
|
894
|
-
out[key] = shouldRedactKey(key) ? redactSecretValue(item) : redactValue(item, depth + 1, seen);
|
|
895
|
-
}
|
|
896
|
-
} finally {
|
|
897
|
-
seen.delete(value);
|
|
898
|
-
}
|
|
899
|
-
return out;
|
|
900
|
-
}
|
|
901
|
-
function shouldRedactKey(key) {
|
|
902
|
-
return SECRET_KEYS.has(key.replace(/[-\s]/g, "_").toLowerCase());
|
|
903
|
-
}
|
|
904
|
-
function redactSecretValue(value) {
|
|
905
|
-
if (typeof value !== "string")
|
|
906
|
-
return REDACTED;
|
|
907
|
-
const redacted = redactString(value);
|
|
908
|
-
if (redacted !== value)
|
|
909
|
-
return redacted;
|
|
910
|
-
if (/^(configured|missing|not_configured|none|present|absent)$/i.test(value))
|
|
911
|
-
return value;
|
|
912
|
-
return REDACTED;
|
|
913
|
-
}
|
|
914
|
-
function redactStringWithCount(input) {
|
|
915
|
-
let text = input;
|
|
916
|
-
let redactionCount = 0;
|
|
917
|
-
for (const { pattern, prefixLength } of SECRET_PATTERNS) {
|
|
918
|
-
text = text.replace(pattern, (match) => {
|
|
919
|
-
redactionCount += 1;
|
|
920
|
-
if (/^Bearer\s+/i.test(match)) {
|
|
921
|
-
const token = match.replace(/^Bearer\s+/i, "");
|
|
922
|
-
return `Bearer ${token.slice(0, prefixLength)}...[REDACTED]`;
|
|
923
|
-
}
|
|
924
|
-
return `${match.slice(0, prefixLength)}...[REDACTED]`;
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
return { text, redactionCount };
|
|
928
|
-
}
|
|
929
|
-
function redactString(input) {
|
|
930
|
-
return redactStringWithCount(input).text;
|
|
931
|
-
}
|
|
932
|
-
function redactSnapshotText(text) {
|
|
933
|
-
const parts = text.split(/(\r\n|\r|\n)/);
|
|
934
|
-
let redactionCount = 0;
|
|
935
|
-
for (let index = 0;index < parts.length; index += 2) {
|
|
936
|
-
const redacted = redactStringWithCount(parts[index] ?? "");
|
|
937
|
-
parts[index] = redacted.text;
|
|
938
|
-
redactionCount += redacted.redactionCount;
|
|
939
|
-
}
|
|
940
|
-
return { text: parts.join(""), redactionCount };
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
// ../../packages/harness-snapshot/src/pack.ts
|
|
944
|
-
function utf8ByteLength(value) {
|
|
945
|
-
let bytes = 0;
|
|
946
|
-
for (let index = 0;index < value.length; index += 1) {
|
|
947
|
-
const code = value.charCodeAt(index);
|
|
948
|
-
if (code <= 127) {
|
|
949
|
-
bytes += 1;
|
|
950
|
-
} else if (code <= 2047) {
|
|
951
|
-
bytes += 2;
|
|
952
|
-
} else if (code >= 55296 && code <= 56319) {
|
|
953
|
-
const next = value.charCodeAt(index + 1);
|
|
954
|
-
if (next >= 56320 && next <= 57343) {
|
|
955
|
-
bytes += 4;
|
|
956
|
-
index += 1;
|
|
957
|
-
} else {
|
|
958
|
-
bytes += 3;
|
|
959
|
-
}
|
|
960
|
-
} else {
|
|
961
|
-
bytes += 3;
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
return bytes;
|
|
965
|
-
}
|
|
966
|
-
function isValidRelativePath(path) {
|
|
967
|
-
if (path.length === 0 || path.startsWith("/") || path.includes("\\"))
|
|
968
|
-
return false;
|
|
969
|
-
return !path.split("/").some((part) => part === "..");
|
|
970
|
-
}
|
|
971
|
-
function packSnapshot(inputs, opts) {
|
|
972
|
-
const maxFiles = opts.maxFiles ?? DEFAULT_MAX_INVENTORY_FILES;
|
|
973
|
-
const maxTextBytes = opts.maxTextBytes ?? DEFAULT_MAX_INVENTORY_TEXT_BYTES;
|
|
974
|
-
const maxSnapshotBytes = opts.maxSnapshotBytes ?? MAX_SNAPSHOT_BODY_BYTES;
|
|
975
|
-
const files = [];
|
|
976
|
-
const skips = [];
|
|
977
|
-
let inventoryTextBytes = 0;
|
|
978
|
-
let serializedBytes = 0;
|
|
979
|
-
let byteCount = 0;
|
|
980
|
-
let truncated = false;
|
|
981
|
-
const recordSkip = (path, reason) => {
|
|
982
|
-
if (skips.length < MAX_RECORDED_SKIPS)
|
|
983
|
-
skips.push({ path, reason });
|
|
984
|
-
};
|
|
985
|
-
const sorted = [...inputs].sort((left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0);
|
|
986
|
-
for (const input of sorted) {
|
|
987
|
-
if (!isValidRelativePath(input.path)) {
|
|
988
|
-
recordSkip(input.path, "invalid relative path");
|
|
989
|
-
continue;
|
|
990
|
-
}
|
|
991
|
-
const path = posixNormalize(input.path);
|
|
992
|
-
if (input.isSymlink) {
|
|
993
|
-
recordSkip(path, "symlink skipped for safety");
|
|
994
|
-
continue;
|
|
995
|
-
}
|
|
996
|
-
if (isSecretishPath(path)) {
|
|
997
|
-
recordSkip(path, "secret-bearing path");
|
|
998
|
-
continue;
|
|
999
|
-
}
|
|
1000
|
-
if (!shouldInventoryFile(path)) {
|
|
1001
|
-
recordSkip(path, "not an inventory file");
|
|
1002
|
-
continue;
|
|
1003
|
-
}
|
|
1004
|
-
if (!isTextFile(path)) {
|
|
1005
|
-
recordSkip(path, "non-text file");
|
|
1006
|
-
continue;
|
|
1007
|
-
}
|
|
1008
|
-
if (input.byteSize > MAX_SCANNED_FILE_BYTES) {
|
|
1009
|
-
recordSkip(path, "file too large");
|
|
1010
|
-
truncated = true;
|
|
1011
|
-
continue;
|
|
1012
|
-
}
|
|
1013
|
-
if (files.length >= maxFiles || inventoryTextBytes + input.byteSize > maxTextBytes) {
|
|
1014
|
-
recordSkip(path, "inventory budget");
|
|
1015
|
-
truncated = true;
|
|
1016
|
-
continue;
|
|
1017
|
-
}
|
|
1018
|
-
const text = opts.redact === false ? input.text : redactSnapshotText(input.text).text;
|
|
1019
|
-
const file = { path, text };
|
|
1020
|
-
const serializedCost = utf8ByteLength(JSON.stringify(file)) + 1;
|
|
1021
|
-
if (serializedBytes + serializedCost > maxSnapshotBytes) {
|
|
1022
|
-
recordSkip(path, "snapshot budget");
|
|
1023
|
-
truncated = true;
|
|
1024
|
-
break;
|
|
1025
|
-
}
|
|
1026
|
-
files.push(file);
|
|
1027
|
-
inventoryTextBytes += input.byteSize;
|
|
1028
|
-
serializedBytes += serializedCost;
|
|
1029
|
-
byteCount += utf8ByteLength(text);
|
|
1030
|
-
}
|
|
1031
|
-
return {
|
|
1032
|
-
snapshot: {
|
|
1033
|
-
repo: { name: opts.repoName, root: "." },
|
|
1034
|
-
files,
|
|
1035
|
-
truncated,
|
|
1036
|
-
fileCount: files.length,
|
|
1037
|
-
byteCount,
|
|
1038
|
-
...opts.gitCommit ? { gitCommit: opts.gitCommit } : {}
|
|
1039
|
-
},
|
|
1040
|
-
skips
|
|
1041
|
-
};
|
|
1042
|
-
}
|
|
1043
654
|
// src/shell-quote.ts
|
|
1044
655
|
function shellArg(value) {
|
|
1045
656
|
if (/^[A-Za-z0-9_.,:@%+/=-]+$/.test(value))
|
|
@@ -2512,29 +2123,4 @@ function extractSuggestedCommands(text) {
|
|
|
2512
2123
|
return commands.length > 0 ? commands : undefined;
|
|
2513
2124
|
}
|
|
2514
2125
|
|
|
2515
|
-
|
|
2516
|
-
var PLATFORM_API_KEY_PREFIX = "moda_pk_";
|
|
2517
|
-
var TENANT_HEADER = "x-moda-tenant-id";
|
|
2518
|
-
function isPlatformApiKey(key) {
|
|
2519
|
-
return Boolean(key?.startsWith(PLATFORM_API_KEY_PREFIX));
|
|
2520
|
-
}
|
|
2521
|
-
var platformTenantOverride;
|
|
2522
|
-
function setPlatformTenantOverride(tenantId) {
|
|
2523
|
-
platformTenantOverride = tenantId;
|
|
2524
|
-
}
|
|
2525
|
-
var TENANT_PATH = /\/tenants\/([^/?#]+)/;
|
|
2526
|
-
function tenantFromUrl(url) {
|
|
2527
|
-
const match = url ? TENANT_PATH.exec(url) : null;
|
|
2528
|
-
return match ? decodeURIComponent(match[1]) : undefined;
|
|
2529
|
-
}
|
|
2530
|
-
function apiKeyHeaders(key, options = {}, url) {
|
|
2531
|
-
const headers = { "x-api-key": key };
|
|
2532
|
-
if (isPlatformApiKey(key)) {
|
|
2533
|
-
const tenantId = tenantFromUrl(url) || platformTenantOverride || resolveTenantId(options);
|
|
2534
|
-
if (tenantId)
|
|
2535
|
-
headers[TENANT_HEADER] = tenantId;
|
|
2536
|
-
}
|
|
2537
|
-
return headers;
|
|
2538
|
-
}
|
|
2539
|
-
|
|
2540
|
-
export { PROD_BASE_URL, DEFAULT_INGEST_URL, getModaPaths, getModaDir, isLoopbackBaseUrl, describeBaseUrlSource, loadProfileConfig, saveProfileConfig, getActiveProfile, setActiveProfile, upsertProfile, clearStoredApiKeyCredentials, secretFilePathFromRef, resolveSecretReference, resolveApiKeyFromActiveProfile, resolveTenantIdFromActiveProfile, ensureSecretFilePermissions, writeSecretJsonFile, CliInputError, attachInputDetails, inputDetailsOf, CliAccessError, CliInputRequiredError, CliAuthError, CliNotFoundError, CliCancellationError, isNetworkLikeError, isApiLikeError, apiErrorStatus, VERSION, MODA_BASE_URL, loadCliConfig, saveCliConfig, resolveApiKey, embeddedTenantIdFromApiKey, resolveIngestUrl2 as resolveIngestUrl, resolveTenantId, resolveApiTenantId, resolveModaBaseUrl, resolveModaBaseUrlStrict, validateConfig, isPlatformApiKey, setPlatformTenantOverride, apiKeyHeaders, recordApiRequest, getApiRequestCount, resetApiRequestCount, MAX_SCANNED_FILE_BYTES, DEFAULT_MAX_INVENTORY_FILES, DEFAULT_MAX_INVENTORY_TEXT_BYTES, MAX_RECORDED_SKIPS, SKIPPED_DIRS, isSkippedDir, isSkippedPathPrefix, isEvalLikePath, shouldInventoryFile, isTextFile, isSecretishPath, SECRET_KEYS, redactDeep, redactString, packSnapshot, shellArg, LEGACY_NAMES, canonicalCommandText, setAgentUpdateNotice, EXIT_OK, EXIT_ERROR, EXIT_DEGRADED, EXIT_AUTH_REQUIRED, EXIT_INPUT_REQUIRED, EXIT_CANCELLED, AGENT_ERROR_CODES, wasOutputCancelled, safeWriteStdout, safeWriteStderr, explicitOutputMode, outputModeFromFlags, resolveOutputMode, createCliOutput, agentEnvelopeFits, errorToAgentError, agentMaxOutputBytes, continuationCommand };
|
|
2126
|
+
export { PROD_BASE_URL, DEFAULT_INGEST_URL, getModaPaths, getModaDir, isLoopbackBaseUrl, describeBaseUrlSource, loadProfileConfig, saveProfileConfig, getActiveProfile, setActiveProfile, upsertProfile, clearStoredApiKeyCredentials, secretFilePathFromRef, resolveSecretReference, resolveApiKeyFromActiveProfile, resolveTenantIdFromActiveProfile, ensureSecretFilePermissions, writeSecretJsonFile, VERSION, MODA_BASE_URL, loadCliConfig, saveCliConfig, resolveApiKey, embeddedTenantIdFromApiKey, resolveIngestUrl2 as resolveIngestUrl, resolveTenantId, resolveApiTenantId, resolveModaBaseUrl, resolveModaBaseUrlStrict, validateConfig, isPlatformApiKey, setPlatformTenantOverride, apiKeyHeaders, recordApiRequest, getApiRequestCount, resetApiRequestCount, shellArg, LEGACY_NAMES, canonicalCommandText, setAgentUpdateNotice, EXIT_OK, EXIT_ERROR, EXIT_DEGRADED, EXIT_AUTH_REQUIRED, EXIT_INPUT_REQUIRED, EXIT_CANCELLED, AGENT_ERROR_CODES, wasOutputCancelled, safeWriteStdout, safeWriteStderr, explicitOutputMode, outputModeFromFlags, resolveOutputMode, createCliOutput, agentEnvelopeFits, errorToAgentError, agentMaxOutputBytes, continuationCommand };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fetchApiKeyProbe
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-97jew729.js";
|
|
4
4
|
import {
|
|
5
5
|
authFetch,
|
|
6
6
|
getCachedLoginContext
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-9bgnvth2.js";
|
|
8
8
|
import {
|
|
9
|
-
CliAccessError,
|
|
10
|
-
CliInputError,
|
|
11
|
-
CliInputRequiredError,
|
|
12
9
|
embeddedTenantIdFromApiKey,
|
|
13
10
|
getModaDir,
|
|
14
11
|
loadCliConfig,
|
|
@@ -18,7 +15,12 @@ import {
|
|
|
18
15
|
resolveTenantIdFromActiveProfile,
|
|
19
16
|
saveCliConfig,
|
|
20
17
|
writeSecretJsonFile
|
|
21
|
-
} from "./cli-
|
|
18
|
+
} from "./cli-99p2jh28.js";
|
|
19
|
+
import {
|
|
20
|
+
CliAccessError,
|
|
21
|
+
CliInputError,
|
|
22
|
+
CliInputRequiredError
|
|
23
|
+
} from "./cli-k4tqwah4.js";
|
|
22
24
|
|
|
23
25
|
// src/init/tenant.ts
|
|
24
26
|
import { randomUUID } from "node:crypto";
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CliAuthError,
|
|
3
|
-
CliInputError,
|
|
4
2
|
getModaPaths,
|
|
5
3
|
loadProfileConfig,
|
|
6
4
|
recordApiRequest,
|
|
@@ -8,7 +6,11 @@ import {
|
|
|
8
6
|
saveProfileConfig,
|
|
9
7
|
secretFilePathFromRef,
|
|
10
8
|
writeSecretJsonFile
|
|
11
|
-
} from "./cli-
|
|
9
|
+
} from "./cli-99p2jh28.js";
|
|
10
|
+
import {
|
|
11
|
+
CliAuthError,
|
|
12
|
+
CliInputError
|
|
13
|
+
} from "./cli-k4tqwah4.js";
|
|
12
14
|
import {
|
|
13
15
|
__require
|
|
14
16
|
} from "./cli-0v6na3yp.js";
|