@psnext/slingcli 2.4.20260509-1 → 2.4.20260509-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/bin/sling.js CHANGED
@@ -1,12 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  process.title = "⭕️ sling";
3
-
4
- const SLING_VERSION = "2.4.20260509-1";
3
+ process.env.PI_CODING_AGENT = "true";
4
+ process.emitWarning = () => {};
5
5
 
6
6
  import { setBedrockProviderModule } from "@earendil-works/pi-ai";
7
7
  import { bedrockProviderModule } from "@earendil-works/pi-ai/bedrock-provider";
8
8
  import { EnvHttpProxyAgent, setGlobalDispatcher } from "undici";
9
- import { main } from "@earendil-works/pi-coding-agent";
10
9
  import path from "node:path";
11
10
  import { fileURLToPath } from "node:url";
12
11
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
@@ -15,7 +14,30 @@ import { spawn } from "node:child_process";
15
14
  import readline from "node:readline/promises";
16
15
  import semver from "semver";
17
16
 
18
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ const __dirname = path.dirname(__filename);
19
+ const IS_DEV = process.env.SLING_DEV === "1";
20
+
21
+ const productionOnly = async (fn, ...args) => (IS_DEV ? undefined : fn(...args));
22
+ const devOnly = async (fn, ...args) => (IS_DEV ? fn(...args) : undefined);
23
+
24
+ function findSlingPkg() {
25
+ let dir = __dirname;
26
+ while (dir !== path.dirname(dir)) {
27
+ const p = path.join(dir, "package.json");
28
+ if (existsSync(p)) {
29
+ const j = JSON.parse(readFileSync(p, "utf-8"));
30
+ if (j.slingVersion) return j;
31
+ }
32
+ dir = path.dirname(dir);
33
+ }
34
+ throw new Error("Could not locate sling package.json with slingVersion");
35
+ }
36
+ const { slingVersion: SLING_VERSION } = findSlingPkg();
37
+
38
+ const { main } = IS_DEV
39
+ ? await import(path.resolve(__dirname, "packages/coding-agent/src/main.ts"))
40
+ : await import("@earendil-works/pi-coding-agent");
19
41
 
