@magpie-community/opencode-agy-tui-auth 0.0.0-stage → 0.1.4
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/LICENSE +24 -0
- package/README.en.md +31 -0
- package/README.md +30 -2
- package/agy-version.mjs +16 -0
- package/default-agent.mjs +131 -0
- package/index.mjs +843 -0
- package/live.mjs +143 -0
- package/login.mjs +116 -0
- package/opencode.mjs +4 -0
- package/opencode2.mjs +634 -0
- package/package.json +45 -4
- package/tool-gate.mjs +18 -0
package/tool-gate.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// A copy of packages/agy-cli/tool-gate.mjs: a change to one goes to the other.
|
|
2
|
+
// agy's PreToolUse hook for a session on agy's default agent (default-agent.mjs).
|
|
3
|
+
// agy runs it before every tool call with the call as JSON on stdin; the
|
|
4
|
+
// arguments are the tool names the session may call, a trailing * matching a
|
|
5
|
+
// prefix. Any other call is denied, and agy fails it without running it.
|
|
6
|
+
// Nothing but node:fs: it runs twice for every call.
|
|
7
|
+
import fs from "node:fs"
|
|
8
|
+
|
|
9
|
+
const allowed = process.argv.slice(2)
|
|
10
|
+
let name = ""
|
|
11
|
+
try {
|
|
12
|
+
const input = JSON.parse(fs.readFileSync(0, "utf8"))
|
|
13
|
+
if (typeof input?.toolCall?.name === "string") name = input.toolCall.name
|
|
14
|
+
} catch {}
|
|
15
|
+
const ok = !!name && allowed.some((pattern) => pattern.endsWith("*") ? name.startsWith(pattern.slice(0, -1)) : name === pattern)
|
|
16
|
+
process.stdout.write(JSON.stringify(ok
|
|
17
|
+
? { decision: "allow" }
|
|
18
|
+
: { decision: "deny", reason: `${name || "This tool"} is turned off in this session. Use only the tools you were given.` }))
|