@eddyskywalker/dsh-chatgpt-subscription 0.1.0-alpha.0 → 0.1.0
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/CHANGELOG.md +6 -0
- package/lib/index.js +34 -3
- package/lib/types/host/responses-mapper.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -637,6 +637,7 @@ async function buildResponsesPayload(options, attachments) {
|
|
|
637
637
|
options.system?.trim(),
|
|
638
638
|
...options.messages.filter((message) => message.role === "system").map((message) => blocksToText(message.content).trim()),
|
|
639
639
|
sandboxToolInstruction(options.tools, sandboxRetryTools),
|
|
640
|
+
commandToolInstruction(options.tools),
|
|
640
641
|
runCodeInstruction(options.tools)
|
|
641
642
|
].filter((value) => Boolean(value));
|
|
642
643
|
const input = [];
|
|
@@ -713,8 +714,18 @@ function runCodeInstruction(tools) {
|
|
|
713
714
|
return "run_code compatibility rule: its code is parsed as strict JavaScript/TypeScript before execution. On Windows, do not embed PowerShell containing $, ${...}, backslashes, or here-strings in JavaScript template literals; String.raw does not disable ${...} interpolation. Prefer arrays of ordinary quoted strings joined with \"\\n\", escaping backslashes, or use a file-write tool for large scripts and then invoke pwsh.";
|
|
714
715
|
}
|
|
715
716
|
function toolDescriptionForCodex(name, description) {
|
|
716
|
-
if (name
|
|
717
|
-
return `${description}\n\
|
|
717
|
+
if (name === "run_code") return `${description}\n\nCompatibility: code is strict JavaScript/TypeScript. When composing PowerShell, avoid JavaScript template literals containing $, \${...}, Windows backslashes, or PowerShell here-strings. Prefer ordinary quoted string arrays joined with "\\n", or write a script file with a dedicated file tool before invoking pwsh.`;
|
|
718
|
+
if (isCommandTool(name)) return `${description}\n\n${commandToolCompatibilityText(name)}`;
|
|
719
|
+
return description;
|
|
720
|
+
}
|
|
721
|
+
function commandToolInstruction(tools) {
|
|
722
|
+
const names = tools?.filter((tool) => isCommandTool(tool.name)).map((tool) => tool.name);
|
|
723
|
+
if (!names?.length) return void 0;
|
|
724
|
+
return `Command tool compatibility rule (${[...new Set(names)].join(", ")}): each command call runs in a fresh process, so do not rely on cd, aliases, functions, or variables from previous calls; set workdir when the tool supports it. On Windows/pwsh, keep commands in native PowerShell syntax and native Windows paths. For deletion or move operations, first resolve and verify exact absolute target paths, then operate on those literal paths only; avoid dynamically deleting paths built from $HOME, wildcards, command substitution, or another shell's output. Treat [auto-mode hard deny] and similar policy denials as non-retriable; choose a safer non-destructive inspection or report the limitation instead of repeating the same command or adding sandbox escalation. If downloads fail with TLS credential or connection-closed errors, treat that as an environment/network failure and use local sources or report the limitation instead of cycling through equivalent download commands.`;
|
|
725
|
+
}
|
|
726
|
+
function commandToolCompatibilityText(name) {
|
|
727
|
+
const shell = name.toLowerCase();
|
|
728
|
+
return `Compatibility: command execution is stateless between calls.${shell === "pwsh" || shell.includes("powershell") ? " Use native PowerShell syntax and native Windows paths; prefer workdir over cd because every call starts a fresh process." : " Prefer workdir over cd because every call starts a fresh process."} For destructive operations, verify exact absolute targets first and use literal paths; policy hard-deny results require a safer command shape, not sandbox escalation.`;
|
|
718
729
|
}
|
|
719
730
|
function sandboxToolInstruction(tools, sandboxRetryTools) {
|
|
720
731
|
if (!tools?.some((tool) => hasSandboxControls(tool.parameters))) return void 0;
|
|
@@ -723,7 +734,8 @@ function sandboxToolInstruction(tools, sandboxRetryTools) {
|
|
|
723
734
|
}
|
|
724
735
|
function toolParametersForCodex(toolName, parameters, allowSandboxRetry) {
|
|
725
736
|
const hideSandboxControls = !allowSandboxRetry && hasSandboxControls(parameters);
|
|
726
|
-
|
|
737
|
+
const augmentCommandTool = isCommandTool(toolName);
|
|
738
|
+
if (!hideSandboxControls && toolName !== "run_code" && !augmentCommandTool) return parameters;
|
|
727
739
|
const cloned = structuredClone(parameters);
|
|
728
740
|
const properties = record$2(cloned.properties);
|
|
729
741
|
if (properties !== null && hideSandboxControls) {
|
|
@@ -739,8 +751,27 @@ function toolParametersForCodex(toolName, parameters, allowSandboxRetry) {
|
|
|
739
751
|
code.description = current ? `${current}\n\n${compatibility}` : compatibility;
|
|
740
752
|
}
|
|
741
753
|
}
|
|
754
|
+
if (augmentCommandTool && properties !== null) {
|
|
755
|
+
appendPropertyDescription(properties.command, "Single command for a fresh process; do not rely on state from earlier calls.");
|
|
756
|
+
appendPropertyDescription(properties.workdir, "Use a native absolute working directory instead of embedding cd in the command.");
|
|
757
|
+
appendPropertyDescription(properties.timeoutMs, "Positive finite timeout in milliseconds for bounded commands.");
|
|
758
|
+
appendPropertyDescription(properties.run_in_background, "Use only for long-running servers or watchers whose output will be checked later.");
|
|
759
|
+
appendPropertyDescription(properties.sandbox_permissions, "Only set when retrying the exact previous sandbox-denied call; it does not bypass hard-deny policy results.");
|
|
760
|
+
appendPropertyDescription(properties.justification, "Required only for an allowed sandbox retry; explain why the wider access is needed.");
|
|
761
|
+
}
|
|
742
762
|
return cloned;
|
|
743
763
|
}
|
|
764
|
+
function appendPropertyDescription(value, addition) {
|
|
765
|
+
const property = record$2(value);
|
|
766
|
+
if (property === null) return;
|
|
767
|
+
const current = typeof property.description === "string" ? property.description.trim() : "";
|
|
768
|
+
if (current.includes(addition)) return;
|
|
769
|
+
property.description = current ? `${current}\n\n${addition}` : addition;
|
|
770
|
+
}
|
|
771
|
+
function isCommandTool(name) {
|
|
772
|
+
const normalized = name.toLowerCase();
|
|
773
|
+
return normalized === "pwsh" || normalized === "powershell" || normalized === "bash" || normalized === "shell";
|
|
774
|
+
}
|
|
744
775
|
function hasSandboxControls(parameters) {
|
|
745
776
|
const properties = record$2(parameters.properties);
|
|
746
777
|
return properties !== null && ("sandbox_permissions" in properties || "justification" in properties);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses-mapper.d.ts","sourceRoot":"","sources":["../../../src/host/responses-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,6BAA6B,CAAA;AACtF,OAAO,KAAK,EAAgB,eAAe,EAAW,MAAM,sBAAsB,CAAA;AAElF,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/D,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACrC,MAAM,EAAE,IAAI,CAAA;IACZ,KAAK,EAAE,KAAK,CAAA;CACb;AAED,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,CAKnF;AAED,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,GAC9C,OAAO,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"responses-mapper.d.ts","sourceRoot":"","sources":["../../../src/host/responses-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,6BAA6B,CAAA;AACtF,OAAO,KAAK,EAAgB,eAAe,EAAW,MAAM,sBAAsB,CAAA;AAElF,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/D,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACrC,MAAM,EAAE,IAAI,CAAA;IACZ,KAAK,EAAE,KAAK,CAAA;CACb;AAED,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,CAKnF;AAED,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,GAC9C,OAAO,CAAC,gBAAgB,CAAC,CAuF3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eddyskywalker/dsh-chatgpt-subscription",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "DSH provider plugin for Codex access through a ChatGPT subscription.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "eddyskywalker",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"type": "module",
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public",
|
|
29
|
-
"tag": "
|
|
29
|
+
"tag": "latest"
|
|
30
30
|
},
|
|
31
31
|
"main": "lib/index.js",
|
|
32
32
|
"types": "lib/types/index.d.ts",
|