20
42
  function applyNoEnv(args) {
21
43
  const filtered = [];
@@ -70,9 +92,9 @@ async function checkAndInstallPackages() {
70
92
  const packages = config.packages || [];
71
93
  if (packages.length === 0) return;
72
94
 
73
- console.log("\\nFirst run detected. Installing default packages...");
95
+ console.log("\nFirst run detected. Installing default packages...");
74
96
  for (const pkg of packages) {
75
- console.log(`Installing \${pkg}...`);
97
+ console.log(`Installing ${pkg}...`);
76
98
  try {
77
99
  await runCommand(process.execPath, [__filename, "install", pkg]);
78
100
  console.log(`✓ Installed ${pkg}`);
@@ -82,7 +104,7 @@ async function checkAndInstallPackages() {
82
104
  }
83
105
  }
84
106
  writeFileSync(markerFile, new Date().toISOString());
85
- console.log("\\nDefault packages installation complete!\\n");
107
+ console.log("\nDefault packages installation complete!\n");
86
108
  } catch (err) {
87
109
  console.error("Failed to read default packages config:", err.message);
88
110
  }
@@ -93,7 +115,6 @@ async function checkForUpdate(args) {
93
115
  if (args.includes("--version") || args.includes("-v")) return;
94
116
  if (args.includes("install")) return;
95
117
 
96
- // Check if -y or --yes flag is present
97
118
  const autoYes = args.includes("-y") || args.includes("--yes");
98
119
 
99
120
  if (!autoYes && (!process.stdin.isTTY || !process.stdout.isTTY)) return;
@@ -132,18 +153,18 @@ async function checkForUpdate(args) {
132
153
  console.log("Installing @psnext/slingcli@" + latestVersion + "...");
133
154
  try {
134
155
  await runCommand("npm", ["install", "-g", "@psnext/slingcli@latest"]);
135
- console.log("\\u2713 Updated to " + latestVersion + ". Please run 'sling' again.");
156
+ console.log(" Updated to " + latestVersion + ". Please run 'sling' again.");
136
157
  process.exit(0);
137
158
  } catch {
138
- console.error("\\u2717 Auto-update failed. Run manually:");
159
+ console.error(" Auto-update failed. Run manually:");
139
160
  console.error(" npm install -g @psnext/slingcli@latest");
140
161
  console.error(" (you may need sudo)");
141
162
  }
142
163
  }
143
164
 
144
- // \`sling install <pkg>\` defaults to global (~/.sling/agent). When run from a
165
+ // `sling install <pkg>` defaults to global (~/.sling/agent). When run from a
145
166
  // TTY without an explicit scope flag, prompt for global vs local. Pi has no
146
- // \`-g/--global\` flag because global is its default; we only inject \`-l\` when
167
+ // `-g/--global` flag because global is its default; we only inject `-l` when
147
168
  // the user picks local. Non-TTY (CI/scripts) keeps the current default.
148
169
  async function promptInstallScopeIfNeeded(args) {
149
170
  let isInstall = false;
@@ -188,9 +209,9 @@ async function run() {
188
209
  console.log(SLING_VERSION);
189
210
  process.exit(0);
190
211
  }
191
- setGlobalDispatcher(new EnvHttpProxyAgent());
192
- await checkForUpdate(rawArgs);
193
- await checkAndInstallPackages();
212
+ setGlobalDispatcher(new EnvHttpProxyAgent({ bodyTimeout: 0, headersTimeout: 0 }));
213
+ await productionOnly(checkForUpdate, rawArgs);
214
+ await productionOnly(checkAndInstallPackages);
194
215
  setBedrockProviderModule(bedrockProviderModule);
195
216
  let args = applyNoEnv(rawArgs);
196
217
  args = await promptInstallScopeIfNeeded(args);
@@ -209,7 +230,9 @@ async function run() {
209
230
  if (existsSync(path.resolve(homedir(), ".slingshot/skills"))) {
210
231
  args.push("--skill", path.resolve(homedir(), ".slingshot/skills"));
211
232
  }
212
- const extensionPath = path.resolve(__dirname, "../slingshot");
233
+ const extensionPath = IS_DEV
234
+ ? path.resolve(__dirname, "slingshot")
235
+ : path.resolve(__dirname, "../slingshot");
213
236
  await main(["-e", extensionPath, "--provider", "slingshot", ...args]);
214
237
  }
215
238
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@psnext/slingcli",
3
- "version": "2.4.20260509-1",
3
+ "version": "2.4.20260509-2",
4
4
  "description": "Connects Sling CLI to Publicis Sapient Slingshot enterprise LLM gateway. Bundles the pi coding-agent runtime.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -29,7 +29,7 @@
29
29
  "type": "git",
30
30
  "url": "git+https://pscode.lioncloud.net/psaiproducts/slingcli.git"
31
31
  },
32
- "slingVersion": "2.4.20260509-1",
32
+ "slingVersion": "2.4.20260509-2",
33
33
  "dependencies": {
34
34
  "@earendil-works/pi-tui": "file:../.sling-pack/earendil-works-pi-tui-0.74.0.tgz",
35
35
  "@earendil-works/pi-ai": "file:../.sling-pack/earendil-works-pi-ai-0.74.0.tgz",
@@ -76,7 +76,7 @@ Log file: ${_t}
76
76
  `;qt.appendFileSync(_t,t)}catch{}}function mo(i,e){if(!(!_t||!qt))try{let n=`[${new Date().toISOString()}] ${i}:
77
77
  ${JSON.stringify(e,null,2)}
78
78
 
79
- `;qt.appendFileSync(_t,n)}catch{}}var ns={name:"slingshot.cli",private:!0,type:"module",workspaces:["packages/*","packages/web-ui/example","packages/coding-agent/examples/extensions/with-deps","packages/coding-agent/examples/extensions/custom-provider-anthropic","packages/coding-agent/examples/extensions/custom-provider-gitlab-duo","packages/coding-agent/examples/extensions/custom-provider-qwen-cli"],scripts:{clean:"npm run clean --workspaces",build:"cd packages/tui && npm run build && cd ../ai && npm run build && cd ../agent && npm run build && cd ../coding-agent && npm run build && cd ../mom && npm run build && cd ../web-ui && npm run build && cd ../pods && npm run build",dev:'concurrently --names "ai,agent,coding-agent,mom,web-ui,tui" --prefix-colors "cyan,yellow,red,white,green,magenta" "cd packages/ai && npm run dev" "cd packages/agent && npm run dev" "cd packages/coding-agent && npm run dev" "cd packages/mom && npm run dev" "cd packages/web-ui && npm run dev" "cd packages/tui && npm run dev"',"dev:tsc":'concurrently --names "ai,web-ui" --prefix-colors "cyan,green" "cd packages/ai && npm run dev:tsc" "cd packages/web-ui && npm run dev:tsc"',check:"","check:browser-smoke":"","profile:tui":"node scripts/profile-coding-agent-node.mjs --mode tui","profile:rpc":"node scripts/profile-coding-agent-node.mjs --mode rpc",test:"npm run test --workspaces --if-present","version:patch":"npm version patch -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:minor":"npm version minor -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:major":"npm version major -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:set":"npm version -ws",prepublishOnly:"npm run clean && npm run build && npm run check",publish:"npm run prepublishOnly && npm publish -ws --access public","publish:dry":"npm run prepublishOnly && npm publish -ws --access public --dry-run","release:patch":"node scripts/release.mjs patch","release:minor":"node scripts/release.mjs minor","release:major":"node scripts/release.mjs major",prepare:"husky"},devDependencies:{esbuild:"^0.25.0","@anthropic-ai/sandbox-runtime":"^0.0.26","@biomejs/biome":"2.3.5","@types/node":"^22.10.5","@typescript/native-preview":"7.0.0-dev.20260120.1",concurrently:"^9.2.1",husky:"^9.1.7",jiti:"^2.7.0",tsx:"^4.20.3",typescript:"^5.9.2",shx:"^0.4.0"},engines:{node:">=20.0.0"},slingVersion:"2.4.20260509-1",overrides:{rimraf:"6.1.3","fast-xml-parser":"5.7.2",gaxios:{rimraf:"6.1.3"}},dependencies:{"compound-engineering-pi":"^0.2.4","get-east-asian-width":"^1.4.0"}};async function ho(i,e,t,n){let s=Op(),o=await e.modelRegistry.getApiKeyForProvider(e.model?.provider||"slingshot");if(!o){yt()&&Ie("ERROR: No API key found");return}let r=o.startsWith("Bearer ")?o:`Bearer ${o}`,a=process.env.SLINGSHOT_PROJECT_ID||t?.projectId||_p,l=process.env.SLINGSHOT_WORKSPACE_ID||t?.workspaceId||Lp,c=process.env.CLIENT_ID||Wp,d={"Content-Type":"application/json",accept:"application/json","access-token":r,"x-project-id":a,"x-workspace-id":l,"x-client-id":c,"sage-trace-id":s,"User-Agent":"pi-slingshot/1.0.0"},p=parseFloat(process.env.SLINGSHOT_TEMPERATURE||"0.2"),u=parseFloat(process.env.SLINGSHOT_TOP_P||"0.8"),h={source:ns.name||"sling",ai_model_info:{ai_provider_name:e.model?.provider||"slingshot",sage_modl_name:e.model?.id||"unknown",sage_modl_option:{temperature:String(p),max_token_size:String(e.model?.maxTokens||16834),top_p:String(u)}},rag_info:{type:null,account_name:"dummy",project_names:[],repository_names:[],programming_language:null},tab_data:{tab_count:"1"},tags:null,slingshot_version:ns.slingVersion||"2.3.2",chat_type:"agent",...n||{}};return{headers:d,sageCommonData:h}}async function go(i,e,t,n){let s={eventName:i,sageCommonData:t,eventData:n};try{let o=await fetch(Pp,{method:"POST",headers:e,body:JSON.stringify(s)});if(o.ok){let r=await o.json().catch(()=>{});if(r.error_code)throw new Error(`Analytics API error: ${r.error_code} - ${r.error_message||"No message"}`);yt()&&(Ie(`'SUCCESS: Event sent: ${i}`),Ie(`Response: ${JSON.stringify(r)}`),Ie("\u2500".repeat(66)))}else{let r=await o.text().catch(()=>""),a={status:o.status,statusText:o.statusText,responseBody:r,requestHeaders:e};throw yt()&&(Ie(`ERROR: ${o.status} ${o.statusText}`),mo("Error Details",a),mo("Failed Request Body",s)),new Error(`Analytics API error: ${o.status} ${o.statusText}`)}}catch(o){let r=o instanceof Error?o.message:String(o);console.warn("[Slingshot Analytics] Request that caused error:",r),yt()&&(Ie(`EXCEPTION: ${r}`),o instanceof Error&&o.stack&&Ie(`Stack trace: ${o.stack}`),mo("Request that caused exception",s))}}import is from"chalk";function Bp(i,e){return{render(t){let n=` \u26AC _______. __ __ .__ __. _______
79
+ `;qt.appendFileSync(_t,n)}catch{}}var ns={name:"slingshot.cli",private:!0,type:"module",workspaces:["packages/*","packages/web-ui/example","packages/coding-agent/examples/extensions/with-deps","packages/coding-agent/examples/extensions/custom-provider-anthropic","packages/coding-agent/examples/extensions/custom-provider-gitlab-duo","packages/coding-agent/examples/extensions/custom-provider-qwen-cli"],scripts:{clean:"npm run clean --workspaces",build:"cd packages/tui && npm run build && cd ../ai && npm run build && cd ../agent && npm run build && cd ../coding-agent && npm run build && cd ../mom && npm run build && cd ../web-ui && npm run build && cd ../pods && npm run build",dev:'concurrently --names "ai,agent,coding-agent,mom,web-ui,tui" --prefix-colors "cyan,yellow,red,white,green,magenta" "cd packages/ai && npm run dev" "cd packages/agent && npm run dev" "cd packages/coding-agent && npm run dev" "cd packages/mom && npm run dev" "cd packages/web-ui && npm run dev" "cd packages/tui && npm run dev"',"dev:tsc":'concurrently --names "ai,web-ui" --prefix-colors "cyan,green" "cd packages/ai && npm run dev:tsc" "cd packages/web-ui && npm run dev:tsc"',check:"","check:browser-smoke":"","profile:tui":"node scripts/profile-coding-agent-node.mjs --mode tui","profile:rpc":"node scripts/profile-coding-agent-node.mjs --mode rpc",test:"npm run test --workspaces --if-present","version:patch":"npm version patch -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:minor":"npm version minor -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:major":"npm version major -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:set":"npm version -ws",prepublishOnly:"npm run clean && npm run build && npm run check",publish:"npm run prepublishOnly && npm publish -ws --access public","publish:dry":"npm run prepublishOnly && npm publish -ws --access public --dry-run","release:patch":"node scripts/release.mjs patch","release:minor":"node scripts/release.mjs minor","release:major":"node scripts/release.mjs major",prepare:"husky"},devDependencies:{esbuild:"^0.25.0","@anthropic-ai/sandbox-runtime":"^0.0.26","@biomejs/biome":"2.3.5","@types/node":"^22.10.5","@typescript/native-preview":"7.0.0-dev.20260120.1",concurrently:"^9.2.1",husky:"^9.1.7",jiti:"^2.7.0",tsx:"^4.20.3",typescript:"^5.9.2",shx:"^0.4.0"},engines:{node:">=20.0.0"},slingVersion:"2.4.20260509-2",overrides:{rimraf:"6.1.3","fast-xml-parser":"5.7.2",gaxios:{rimraf:"6.1.3"}},dependencies:{"compound-engineering-pi":"^0.2.4","get-east-asian-width":"^1.4.0"}};async function ho(i,e,t,n){let s=Op(),o=await e.modelRegistry.getApiKeyForProvider(e.model?.provider||"slingshot");if(!o){yt()&&Ie("ERROR: No API key found");return}let r=o.startsWith("Bearer ")?o:`Bearer ${o}`,a=process.env.SLINGSHOT_PROJECT_ID||t?.projectId||_p,l=process.env.SLINGSHOT_WORKSPACE_ID||t?.workspaceId||Lp,c=process.env.CLIENT_ID||Wp,d={"Content-Type":"application/json",accept:"application/json","access-token":r,"x-project-id":a,"x-workspace-id":l,"x-client-id":c,"sage-trace-id":s,"User-Agent":"pi-slingshot/1.0.0"},p=parseFloat(process.env.SLINGSHOT_TEMPERATURE||"0.2"),u=parseFloat(process.env.SLINGSHOT_TOP_P||"0.8"),h={source:ns.name||"sling",ai_model_info:{ai_provider_name:e.model?.provider||"slingshot",sage_modl_name:e.model?.id||"unknown",sage_modl_option:{temperature:String(p),max_token_size:String(e.model?.maxTokens||16834),top_p:String(u)}},rag_info:{type:null,account_name:"dummy",project_names:[],repository_names:[],programming_language:null},tab_data:{tab_count:"1"},tags:null,slingshot_version:ns.slingVersion||"2.3.2",chat_type:"agent",...n||{}};return{headers:d,sageCommonData:h}}async function go(i,e,t,n){let s={eventName:i,sageCommonData:t,eventData:n};try{let o=await fetch(Pp,{method:"POST",headers:e,body:JSON.stringify(s)});if(o.ok){let r=await o.json().catch(()=>{});if(r.error_code)throw new Error(`Analytics API error: ${r.error_code} - ${r.error_message||"No message"}`);yt()&&(Ie(`'SUCCESS: Event sent: ${i}`),Ie(`Response: ${JSON.stringify(r)}`),Ie("\u2500".repeat(66)))}else{let r=await o.text().catch(()=>""),a={status:o.status,statusText:o.statusText,responseBody:r,requestHeaders:e};throw yt()&&(Ie(`ERROR: ${o.status} ${o.statusText}`),mo("Error Details",a),mo("Failed Request Body",s)),new Error(`Analytics API error: ${o.status} ${o.statusText}`)}}catch(o){let r=o instanceof Error?o.message:String(o);console.warn("[Slingshot Analytics] Request that caused error:",r),yt()&&(Ie(`EXCEPTION: ${r}`),o instanceof Error&&o.stack&&Ie(`Stack trace: ${o.stack}`),mo("Request that caused exception",s))}}import is from"chalk";function Bp(i,e){return{render(t){let n=` \u26AC _______. __ __ .__ __. _______
80
80
  \u274D \xB7 \u274D / || | | | | \\ | | / _____|
81
81
  \u2726 \u26AC \u2726 | (----\`| | | | | \\| | | | __
82
82
  \u26AC \xB7 \u26AC \u26AC \xB7 \u26AC \\ \\ | | | | | . \` | | | |_ |