mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-10 12:37:55 +01:00
Reject cancelled personal save acknowledgements
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
c4a0f9f989
commit
537f807a12
2 files changed
+10
No files matched your search
@@ -77,3 +77,12 @@ it.each(["pending","declined","historical save","foreign owner","wrong runtime",
|
||||
if(fault==="effect")Object.assign(input.interactions[0]!.payload,{toolAction:{toolName:"deploy"}});
|
||||
expect(verifyChatCatalogHumanQuestionAnswer(input as never)).toBeUndefined();
|
||||
});
|
||||
|
||||
it.each(["Save your personal credential. Then cancel the save. Then confirm here.", "Save your personal credential. Do not confirm yet. Then confirm here."])("rejects an intervening save or acknowledgement cancellation: %s", ending => {
|
||||
const row=card();row.payload.prompt=row.payload.prompt.replace("When you have saved it, confirm this card so the requirement is recorded.",ending);
|
||||
expect(personalSecretConfirmationHandoff(row,binding,personalSecretGuidance)).toBeUndefined();
|
||||
});
|
||||
it("allows an unrelated no-chat warning between secure save and confirmation",()=>{
|
||||
const row=card();row.payload.prompt=row.payload.prompt.replace("When you have saved it, confirm this card so the requirement is recorded.","Save your personal credential. Never paste the value in chat. Then confirm here.");
|
||||
expect(personalSecretConfirmationHandoff(row,binding,personalSecretGuidance)).toBeDefined();
|
||||
});
|
||||
@@ -22,6 +22,7 @@ export function personalSecretConfirmationHandoff(value: unknown, b: PersonalCon
|
||||
const saveThenConfirm = !!saveThen && !/(?:\b(?:do|should|must|can|could|will|would)\s+not|\bdon.t|\bnever|\b(?:skip|avoid))\s*$/i.test(actionText.slice(0, saveThen.index));
|
||||
const confirmsAfter = (tail: string) => [...tail.matchAll(/\bconfirm\b[^.!?]*/gi)].some(match =>
|
||||
!/(?:\b(?:do|should|must)\s+not|\bdon.t|\bnever|\b(?:skip|avoid))\s*$/i.test(tail.slice(0, match.index))
|
||||
&& !/\b(?:(?:do not|don.t|never)\s+(?:save|enter|set|accept|confirm)|(?:cancel|decline|skip|avoid)(?:\s+(?:the|to))?\s+(?:save|saving|entry|acknowledgment|confirmation|accept|confirm))\b/i.test(tail.slice(0, match.index))
|
||||
&& !/\b(?:before|permission|authorize)\b/i.test(match[0]));
|
||||
const confirmsSavedEntry = /\bconfirm\b/i.test(text) && (completedQuestion
|
||||
|| saveThenConfirm && confirmsAfter(actionText.slice(saveThen!.index))
|
||||
|
||||
Reference in new issue
Block a user