mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-04 16:13:11 +00:00
feat(id): brand PermissionID, PtyID, QuestionID, and ToolID (#17042)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { test, expect } from "bun:test"
|
||||
import os from "os"
|
||||
import { PermissionNext } from "../../src/permission/next"
|
||||
import { PermissionID } from "../../src/permission/schema"
|
||||
import { Instance } from "../../src/project/instance"
|
||||
import { tmpdir } from "../fixture/fixture"
|
||||
import { SessionID } from "../../src/session/schema"
|
||||
@@ -522,7 +523,7 @@ test("reply - once resolves the pending ask", async () => {
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const askPromise = PermissionNext.ask({
|
||||
id: "permission_test1",
|
||||
id: PermissionID.make("per_test1"),
|
||||
sessionID: SessionID.make("session_test"),
|
||||
permission: "bash",
|
||||
patterns: ["ls"],
|
||||
@@ -532,7 +533,7 @@ test("reply - once resolves the pending ask", async () => {
|
||||
})
|
||||
|
||||
await PermissionNext.reply({
|
||||
requestID: "permission_test1",
|
||||
requestID: PermissionID.make("per_test1"),
|
||||
reply: "once",
|
||||
})
|
||||
|
||||
@@ -547,7 +548,7 @@ test("reply - reject throws RejectedError", async () => {
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const askPromise = PermissionNext.ask({
|
||||
id: "permission_test2",
|
||||
id: PermissionID.make("per_test2"),
|
||||
sessionID: SessionID.make("session_test"),
|
||||
permission: "bash",
|
||||
patterns: ["ls"],
|
||||
@@ -557,7 +558,7 @@ test("reply - reject throws RejectedError", async () => {
|
||||
})
|
||||
|
||||
await PermissionNext.reply({
|
||||
requestID: "permission_test2",
|
||||
requestID: PermissionID.make("per_test2"),
|
||||
reply: "reject",
|
||||
})
|
||||
|
||||
@@ -572,7 +573,7 @@ test("reply - always persists approval and resolves", async () => {
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const askPromise = PermissionNext.ask({
|
||||
id: "permission_test3",
|
||||
id: PermissionID.make("per_test3"),
|
||||
sessionID: SessionID.make("session_test"),
|
||||
permission: "bash",
|
||||
patterns: ["ls"],
|
||||
@@ -582,7 +583,7 @@ test("reply - always persists approval and resolves", async () => {
|
||||
})
|
||||
|
||||
await PermissionNext.reply({
|
||||
requestID: "permission_test3",
|
||||
requestID: PermissionID.make("per_test3"),
|
||||
reply: "always",
|
||||
})
|
||||
|
||||
@@ -613,7 +614,7 @@ test("reply - reject cancels all pending for same session", async () => {
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const askPromise1 = PermissionNext.ask({
|
||||
id: "permission_test4a",
|
||||
id: PermissionID.make("per_test4a"),
|
||||
sessionID: SessionID.make("session_same"),
|
||||
permission: "bash",
|
||||
patterns: ["ls"],
|
||||
@@ -623,7 +624,7 @@ test("reply - reject cancels all pending for same session", async () => {
|
||||
})
|
||||
|
||||
const askPromise2 = PermissionNext.ask({
|
||||
id: "permission_test4b",
|
||||
id: PermissionID.make("per_test4b"),
|
||||
sessionID: SessionID.make("session_same"),
|
||||
permission: "edit",
|
||||
patterns: ["foo.ts"],
|
||||
@@ -638,7 +639,7 @@ test("reply - reject cancels all pending for same session", async () => {
|
||||
|
||||
// Reject the first one
|
||||
await PermissionNext.reply({
|
||||
requestID: "permission_test4a",
|
||||
requestID: PermissionID.make("per_test4a"),
|
||||
reply: "reject",
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { test, expect } from "bun:test"
|
||||
import { Question } from "../../src/question"
|
||||
import { Instance } from "../../src/project/instance"
|
||||
import { QuestionID } from "../../src/question/schema"
|
||||
import { tmpdir } from "../fixture/fixture"
|
||||
import { SessionID } from "../../src/session/schema"
|
||||
|
||||
@@ -131,7 +132,7 @@ test("reply - does nothing for unknown requestID", async () => {
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
await Question.reply({
|
||||
requestID: "que_unknown",
|
||||
requestID: QuestionID.make("que_unknown"),
|
||||
answers: [["Option 1"]],
|
||||
})
|
||||
// Should not throw
|
||||
@@ -204,7 +205,7 @@ test("reject - does nothing for unknown requestID", async () => {
|
||||
await Instance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
await Question.reject("que_unknown")
|
||||
await Question.reject(QuestionID.make("que_unknown"))
|
||||
// Should not throw
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user