@wrongstack/plugin-sdk 1.0.10 → 1.0.11
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/runtime/index.d.ts +8 -8
- package/dist/runtime/sandbox.js +2 -2
- package/dist/runtime.js +67 -67
- package/package.json +3 -3
package/dist/runtime/index.d.ts
CHANGED
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
* Anything language-specific (flag tables, default commands,
|
|
29
29
|
* output parsing) stays in the plugin that owns that language.
|
|
30
30
|
*/
|
|
31
|
-
export {
|
|
32
|
-
export { BoundedMap,
|
|
33
|
-
export {
|
|
34
|
-
export { UNSERIALIZABLE, safeJsonStringify } from './safe-json.js';
|
|
35
|
-
export { releaseHandle, releaseHandles, type Unregister } from './handles.js';
|
|
36
|
-
export { withReDoSGuard, guardedMatcher, type ReDoSResult, type ReDoSOptions, } from './redos-guard.js';
|
|
37
|
-
export { safePath, isInsideProject, type SafePathOptions, } from './sandbox.js';
|
|
31
|
+
export { type OptionalCouncilRequest, type OptionalLlmRequest, type OptionalLlmResult, parseLlmJsonObject, runOptionalPluginCouncil, runOptionalPluginLlm, stripOuterMarkdownFence, } from './llm.js';
|
|
32
|
+
export { BoundedMap, type BoundedMapOptions, BoundedSet } from './bounded-map.js';
|
|
33
|
+
export { CREDENTIAL_PATTERNS, type CredentialPattern, cloneCredentialPatterns, } from './credential-patterns.js';
|
|
38
34
|
export { createH1State, type H1State, } from './h1-state.js';
|
|
39
|
-
export {
|
|
35
|
+
export { releaseHandle, releaseHandles, type Unregister } from './handles.js';
|
|
36
|
+
export { clearLocalBinCache, type ExecInvocation, findOnPath, type ResolvedNodeBin, resolveExecInvocation, resolveFirstNodeBin, resolveNodeBin, resolveWin32Command, } from './local-bin.js';
|
|
37
|
+
export { guardedMatcher, type ReDoSOptions, type ReDoSResult, withReDoSGuard, } from './redos-guard.js';
|
|
38
|
+
export { safeJsonStringify, UNSERIALIZABLE } from './safe-json.js';
|
|
39
|
+
export { isInsideProject, type SafePathOptions, safePath, } from './sandbox.js';
|
|
40
40
|
export type LanguageId = 'typescript' | 'javascript' | 'python' | 'go' | 'rust' | 'shell' | 'ruby' | 'java' | 'kotlin' | 'dotnet' | 'generic';
|
|
41
41
|
export type PackageManagerId = 'npm' | 'pnpm' | 'yarn' | 'bun' | 'pip' | 'poetry' | 'go' | 'cargo' | 'gem' | 'maven' | 'gradle' | 'dotnet' | 'none';
|
|
42
42
|
export interface LanguageRuntime {
|
package/dist/runtime/sandbox.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/runtime/sandbox.ts
|
|
2
2
|
import { realpathSync } from "node:fs";
|
|
3
|
-
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
3
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
var MAX_PATH_BYTES = 4096;
|
|
5
5
|
function safePath(input, options = {}) {
|
|
6
6
|
if (typeof input !== "string") return null;
|
|
@@ -36,7 +36,7 @@ function realpathWithMissingLeaf(candidate) {
|
|
|
36
36
|
function withinLexical(projectRoot, candidate) {
|
|
37
37
|
const rel = relative(projectRoot, candidate);
|
|
38
38
|
if (rel === "" || rel === ".") return true;
|
|
39
|
-
if (rel.startsWith(
|
|
39
|
+
if (rel === ".." || rel.startsWith(`..${sep}`)) return false;
|
|
40
40
|
if (isAbsolute(rel)) return false;
|
|
41
41
|
return true;
|
|
42
42
|
}
|
package/dist/runtime.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/runtime/index.ts
|
|
2
2
|
import { execFile } from "node:child_process";
|
|
3
3
|
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
4
|
-
import { basename as basename2, extname as extname2, isAbsolute as isAbsolute3, relative as relative3, resolve as resolve3 } from "node:path";
|
|
4
|
+
import { basename as basename2, extname as extname2, isAbsolute as isAbsolute3, relative as relative3, resolve as resolve3, sep as sep3 } from "node:path";
|
|
5
5
|
import { buildChildEnv } from "@wrongstack/core/utils/child-env";
|
|
6
6
|
|
|
7
7
|
// src/runtime/llm.ts
|
|
@@ -494,27 +494,46 @@ function cloneCredentialPatterns() {
|
|
|
494
494
|
}));
|
|
495
495
|
}
|
|
496
496
|
|
|
497
|
-
// src/runtime/
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
497
|
+
// src/runtime/h1-state.ts
|
|
498
|
+
function createH1State(initial) {
|
|
499
|
+
const handles = /* @__PURE__ */ new Map();
|
|
500
|
+
const safeRelease = (unregister) => {
|
|
501
|
+
try {
|
|
502
|
+
unregister();
|
|
503
|
+
} catch {
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
return {
|
|
507
|
+
state: initial,
|
|
508
|
+
register(key, unregister) {
|
|
509
|
+
const prior = handles.get(key);
|
|
510
|
+
if (prior) {
|
|
511
|
+
safeRelease(prior);
|
|
512
|
+
handles.delete(key);
|
|
513
|
+
}
|
|
514
|
+
if (unregister) {
|
|
515
|
+
handles.set(key, unregister);
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
release(key) {
|
|
519
|
+
const prior = handles.get(key);
|
|
520
|
+
if (!prior) return;
|
|
521
|
+
handles.delete(key);
|
|
522
|
+
safeRelease(prior);
|
|
523
|
+
},
|
|
524
|
+
releaseAll() {
|
|
525
|
+
for (const unregister of handles.values()) {
|
|
526
|
+
safeRelease(unregister);
|
|
527
|
+
}
|
|
528
|
+
handles.clear();
|
|
529
|
+
},
|
|
530
|
+
size() {
|
|
531
|
+
return handles.size;
|
|
532
|
+
},
|
|
533
|
+
keys() {
|
|
534
|
+
return [...handles.keys()];
|
|
535
|
+
}
|
|
536
|
+
};
|
|
518
537
|
}
|
|
519
538
|
|
|
520
539
|
// src/runtime/handles.ts
|
|
@@ -625,9 +644,32 @@ function guardedMatcher(re, budgetMs = 50, onTimeout) {
|
|
|
625
644
|
return (input) => withReDoSGuard(re, input, budgetMs, onTimeout ? { onTimeout } : {});
|
|
626
645
|
}
|
|
627
646
|
|
|
647
|
+
// src/runtime/safe-json.ts
|
|
648
|
+
var UNSERIALIZABLE = "[unserializable]";
|
|
649
|
+
function safeJsonStringify(value, indent) {
|
|
650
|
+
try {
|
|
651
|
+
const stack = [];
|
|
652
|
+
const out = JSON.stringify(
|
|
653
|
+
value,
|
|
654
|
+
function replacer(_key, val) {
|
|
655
|
+
if (typeof val === "bigint") return `${val.toString()}n`;
|
|
656
|
+
if (val === null || typeof val !== "object") return val;
|
|
657
|
+
while (stack.length > 0 && stack[stack.length - 1] !== this) stack.pop();
|
|
658
|
+
if (stack.includes(val)) return "[circular]";
|
|
659
|
+
stack.push(val);
|
|
660
|
+
return val;
|
|
661
|
+
},
|
|
662
|
+
indent
|
|
663
|
+
);
|
|
664
|
+
return out ?? String(value);
|
|
665
|
+
} catch {
|
|
666
|
+
return UNSERIALIZABLE;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
628
670
|
// src/runtime/sandbox.ts
|
|
629
671
|
import { realpathSync } from "node:fs";
|
|
630
|
-
import { basename, dirname as dirname2, isAbsolute as isAbsolute2, join as join2, relative as relative2, resolve as resolve2 } from "node:path";
|
|
672
|
+
import { basename, dirname as dirname2, isAbsolute as isAbsolute2, join as join2, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
|
|
631
673
|
var MAX_PATH_BYTES = 4096;
|
|
632
674
|
function safePath(input, options = {}) {
|
|
633
675
|
if (typeof input !== "string") return null;
|
|
@@ -663,7 +705,7 @@ function realpathWithMissingLeaf(candidate) {
|
|
|
663
705
|
function withinLexical(projectRoot, candidate) {
|
|
664
706
|
const rel = relative2(projectRoot, candidate);
|
|
665
707
|
if (rel === "" || rel === ".") return true;
|
|
666
|
-
if (rel.startsWith(
|
|
708
|
+
if (rel === ".." || rel.startsWith(`..${sep2}`)) return false;
|
|
667
709
|
if (isAbsolute2(rel)) return false;
|
|
668
710
|
return true;
|
|
669
711
|
}
|
|
@@ -671,48 +713,6 @@ function isInsideProject(input, options = {}) {
|
|
|
671
713
|
return safePath(input, options) !== null;
|
|
672
714
|
}
|
|
673
715
|
|
|
674
|
-
// src/runtime/h1-state.ts
|
|
675
|
-
function createH1State(initial) {
|
|
676
|
-
const handles = /* @__PURE__ */ new Map();
|
|
677
|
-
const safeRelease = (unregister) => {
|
|
678
|
-
try {
|
|
679
|
-
unregister();
|
|
680
|
-
} catch {
|
|
681
|
-
}
|
|
682
|
-
};
|
|
683
|
-
return {
|
|
684
|
-
state: initial,
|
|
685
|
-
register(key, unregister) {
|
|
686
|
-
const prior = handles.get(key);
|
|
687
|
-
if (prior) {
|
|
688
|
-
safeRelease(prior);
|
|
689
|
-
handles.delete(key);
|
|
690
|
-
}
|
|
691
|
-
if (unregister) {
|
|
692
|
-
handles.set(key, unregister);
|
|
693
|
-
}
|
|
694
|
-
},
|
|
695
|
-
release(key) {
|
|
696
|
-
const prior = handles.get(key);
|
|
697
|
-
if (!prior) return;
|
|
698
|
-
handles.delete(key);
|
|
699
|
-
safeRelease(prior);
|
|
700
|
-
},
|
|
701
|
-
releaseAll() {
|
|
702
|
-
for (const unregister of handles.values()) {
|
|
703
|
-
safeRelease(unregister);
|
|
704
|
-
}
|
|
705
|
-
handles.clear();
|
|
706
|
-
},
|
|
707
|
-
size() {
|
|
708
|
-
return handles.size;
|
|
709
|
-
},
|
|
710
|
-
keys() {
|
|
711
|
-
return [...handles.keys()];
|
|
712
|
-
}
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
|
-
|
|
716
716
|
// src/runtime/index.ts
|
|
717
717
|
var META_CHARS = /["'`;&|<>\r\n]/;
|
|
718
718
|
var MAX_BUFFER_BYTES = 16 * 1024 * 1024;
|
|
@@ -729,7 +729,7 @@ function withinProjectPath(projectRoot, candidate) {
|
|
|
729
729
|
if (hasLeadingDash(candidate)) return false;
|
|
730
730
|
const resolved = isAbsolute3(candidate) ? resolve3(candidate) : resolve3(projectRoot, candidate);
|
|
731
731
|
const rel = relative3(projectRoot, resolved);
|
|
732
|
-
return rel === "" || !rel.startsWith(
|
|
732
|
+
return rel === "" || rel !== ".." && !rel.startsWith(`..${sep3}`) && !isAbsolute3(rel);
|
|
733
733
|
}
|
|
734
734
|
function everyFlagAllowed(allowed, args) {
|
|
735
735
|
for (const arg of args) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wrongstack/plugin-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "Authoring SDK for WrongStack plugins — the plugin contract types, definePlugin, and shared runtime helpers. Third-party plugins should depend on this package only.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ECOSTACK TECHNOLOGY OÜ",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"vitest": "^5.0.0"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@wrongstack/core": "1.0.
|
|
69
|
-
"@wrongstack/tools": "1.0.
|
|
68
|
+
"@wrongstack/core": "1.0.11",
|
|
69
|
+
"@wrongstack/tools": "1.0.11"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "node ../../scripts/build-package.mjs",
|