@picassohq/cli 1.0.1 → 1.0.2
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/build-info.json +1 -1
- package/dist/index.js +1291 -1257
- package/package.json +1 -1
- package/runtime/engine-manifest.json +10 -9
- package/runtime/packages/picasso-lean-context/index.js +238 -7
- package/runtime/packages/picasso-lean-context/read-image-recovery.js +306 -0
- package/runtime/packages/picasso-lean-context/timeline.js +4 -3
- package/runtime/packages/picasso-model-router/connections.js +17 -0
- package/runtime/packages/picasso-model-router/index.js +2 -0
- package/runtime/packages/picasso-sdk-server/aside.js +15 -1
- package/runtime/packages/picasso-sdk-server/index.js +6 -1
- package/runtime/packages/picasso-web-search/backends.js +71 -9
- package/runtime/packages/picasso-web-search/failure.js +9 -4
- package/runtime/packages/picasso-web-search/format.js +13 -6
- package/runtime/packages/picasso-web-search/index.js +9 -4
- package/runtime/packages/picasso-web-search/router.js +3 -2
- package/runtime/plugins/picasso-lean-context/index.js +238 -7
- package/runtime/plugins/picasso-lean-context/read-image-recovery.js +306 -0
- package/runtime/plugins/picasso-lean-context/timeline.js +4 -3
- package/runtime/plugins/picasso-model-router/connections.js +17 -0
- package/runtime/plugins/picasso-model-router/index.js +2 -0
- package/runtime/plugins/picasso-web-search/backends.js +71 -9
- package/runtime/plugins/picasso-web-search/failure.js +9 -4
- package/runtime/plugins/picasso-web-search/format.js +13 -6
- package/runtime/plugins/picasso-web-search/index.js +9 -4
- package/runtime/plugins/picasso-web-search/router.js +3 -2
- package/runtime/relay/main.mjs +2403 -1075
- package/runtime/relay/versions-routes.mjs +218 -16
|
@@ -73,7 +73,12 @@ var LOCAL_ATTACH_PROVIDER_ROUTES = Object.freeze([
|
|
|
73
73
|
{ method: "POST", path: "/providers/custom" },
|
|
74
74
|
{ method: "POST", path: "/providers/:id/models" },
|
|
75
75
|
{ method: "POST", path: "/providers/:id/edit" },
|
|
76
|
-
{ method: "POST", path: "/providers/:id/remove" }
|
|
76
|
+
{ method: "POST", path: "/providers/:id/remove" },
|
|
77
|
+
// Active models (which models the pickers show; model-connections.json `active`): the same class as `/models`,
|
|
78
|
+
// never a key. `POST /models/refresh` reads endpoints with stored keys, so it stays refused like `/refresh`.
|
|
79
|
+
{ method: "GET", path: "/models/active" },
|
|
80
|
+
{ method: "GET", path: "/providers/:id/model-choices" },
|
|
81
|
+
{ method: "POST", path: "/providers/:id/active-models" }
|
|
77
82
|
]);
|
|
78
83
|
var LOCAL_ATTACH_ROUTES = Object.freeze([
|
|
79
84
|
{ method: "GET", path: "/health" },
|
|
@@ -527,11 +532,24 @@ var GiB = 1024 * 1024 * 1024;
|
|
|
527
532
|
var MEMORY_HIGH_BYTES = 6 * GiB;
|
|
528
533
|
var MEMORY_CRITICAL_BYTES = 16 * GiB;
|
|
529
534
|
|
|
535
|
+
// ../../packages/shared-home/dist/route-listings.js
|
|
536
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync5, renameSync as renameSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
537
|
+
import { dirname as dirname7, join as join17 } from "node:path";
|
|
538
|
+
|
|
539
|
+
// ../../packages/shared-home/dist/model-id-migration.js
|
|
540
|
+
import { copyFileSync, existsSync as existsSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
541
|
+
import { join as join18 } from "node:path";
|
|
542
|
+
import { isMap, isScalar, isSeq, parseDocument } from "yaml";
|
|
543
|
+
|
|
544
|
+
// ../../packages/shared-home/dist/active-models.js
|
|
545
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync4, readFileSync as readFileSync7, readdirSync as readdirSync3 } from "node:fs";
|
|
546
|
+
import { join as join19 } from "node:path";
|
|
547
|
+
|
|
530
548
|
// ../../packages/sessions/dist/index.js
|
|
531
549
|
import { createHash as createHash3, randomBytes as randomBytes4 } from "node:crypto";
|
|
532
|
-
import { createReadStream, readFileSync as
|
|
550
|
+
import { createReadStream, readFileSync as readFileSync10, statSync as statSync4 } from "node:fs";
|
|
533
551
|
import { appendFile, chmod as chmod4, mkdir as mkdir4, readdir as readdir2, rename as rename3, rm as rm5, writeFile } from "node:fs/promises";
|
|
534
|
-
import { isAbsolute as isAbsolute3, join as
|
|
552
|
+
import { isAbsolute as isAbsolute3, join as join23, resolve as resolve5 } from "node:path";
|
|
535
553
|
import { createInterface } from "node:readline/promises";
|
|
536
554
|
|
|
537
555
|
// ../../packages/shared/dist/logger.js
|
|
@@ -594,10 +612,194 @@ var CREDENTIAL_PATTERNS = [
|
|
|
594
612
|
...CREDENTIAL_RULES
|
|
595
613
|
];
|
|
596
614
|
|
|
615
|
+
// ../../packages/shared/dist/model-facts.js
|
|
616
|
+
var TOKEN_CASING = {
|
|
617
|
+
ai: "AI",
|
|
618
|
+
api: "API",
|
|
619
|
+
glm: "GLM",
|
|
620
|
+
gpt: "GPT",
|
|
621
|
+
deepseek: "DeepSeek",
|
|
622
|
+
qwen: "Qwen",
|
|
623
|
+
kimi: "Kimi",
|
|
624
|
+
minimax: "MiniMax",
|
|
625
|
+
gemini: "Gemini",
|
|
626
|
+
claude: "Claude",
|
|
627
|
+
llama: "Llama",
|
|
628
|
+
mimo: "MiMo",
|
|
629
|
+
vl: "VL",
|
|
630
|
+
oss: "OSS",
|
|
631
|
+
moe: "MoE",
|
|
632
|
+
openai: "OpenAI",
|
|
633
|
+
zai: "Z.ai",
|
|
634
|
+
xai: "xAI",
|
|
635
|
+
nvidia: "NVIDIA",
|
|
636
|
+
github: "GitHub",
|
|
637
|
+
aws: "AWS",
|
|
638
|
+
lm: "LM",
|
|
639
|
+
tts: "TTS",
|
|
640
|
+
hf: "HF"
|
|
641
|
+
};
|
|
642
|
+
var PROVIDER_NAMES = {
|
|
643
|
+
anthropic: "Anthropic",
|
|
644
|
+
openai: "OpenAI",
|
|
645
|
+
"openai-codex": "OpenAI Codex",
|
|
646
|
+
google: "Google Gemini",
|
|
647
|
+
"google-vertex": "Google Vertex AI",
|
|
648
|
+
deepseek: "DeepSeek",
|
|
649
|
+
"deepseek-official": "DeepSeek",
|
|
650
|
+
mistral: "Mistral",
|
|
651
|
+
xai: "xAI",
|
|
652
|
+
groq: "Groq",
|
|
653
|
+
openrouter: "OpenRouter",
|
|
654
|
+
"vercel-ai-gateway": "Vercel AI Gateway",
|
|
655
|
+
"cloudflare-ai-gateway": "Cloudflare AI Gateway",
|
|
656
|
+
"cloudflare-workers-ai": "Cloudflare Workers AI",
|
|
657
|
+
"amazon-bedrock": "Amazon Bedrock",
|
|
658
|
+
azure: "Azure OpenAI",
|
|
659
|
+
together: "Together AI",
|
|
660
|
+
fireworks: "Fireworks",
|
|
661
|
+
huggingface: "Hugging Face",
|
|
662
|
+
moonshotai: "Moonshot AI",
|
|
663
|
+
"moonshotai-cn": "Moonshot AI (China)",
|
|
664
|
+
opencode: "OpenCode Zen",
|
|
665
|
+
"opencode-go": "OpenCode Go",
|
|
666
|
+
"github-copilot": "GitHub Copilot",
|
|
667
|
+
cerebras: "Cerebras",
|
|
668
|
+
nvidia: "NVIDIA",
|
|
669
|
+
minimax: "MiniMax",
|
|
670
|
+
"minimax-cn": "MiniMax (China)",
|
|
671
|
+
zai: "Z.ai",
|
|
672
|
+
"kimi-coding": "Kimi Coding",
|
|
673
|
+
"qwen-token-plan": "Qwen Token Plan",
|
|
674
|
+
baseten: "Baseten",
|
|
675
|
+
meta: "Meta",
|
|
676
|
+
xiaomi: "Xiaomi",
|
|
677
|
+
ollama: "Ollama",
|
|
678
|
+
"lm-studio": "LM Studio",
|
|
679
|
+
"kiro-prism": "Kiro Prism",
|
|
680
|
+
prism: "Kiro Prism"
|
|
681
|
+
};
|
|
682
|
+
function tidyModelId(id) {
|
|
683
|
+
const last = id.split("/").filter((part) => part.length > 0).pop() ?? id;
|
|
684
|
+
return last.split(/[-_\s]+/u).filter((token) => token.length > 0).map(tidyToken).join(" ");
|
|
685
|
+
}
|
|
686
|
+
function tidyToken(token) {
|
|
687
|
+
const lower = token.toLowerCase();
|
|
688
|
+
const known = TOKEN_CASING[lower];
|
|
689
|
+
if (known !== void 0)
|
|
690
|
+
return known;
|
|
691
|
+
if (/^[vk]\d/u.test(lower))
|
|
692
|
+
return lower[0].toUpperCase() + lower.slice(1);
|
|
693
|
+
if (/^\d+(\.\d+)*[bkm]$/u.test(lower))
|
|
694
|
+
return lower.slice(0, -1) + lower.slice(-1).toUpperCase();
|
|
695
|
+
if (/^\d/u.test(lower))
|
|
696
|
+
return lower;
|
|
697
|
+
return lower[0].toUpperCase() + lower.slice(1);
|
|
698
|
+
}
|
|
699
|
+
function isNaiveName(name, id) {
|
|
700
|
+
const squash = (value) => value.toLowerCase().replace(/[-_\s]+/gu, " ").trim();
|
|
701
|
+
const last = id.split("/").filter((part) => part.length > 0).pop() ?? id;
|
|
702
|
+
if (squash(name) !== squash(id) && squash(name) !== squash(last))
|
|
703
|
+
return false;
|
|
704
|
+
return name.split(/[-_\s/]+/u).every((token) => token.slice(1) === token.slice(1).toLowerCase());
|
|
705
|
+
}
|
|
706
|
+
function displayProviderName(id, name) {
|
|
707
|
+
const given = name?.trim();
|
|
708
|
+
if (given && !isNaiveName(given, id))
|
|
709
|
+
return given;
|
|
710
|
+
return PROVIDER_NAMES[id] ?? tidyModelId(id);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// ../../packages/shared/dist/engine-errors.js
|
|
714
|
+
function addModelHint(surface, route, model) {
|
|
715
|
+
switch (surface) {
|
|
716
|
+
case "tui":
|
|
717
|
+
return "/provider to add it";
|
|
718
|
+
case "cli":
|
|
719
|
+
return `add it with: picasso provider models ${route} --add ${model}`;
|
|
720
|
+
case "mac":
|
|
721
|
+
return "add it in Settings \u203A Providers";
|
|
722
|
+
case "any":
|
|
723
|
+
return "add it to the connection's models";
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
function connectHint(surface, route) {
|
|
727
|
+
switch (surface) {
|
|
728
|
+
case "tui":
|
|
729
|
+
return "/provider to set it up";
|
|
730
|
+
case "cli":
|
|
731
|
+
return `set it up with: picasso provider set ${route}`;
|
|
732
|
+
case "mac":
|
|
733
|
+
return "set it up in Settings \u203A Providers";
|
|
734
|
+
case "any":
|
|
735
|
+
return "set up the connection first";
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
var connection = (route) => `The ${displayProviderName(route)} connection`;
|
|
739
|
+
var RULES = [
|
|
740
|
+
{
|
|
741
|
+
pattern: /pi-ai provider "([^"]+)" has no configured model "([^"]+)"/u,
|
|
742
|
+
plain: (m, surface) => `${connection(m[1])} doesn't have ${m[2]} set up \xB7 ${addModelHint(surface, m[1], m[2])}`
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
// Kept as "does not support reasoning effort" so the refusal is still recognised (model-reasoning.json).
|
|
746
|
+
pattern: /pi-ai provider "([^"]+)" model "([^"]+)" does not support reasoning effort "([^"]+)"/u,
|
|
747
|
+
plain: (m) => `${m[2]} on ${displayProviderName(m[1])} does not support reasoning effort "${m[3]}"`
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
pattern: /pi-ai adapter does not own provider "([^"]+)"/u,
|
|
751
|
+
plain: (m, surface) => `${connection(m[1])} isn't set up \xB7 ${connectHint(surface, m[1])}`
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
pattern: /no adapter registered for provider "([^"]+)"/u,
|
|
755
|
+
plain: (m, surface) => `${connection(m[1])} isn't set up \xB7 ${connectHint(surface, m[1])}`
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
pattern: /pi-ai request header preparation failed for provider "([^"]+)":\s*/u,
|
|
759
|
+
plain: (m) => `Couldn't prepare the request for ${displayProviderName(m[1])}: `
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
pattern: /pi-ai model "([^"]+)" does not support image input/u,
|
|
763
|
+
plain: (m) => `${m[1]} doesn't take images`
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
pattern: /pi-ai stream idle timeout after (\d+)ms/u,
|
|
767
|
+
plain: (m) => `The model sent nothing for ${Math.max(1, Math.round(Number(m[1]) / 1e3))} s`
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
pattern: /pi-ai detected context overflow for model "([^"]+)"/u,
|
|
771
|
+
plain: (m) => `The conversation is too long for ${m[1]}`
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
pattern: /pi-ai stream for model "([^"]+)" ended pending/u,
|
|
775
|
+
plain: (m) => `${m[1]} stopped before it finished the reply`
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
pattern: /pi-ai deferred response for model "([^"]+)" is not supported/u,
|
|
779
|
+
plain: (m) => `${m[1]} answered with a deferred response, which Picasso can't read`
|
|
780
|
+
}
|
|
781
|
+
];
|
|
782
|
+
function plainEngineError(raw, surface = "tui") {
|
|
783
|
+
if (typeof raw !== "string" || raw.length === 0)
|
|
784
|
+
return raw;
|
|
785
|
+
let text = raw;
|
|
786
|
+
for (const rule of RULES) {
|
|
787
|
+
const match = rule.pattern.exec(text);
|
|
788
|
+
if (match !== null)
|
|
789
|
+
text = text.slice(0, match.index) + rule.plain(match, surface) + text.slice(match.index + match[0].length);
|
|
790
|
+
}
|
|
791
|
+
if (!namesEngineLibrary(text))
|
|
792
|
+
return text;
|
|
793
|
+
return text.replace(/(^|[^-\w])\[?pi-ai\]?:?\s*/giu, (_whole, lead) => lead).replace(/\s{2,}/gu, " ").trim();
|
|
794
|
+
}
|
|
795
|
+
function namesEngineLibrary(text) {
|
|
796
|
+
return /(^|[^-\w])pi-ai\b/iu.test(text);
|
|
797
|
+
}
|
|
798
|
+
|
|
597
799
|
// ../../packages/sessions/dist/dsh-log.js
|
|
598
|
-
import { existsSync as
|
|
800
|
+
import { existsSync as existsSync5, readdirSync as readdirSync4, readFileSync as readFileSync8, statSync as statSync2 } from "node:fs";
|
|
599
801
|
import { homedir as homedir3 } from "node:os";
|
|
600
|
-
import { join as
|
|
802
|
+
import { join as join20 } from "node:path";
|
|
601
803
|
import * as zlib from "node:zlib";
|
|
602
804
|
var LOG_FILE = /^session\.v(\d+)\.jsonl(\.zstd)?$/u;
|
|
603
805
|
var ZSTD_MAGIC = Buffer.from([40, 181, 47, 253]);
|
|
@@ -605,14 +807,14 @@ var MEMORY_PREAMBLE = "Background memory recalled from EARLIER";
|
|
|
605
807
|
var MEMORY_REQUEST_MARKER = "\n\nUser request:\n";
|
|
606
808
|
var PROMPT_SOURCES = ["user", "goal", "agent-message", "subagent-settled"];
|
|
607
809
|
function defaultDshHome() {
|
|
608
|
-
return process.env.DSH_HOME ??
|
|
810
|
+
return process.env.DSH_HOME ?? join20(homedir3(), ".dsh");
|
|
609
811
|
}
|
|
610
812
|
function dshSessionsRoot(dshHome2 = defaultDshHome()) {
|
|
611
|
-
return
|
|
813
|
+
return join20(dshHome2, "sessions");
|
|
612
814
|
}
|
|
613
815
|
function safeReaddir(path) {
|
|
614
816
|
try {
|
|
615
|
-
return
|
|
817
|
+
return readdirSync4(path, { withFileTypes: true });
|
|
616
818
|
} catch {
|
|
617
819
|
return [];
|
|
618
820
|
}
|
|
@@ -625,7 +827,7 @@ function logInSessionDir(sessionDir, sessionId, projectDir) {
|
|
|
625
827
|
const match = LOG_FILE.exec(entry.name);
|
|
626
828
|
if (match === null)
|
|
627
829
|
continue;
|
|
628
|
-
const path =
|
|
830
|
+
const path = join20(sessionDir, entry.name);
|
|
629
831
|
let stats;
|
|
630
832
|
try {
|
|
631
833
|
stats = statSync2(path);
|
|
@@ -652,11 +854,11 @@ function indexDshSessionLogs(dshHome2) {
|
|
|
652
854
|
for (const project of safeReaddir(root)) {
|
|
653
855
|
if (!project.isDirectory())
|
|
654
856
|
continue;
|
|
655
|
-
const projectDir =
|
|
857
|
+
const projectDir = join20(root, project.name);
|
|
656
858
|
for (const session of safeReaddir(projectDir)) {
|
|
657
859
|
if (!session.isDirectory())
|
|
658
860
|
continue;
|
|
659
|
-
const found = logInSessionDir(
|
|
861
|
+
const found = logInSessionDir(join20(projectDir, session.name), session.name, projectDir);
|
|
660
862
|
if (found === void 0)
|
|
661
863
|
continue;
|
|
662
864
|
const existing = index.get(found.sessionId);
|
|
@@ -912,7 +1114,7 @@ function projectDshTranscript(records, options = {}) {
|
|
|
912
1114
|
if (kind === "error") {
|
|
913
1115
|
const error = isRecord(reason.error) ? str(reason.error.message) : str(reason.message);
|
|
914
1116
|
if (error !== void 0)
|
|
915
|
-
draft.error = error;
|
|
1117
|
+
draft.error = plainEngineError(error, "any");
|
|
916
1118
|
}
|
|
917
1119
|
const time = num(record.time);
|
|
918
1120
|
if (time !== void 0)
|
|
@@ -940,17 +1142,17 @@ import { resolve as resolve3 } from "node:path";
|
|
|
940
1142
|
|
|
941
1143
|
// ../../packages/sessions/dist/dsh-log-diagnostics.js
|
|
942
1144
|
import { createHash } from "node:crypto";
|
|
943
|
-
import { existsSync as
|
|
944
|
-
import { basename as basename3, dirname as
|
|
1145
|
+
import { existsSync as existsSync6, readFileSync as readFileSync9, statSync as statSync3 } from "node:fs";
|
|
1146
|
+
import { basename as basename3, dirname as dirname8, join as join21 } from "node:path";
|
|
945
1147
|
|
|
946
1148
|
// ../../packages/sessions/dist/sharing.js
|
|
947
1149
|
import { createHash as createHash2 } from "node:crypto";
|
|
948
1150
|
|
|
949
1151
|
// ../../packages/sessions/dist/lease.js
|
|
950
1152
|
import { execFile as execFile3 } from "node:child_process";
|
|
951
|
-
import { existsSync as
|
|
1153
|
+
import { existsSync as existsSync7, readdirSync as readdirSync5 } from "node:fs";
|
|
952
1154
|
import { readdir, readlink, realpath } from "node:fs/promises";
|
|
953
|
-
import { join as
|
|
1155
|
+
import { join as join22, resolve as resolve4 } from "node:path";
|
|
954
1156
|
|
|
955
1157
|
// ../../packages/sessions/dist/work-artifacts.js
|
|
956
1158
|
import { isAbsolute as isAbsolute2, posix } from "node:path";
|