paseo-plugin-secure-input 0.2.2 → 0.4.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.
@@ -17,8 +17,17 @@ export interface ToolAgent {
17
17
  provider: string;
18
18
  cwd: string;
19
19
  title: string | null;
20
+ /** Paseo 0.16 and newer: a helper with no tab, no notification and no place in the sidebar. Absent before. */
21
+ background?: boolean;
20
22
  }
21
23
 
24
+ /**
25
+ * A background agent's chat is out of sight: no tab, no notification. A form posted there would wait for an answer
26
+ * nobody can give, so the request is refused at once and the agent is sent to whoever started it.
27
+ */
28
+ export const BACKGROUND_AGENT =
29
+ "you run as a background agent, whose chat nobody sees, so no one can fill in a form for you. Ask the agent or person that started you to request the values and pass you the file paths";
30
+
22
31
  /** The names of the plugin's tools. A tool of one of these names that comes with a session is an older one of its own. */
23
32
  export const TOOL_NAMES = ["request_secret", "request_status", "cancel_request", "release_secret"] as const;
24
33
 
@@ -47,7 +56,7 @@ const REQUEST_SECRET =
47
56
  'It returns at once with status "pending": end your turn, and a message with the paths arrives when the user has submitted. Do not poll. ' +
48
57
  "Never read, print, open, compare or log a file or directory whose name starts with si-secret-. " +
49
58
  "Move each value where it belongs without reading it (`command < PATH`, `cp PATH DESTINATION`), then delete the directory or call release_secret. " +
50
- `The files are deleted at the end of the turn the message starts, and ${MINUTES} minutes after they were written at the latest.`;
59
+ `The files are deleted at the end of the turn the delivery message starts, or at the end of your next turn if it joins a running turn, and ${MINUTES} minutes after they were written at the latest.`;
51
60
 
52
61
  const REQUEST_STATUS =
53
62
  "The state of one of your requests, its keys and whether a second submission reached it; while its files exist, the path of each file and when they are deleted. Never returns values. " +
@@ -126,7 +135,11 @@ export function agentTools({ registry, runtime, started, drop }: ToolDeps): Agen
126
135
  description: REQUEST_SECRET,
127
136
  input: SecretRequestShape,
128
137
  // The shape is what the daemon checks a call against; the registry holds the input to the whole request schema.
129
- execute: (input, { agent, paseo, signal }) => answer(paseo, () => registry.create(identityOf(agent), input, { signal })),
138
+ execute: (input, { agent, paseo, signal }) =>
139
+ answer(paseo, () => {
140
+ if ((agent as ToolAgent).background === true) throw new SecureInputError("invalid_request", BACKGROUND_AGENT);
141
+ return registry.create(identityOf(agent), input, { signal });
142
+ }),
130
143
  }),
