paseo-plugin-secure-input 0.3.0 → 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.
@@ -1,14 +1,15 @@
1
1
  import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
2
- import { useRpc } from "@getpaseo/plugin/client";
2
+ import { useRpc, useTranslation } from "@getpaseo/plugin/client";
3
3
  import { Icon, SettingsAction, SettingsCard, SettingsRow, SettingsSection } from "@getpaseo/plugin/client/ui";
4
4
  import { useQuery } from "@tanstack/react-query";
5
5
  import { useState, type ReactElement } from "react";
6
6
  import { ActivityIndicator, Text, View } from "react-native";
7
7
  import { clearDrop, readDiagnostics, selfTestBegin, selfTestFinish, type Diagnostics } from "../shared/contracts";
8
8
  import { PASEO_SINCE, PLUGIN_VERSION } from "../shared/limits";
9
- import { DELETE_ALL, DELETE_FAILED, SETTINGS_BADGE, canDeleteAll, dotColor, statusRows, type StatusRow } from "./diagnostics-rows";
9
+ import { SETTINGS_BADGE, canDeleteAll, dotColor, statusRows, type StatusRow } from "./diagnostics-rows";
10
10
  import { MONO } from "./fields";
11
- import { IDLE, RUNNING, SELF_TEST_RUNNING, runSelfTest, selfTestText, type SelfTestState } from "./self-test";
11
+ import { messages, type Translate } from "./messages";
12
+ import { IDLE, RUNNING, runSelfTest, selfTestText, type SelfTestState } from "./self-test";
12
13
  import { tone, type Tone } from "./tone";
13
14
 
14
15
  /** How often the state is read again while the screen is open: a set that arrives or goes shows without leaving the screen. */