131
144
  defineAgentTool({
132
145
  name: "request_status",
package/shared/limits.ts CHANGED
@@ -26,10 +26,10 @@ export const LIMITS = {
26
26
  export const DROP_TTL_MS = 900_000;
27
27
 
28
28
  /** The version of the plugin, as the settings screen says it. `tests/mirrored-constants.test.ts` holds it equal to the version in `package.json`. */
29
- export const PLUGIN_VERSION = "0.2.2";
29
+ export const PLUGIN_VERSION = "0.4.0";
30
30
 
31
31
  /** The release of Paseo the plugin needs, as the settings screen says it. The same test holds it to the requirement in `paseo-plugin.json`. */
32
- export const PASEO_SINCE = "Paseo 0.14+";
32
+ export const PASEO_SINCE = "Paseo 0.15+";
33
33
 
34
34
  /**
35
35
  * The most bytes one Paseo RPC message may have on its way from either app to the daemon: the smallest limit on that
@@ -11,7 +11,8 @@ When you need a secret, make a request instead of asking in chat. The user fills
11
11
 
12
12
  - **Never ask for a secret in chat.** Not "paste it here", not "export it and tell me", not "put it in `.env` yourself". Make a request.
13
13
  - **Never let a `si-secret-` file's content reach you.** Never read, print, open, compare, hash, measure or log a file or directory whose name starts with `si-secret-`, and never pass its content as an argument: no `cat PATH`, `head`, `less`, `grep`, `diff`, `wc`, `xxd`, `base64`, no editor or file viewer, and no `ls -l` of its files. Such a path may stand in a command only after `<`, as the source of `cp`, or after `rm -r`: a value moves by redirection or by copy, and a command that reads it from its stdin into its destination, `cat` included, moves it blind.
14
- - **Move, then delete or release.** Move every value in the turn the message starts. Then delete the directory, as the message shows, or call `release_secret`. At the end of that turn the plugin deletes the files anyway.
14
+ - **Move, then delete or release.** Move every value in the turn when you receive the delivery message. Then delete the directory, as the message shows, or call `release_secret`. The plugin deletes the files when the turn started by the message ends. If the message joined a running turn, the files go when your next turn ends, or at their deadline if sooner.
15
+ - **Keep a delegated move inside your turn.** The files can go when your turn ends, even while a subagent you started is still working. Move the value yourself, or wait for the subagent before you end the turn. Your requests are not its requests: `request_status` and `release_secret` answer it as if they did not exist. A subagent that needs a value after your turn makes a request of its own.
15
16
  - **Do not poll.** A request answers `End your turn now. You will receive a message when the user has submitted. Do not poll.` Do that. Call `request_status` once, and only when the user says they submitted and no message came, or that no form appeared.
16
17
  - **Say the reason yourself.** The form shows neither your reason nor your labels. In your own message, tell the user what you need, why, and that the form opens from the pill in this chat.
17
18
  - **A plugin that is down is no reason to take a secret in chat.** When the tool is missing, or keeps answering `service_unavailable`, tell the user and stop.
@@ -135,7 +136,7 @@ ssh HOST 'umask 077; mkdir -p ~/.config/app && touch ~/.config/app/token && chmo
135
136
 
136
137
  `request_status` gives `state`, `keys`, `written`, `tamper` and `errorCode`, and while the files exist, `files` (key → path) and `deleteBy`. Never a value. If it says `delivered`, move the files at those paths as you would from the message, each quoted for the shell first. If it says `pending`, the form is still waiting: the user has not submitted, or the form refused what they sent and shows why. Either way the pill in this chat opens it; do not cancel and ask again, or the user types everything twice.
137
138
 
138
- Nothing comes when the files go the ordinary way: when you delete them or call `release_secret`, or at the end of your turn. A request you cancel ends without a message.
139
+ Nothing comes when the files go the ordinary way: when you delete them or call `release_secret`, or at the end of your turn. A request you cancel ends without a message. When you are archived, your open requests close and their files go, also without a message; if you are brought back, make a new request.
139
140
 
140
141
  ## When a request is refused at once
141
142
 
@@ -143,7 +144,7 @@ The tool answers with an error whose text is `{"error": "<code>", "message": "<c
143
144
 
144
145
  | `error` | Do |
145
146
  |---|---|
146
- | `invalid_request` | The message says what is wrong. A member of your request: fix it. `unknown request`: the id is not one of your requests. `the request has no files to release`: it was never delivered |
147
+ | `invalid_request` | The message says what is wrong. A member of your request: fix it. `unknown request`: the id is not one of your requests. `the request has no files to release`: it was never delivered. `you run as a background agent…`: nobody sees your chat, so do not retry and do not ask in chat; tell the agent or person that started you which keys you need, and let them request the values and pass you the file paths |
147
148
  | `request_already_pending` | The message is the id of your pending request. Wait for it. `cancel_request` it only when its values are no longer needed, never to make room for a new request: the user would type everything again |
148
149
  | `request_closed` | `cancel_request` on a request that no longer waits. `request_status` shows its state |
149
150
  | `service_unavailable` | `the plugin has not finished starting; retry in a few seconds`: retry, twice at most. `the plugin is busy; retry in a few seconds`: nothing of the call was done; retry, twice at most, then tell the user. `the plugin did not start (…). Tell the user. Do not ask for the secret in chat instead.`: do that. `the plugin is shutting down`: tell the user. `the request could not be handled`: the plugin failed over the call; ask once more, and if that answers `request_already_pending`, wait for that request |
package/client/text.ts DELETED
@@ -1,47 +0,0 @@
1
- /** Which of three forms a count takes in Ukrainian: 1, 21, 101 take the first; 2-4, 22-24 the second; the rest, and 11-14, the third. */
2
- function formFor<Form>(count: number, one: Form, few: Form, many: Form): Form {
3
- const tens = count % 100;
4
- const units = count % 10;
5
- if (units === 1 && tens !== 11) return one;
6
- if (units >= 2 && units <= 4 && (tens < 12 || tens > 14)) return few;
7
- return many;
8
- }
9
-
10
- /** Ukrainian plural: the count and the form of the noun that goes with it. */
11
- export function plural(count: number, one: string, few: string, many: string): string {
12
- return `${count} ${formFor(count, one, few, many)}`;
13
- }
14
-
15
- /** «1 байт», «2 байти», «5 байтів»: wherever a size is shown, it is said this way. */
16
- export function bytesText(count: number): string {
17
- return plural(count, "байт", "байти", "байтів");
18
- }
19
-
20
- /** One to ten of something feminine, as it is said: «три спроби», and «після трьох спроб». A number past the list is written in digits. */
21
- const FEMININE_COUNT: ReadonlyArray<{ nominative: string; genitive: string }> = [
22
- { nominative: "одна", genitive: "однієї" },
23
- { nominative: "дві", genitive: "двох" },
24
- { nominative: "три", genitive: "трьох" },
25
- { nominative: "чотири", genitive: "чотирьох" },
26
- { nominative: "п'ять", genitive: "п'яти" },
27
- { nominative: "шість", genitive: "шести" },
28
- { nominative: "сім", genitive: "семи" },
29
- { nominative: "вісім", genitive: "восьми" },
30
- { nominative: "дев'ять", genitive: "дев'яти" },
31
- { nominative: "десять", genitive: "десяти" },
32
- ];
33
-
34
- /**
35
- * «Три спроби не вдались»: how many attempts failed, as the start of a sentence. The number is the limit the plugin
36
- * counts to (`MAX_RETRIES`), so the sentence is built from it and cannot say another number than the plugin means.
37
- */
38
- export function attemptsFailed(count: number): string {
39
- const word = FEMININE_COUNT[count - 1]?.nominative ?? String(count);
40
- return `${word.charAt(0).toUpperCase()}${word.slice(1)} ${formFor(count, "спроба не вдалась", "спроби не вдались", "спроб не вдалось")}`;
41
- }
42
-
43
- /** «Після трьох невдалих спроб»: after how many failed attempts something happens. */
44
- export function afterFailedAttempts(count: number): string {
45
- const word = FEMININE_COUNT[count - 1]?.genitive ?? String(count);
46
- return `Після ${word} ${formFor(count, "невдалої спроби", "невдалих спроб", "невдалих спроб")}`;
47
- }