@@ -34,7 +35,7 @@ function Header({ colors }: { colors: Tone }) {
34
35
  * submission can have. It runs on the press and not on the render. What a run comes to, and what is said of it, is
35
36
  * `self-test.ts`'s to decide; a spinner stands in the place of the result while it runs.
36
37
  */
37
- function Encryption({ colors }: { colors: Tone }) {
38
+ function Encryption({ t, colors }: { t: Translate; colors: Tone }) {
38
39
  const begin = useRpc(selfTestBegin);
39
40
  const finish = useRpc(selfTestFinish);
40
41
  const [state, setState] = useState<SelfTestState>(IDLE);
@@ -47,20 +48,20 @@ function Encryption({ colors }: { colors: Tone }) {
47
48
  }
48
49
 
49
50
  return (
50
- <SettingsSection title="Шифрування">
51
+ <SettingsSection title={t("settings.encryption")}>
51
52
  <SettingsCard>
52
53
  <View style={{ paddingHorizontal: 16, paddingVertical: 12, alignItems: "flex-start" }}>
53
54
  <View style={{ borderWidth: 1, borderColor: colors.border, borderRadius: 6, paddingHorizontal: 8, paddingVertical: 3 }}>
54
55
  <Text style={{ color: colors.accent, fontFamily: MONO, fontSize: 11 }}>{SETTINGS_BADGE}</Text>
55
56
  </View>
56
57
  </View>
57
- <SettingsAction label="Цей пристрій" actionLabel="Перевірити" disabled={running} onPress={() => void run()} />
58
+ <SettingsAction label={t("settings.thisDevice")} actionLabel={t("settings.check")} disabled={running} onPress={() => void run()} />
58
59
  {state.kind === "idle" ? null : (
59
- <SettingsRow label="Результат">
60
+ <SettingsRow label={t("settings.result")}>
60
61
  {running ? (
61
- <ActivityIndicator size="small" color={colors.muted} accessibilityLabel={SELF_TEST_RUNNING} />
62
+ <ActivityIndicator size="small" color={colors.muted} accessibilityLabel={t("selfTest.running")} />
62
63
  ) : (
63
- <Text style={{ color: state.kind === "passed" ? colors.success : colors.danger, fontFamily: MONO, fontSize: 12 }}>{selfTestText(state)}</Text>
64
+ <Text style={{ color: state.kind === "passed" ? colors.success : colors.danger, fontFamily: MONO, fontSize: 12 }}>{selfTestText(t, state)}</Text>
64
65
  )}
65
66
  </SettingsRow>
66
67
  )}
@@ -85,21 +86,21 @@ function StatusValue({ row, colors }: { row: StatusRow; colors: Tone }) {
85
86
  * The four rows. The explanation is under a red row only (`error` of the row). Read-only: the RPC behind it is open to
86
87
  * agents too. A failed reading leaves the last answer in `data`; it is shown, and said to be old, instead of passing for current.
87
88
  */
88
- function Status({ data, failed, colors }: { data: Diagnostics | undefined; failed: boolean; colors: Tone }) {
89
- const stale = <SettingsRow key="stale" label="Оновлення" error="Не вдалося оновити: показано попередній стан" />;
89
+ function Status({ t, data, failed, colors }: { t: Translate; data: Diagnostics | undefined; failed: boolean; colors: Tone }) {
90
+ const stale = <SettingsRow key="stale" label={t("settings.refresh")} error={t("settings.refreshFailed")} />;
90
91
  const rows: ReactElement[] =
91
92
  data === undefined
92
- ? [<SettingsRow key="reading" label={failed ? "Не вдалося прочитати стан плагіна" : "Завантаження…"} />]
93
+ ? [<SettingsRow key="reading" label={t(failed ? "settings.readFailed" : "settings.loading")} />]
93
94
  : [
94
95
  ...(failed ? [stale] : []),
95
- ...statusRows(data).map((row) => (
96
- <SettingsRow key={row.label} label={row.label} error={row.explanation}>
96
+ ...statusRows(t, data).map((row) => (
97
+ <SettingsRow key={row.label} label={t(row.label)} error={row.explanation}>
97
98
  <StatusValue row={row} colors={colors} />
98
99
  </SettingsRow>
99
100
  )),
100
101
  ];
101
102
  return (
102
- <SettingsSection title="Стан">
103
+ <SettingsSection title={t("settings.status")}>
103
104
  <SettingsCard>{rows}</SettingsCard>
104
105
  </SettingsSection>
105
106
  );
@@ -108,10 +109,10 @@ function Status({ data, failed, colors }: { data: Diagnostics | undefined; faile
108
109
  /**
109
110
  * Deletes every set of files at once, and reads the state again. What the plugin could not remove shows in the rows that
110
111
  * are read. When the clear call fails (the plugin is stopping, `drop/` could not be swept), earlier removals may have
111
- * succeeded; one fixed line under the button, `DELETE_FAILED`, says that it failed, until a press succeeds: the words of
112
- * the failure are not the screen's to show.
112
+ * succeeded; one fixed line under the button, `settings.deleteFailed`, says that it failed until a press succeeds. The words of the
113
+ * failure are not the screen's to show.
113
114
  */
114
- function DeleteAll({ refresh }: { refresh(): Promise<unknown> }) {
115
+ function DeleteAll({ t, refresh }: { t: Translate; refresh(): Promise<unknown> }) {
115
116
  const clear = useRpc(clearDrop);
116
117
  const [busy, setBusy] = useState(false);
117
118
  const [refused, setRefused] = useState(false);
@@ -137,13 +138,14 @@ function DeleteAll({ refresh }: { refresh(): Promise<unknown> }) {
137
138
  return (
138
139
  <View style={{ marginTop: 12 }}>
139
140
  <SettingsCard>
140
- <SettingsAction label={DELETE_ALL} actionLabel="Видалити" error={refused ? DELETE_FAILED : null} disabled={busy} onPress={() => void run()} />
141
+ <SettingsAction label={t("settings.deleteAll")} actionLabel={t("settings.delete")} error={refused ? t("settings.deleteFailed") : null} disabled={busy} onPress={() => void run()} />
141
142
  </SettingsCard>
142
143
  </View>
143
144
  );
144
145
  }
145
146
 
146
147
  export function SettingsScreen({ theme }: PluginSurfaceProps) {
148
+ const { t } = useTranslation(messages);
147
149
  const colors = tone(theme.colors);
148
150
  const read = useRpc(readDiagnostics);
149
151
  const query = useQuery({ queryKey: ["secure-input", "diagnostics"], queryFn: () => read({}), refetchInterval: REFRESH_MS });
@@ -152,9 +154,9 @@ export function SettingsScreen({ theme }: PluginSurfaceProps) {
152
154
  return (
153
155
  <>
154
156
  <Header colors={colors} />
155
- <Encryption colors={colors} />
156
- <Status data={data} failed={query.isError} colors={colors} />
157
- {data !== undefined && canDeleteAll(data) ? <DeleteAll refresh={() => query.refetch()} /> : null}
157
+ <Encryption t={t} colors={colors} />
158
+ <Status t={t} data={data} failed={query.isError} colors={colors} />
159
+ {data !== undefined && canDeleteAll(data) ? <DeleteAll t={t} refresh={() => query.refetch()} /> : null}
158
160
  </>
159
161
  );
160
162
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "paseo-plugin-secure-input",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "paseo-plugin-secure-input",
9
- "version": "0.3.0",
9
+ "version": "0.4.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@noble/ciphers": "2.4.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-plugin-secure-input",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Secure secret input for Paseo agents: a typed value or a whole file travels sealed to the daemon and lands in a short-lived file; the agent gets its path, never the value",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,19 +40,20 @@
40
40
  "@noble/hashes": "2.4.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@getpaseo/client": "0.14.0-beta.1",
44
- "@getpaseo/plugin": "0.14.0-beta.1",
45
- "@getpaseo/protocol": "0.14.0-beta.1",
46
- "@getpaseo/relay": "0.14.0-beta.1",
43
+ "@getpaseo/client": "0.15.0",
44
+ "@getpaseo/plugin": "0.15.0",
45
+ "@getpaseo/protocol": "0.15.0",
46
+ "@getpaseo/relay": "0.15.0",
47
47
  "@modelcontextprotocol/sdk": "1.32.2",
48
48
  "@tanstack/react-query": "^5.105.0",
49
49
  "@types/node": "^22.0.0",
50
50
  "@types/react": "~19.2.0",
51
51
  "react": "19.1.0",
52
52
  "react-native": "0.81.5",
53
- "semver": "7.8.5",
53
+ "semver": "7.8.6",
54
54
  "typescript": "^7.0.2",
55
55
  "typescript-5": "npm:typescript@5.9.3",
56
+ "vite": "8.3.6",
56
57
  "vitest": "^5.0.5",
57
58
  "zod": "^4.6.7"
58
59
  },
package/paseo-plugin.json CHANGED
@@ -2,5 +2,5 @@
2
2
  "id": "secure-input",
3
3
  "description": "Agents ask for secrets through a form; each value or file lands in a short-lived file the agent moves without reading it",
4
4
  "icon": "assets/icon.png",
5
- "requirements": { "paseo": ">=0.14.0-beta.1" }
5
+ "requirements": { "paseo": ">=0.15.0" }
6
6
  }
@@ -86,7 +86,7 @@ function deliveredText(head: string, record: RequestRecord, drop: string): strin
86
86
  "The values were not shown to you. Never let the content of a file or directory whose name starts with si-secret- reach you: do not read, print, open, compare or log it, and do not pass it as an argument.",
87
87
  "Move each value where it is needed only by redirection or by copy, for example `command < PATH` or `cp PATH DESTINATION`.",
88
88
  `Then delete the directory (\`rm -r ${shellPath(setPath(drop, record.id))}\`) or call release_secret.`,
89
- `The files are deleted at the end of the turn this message starts, and at ${new Date(deleteBy).toISOString()} at the latest.`,
89
+ `The files are deleted at the end of the turn this message starts, or at the end of your next turn if it joins a running turn, and at ${new Date(deleteBy).toISOString()} at the latest.`,
90
90
  ].join("\n");
91
91
  }
92
92
 
@@ -1,11 +1,11 @@
1
- import type { AgentToolDefinition, PluginBeforeRequests, PluginServerContext } from "@getpaseo/plugin/server";
1
+ import type { AgentToolDefinition, PluginHookRequests, PluginServerContext } from "@getpaseo/plugin/server";
2
2
  import { SecureInputError } from "../../shared/errors";
3
3
  import type { Registry } from "../core/registry";
4
4
  import { within } from "./bounded";
5
5
  import type { Runtime } from "./runtime";
6
6
  import { TOOL_NAMES } from "./tools";
7
7
 
8
- export type SessionOpenRequest = PluginBeforeRequests["agent.session_open"];
8
+ export type SessionOpenRequest = PluginHookRequests["agent.open.before"];
9
9
 
10
10
  /**
11
11
  * How long the handler of a turn's end, or of an agent's archiving, waits at most for what it closes (`Registry.turnEnded`,
@@ -46,67 +46,67 @@ export function failureCode(error: unknown): string {
46
46
 
47
47
  /**
48
48
  * The daemon runs the `before` hooks inside the opening of an agent's session: a throw from one fails that opening (0.14
49
- * passes it on as "Plugin … before agent.session_open failed"), and it gives a hook 30 seconds. So nothing here can
49
+ * passes it on as "Plugin … before agent.open.before failed"), and it gives a hook 30 seconds. So nothing here can
50
50
  * reject, and the session-open hook waits for nothing: it builds the tools and hands them over, and a call waits for the
51
51
  * start-up itself (`agentTools`). Any failure of the hook (tools that cannot be built, a payload that is not what the SDK
52
52
  * declares) is remembered as a code, and the request goes on as it came. The handlers of events are held to the same
53
53
  * rule, which the daemon only logs for; the two handlers that wait, a turn's end and an agent's archiving, wait within
54
54
  * `RELEASE_WAIT_MS`.
55
55
  */
56
- export function registerHooks(host: Pick<PluginServerContext, "before" | "on">, deps: HookDeps): void {
57
- host.before("agent.session_open", ({ request }, { paseo }) => {
56
+ export function registerHooks(host: Pick<PluginServerContext, "addHook">, deps: HookDeps): void {
57
+ host.addHook("agent.open.before", async ({ request }, { paseo }) => {
58
58
  try {
59
59
  deps.runtime.attach(paseo);
60
60
  return withTools(request, deps.tools());
61
61
  } catch (error) {
62
- deps.failed("agent.session_open", failureCode(error));
62
+ deps.failed("agent.open.before", failureCode(error));
63
63
  return request;
64
64
  }
65
65
  });
66
66
 
67
67
  // A turn began: a delivered request whose message was handed over before it is armed, and the end of this turn takes
68
68
  // its set (`Registry.turnStarted`). The event is read inside the guard: a payload without an agent is a failure.
69
- host.on("agent.turn_started", (event, { paseo }) => {
69
+ host.addHook("agent.turn.before", async (event, { paseo }) => {
70
70
  try {
71
71
  deps.runtime.attach(paseo);
72
72
  deps.turns.turnStarted(event.agent.id);
73
73
  } catch (error) {
74
- deps.failed("agent.turn_started", failureCode(error));
74
+ deps.failed("agent.turn.before", failureCode(error));
75
75
  }
76
76
  });
77
77
 
78
78
  // A turn ended, with any outcome. First the sets it releases, waited for within `RELEASE_WAIT_MS`: a wait that runs out
79
79
  // is no failure, and the removal goes on in the registry. Then what waits for the agent is asked for, also when the
80
80
  // releases failed: a message is never held back by them.
81
- host.on("agent.turn_ended", async (event, { paseo }) => {
81
+ host.addHook("agent.turn.after", async (event, { paseo }) => {
82
82
  try {
83
83
  deps.runtime.attach(paseo);
84
84
  const agentId = event.agent.id;
85
85
  try {
86
86
  await within(deps.releaseWaitMs ?? RELEASE_WAIT_MS, () => deps.turns.turnEnded(agentId));
87
87
  } catch (error) {
88
- deps.failed("agent.turn_ended", failureCode(error));
88
+ deps.failed("agent.turn.after", failureCode(error));
89
89
  }
90
90
  deps.runtime.turnEnded(agentId);
91
91
  } catch (error) {
92
- deps.failed("agent.turn_ended", failureCode(error));
92
+ deps.failed("agent.turn.after", failureCode(error));
93
93
  }
94
94
  });
95
95
 
96
96
  // An archived agent has no use for what it asked for, so its requests close and what waits for it is dropped. `agent.closed`
97
97
  // is deliberately not used for this: what "closed" means for an agent that can be opened again could not be established.
98
- host.on("agent.archived", async (event, { paseo }) => {
98
+ host.addHook("agent.archive.after", async (event, { paseo }) => {
99
99
  try {
100
100
  deps.runtime.attach(paseo);
101
101
  const agentId = event.agent.id;
102
102
  try {
103
103
  await within(deps.releaseWaitMs ?? RELEASE_WAIT_MS, () => deps.turns.agentArchived(agentId));
104
104
  } catch (error) {
105
- deps.failed("agent.archived", failureCode(error));
105
+ deps.failed("agent.archive.after", failureCode(error));
106
106
  }
107
107
  deps.runtime.agentArchived(agentId);
108
108
  } catch (error) {
109
- deps.failed("agent.archived", failureCode(error));
109
+ deps.failed("agent.archive.after", failureCode(error));
110
110
  }
111
111
  });
112
112
  }
@@ -19,7 +19,7 @@ import { Runtime, SETTLE_BOUND_MS } from "./runtime";
19
19
  import { agentTools } from "./tools";
20
20
 
21
21
  /** The parts of the server context the plugin uses. */
22
- export type PluginHost = Pick<PluginServerContext, "handle" | "before" | "on">;
22
+ export type PluginHost = Pick<PluginServerContext, "handle" | "addHook">;
23
23
 
24
24
  /**
25
25
  * What the plugin runs in. Under plain Node the shim v1 left is pointed at `execPath`, which runs the stub in place of
@@ -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.3.0";
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,8 +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.
15
- - **Keep a delegated move inside your turn.** The files 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.
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.
16
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.
17
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.
18
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.
@@ -144,7 +144,7 @@ The tool answers with an error whose text is `{"error": "<code>", "message": "<c
144
144
 
145
145
  | `error` | Do |
146
146
  |---|---|
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 |
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 |
148
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 |
149
149
  | `request_closed` | `cancel_request` on a request that no longer waits. `request_status` shows its state |
150
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
- }