@aliou/pi-processes 0.10.2 → 0.10.3
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/extensions/processes/handlers/notifications.ts +5 -4
- package/extensions/processes/notifications/service.ts +4 -1
- package/extensions/processes/tools/index.ts +2 -1
- package/extensions/processes/tools/notify.ts +13 -4
- package/extensions/processes/tools/schema.ts +10 -8
- package/package.json +1 -1
- package/skills/pi-processes/SKILL.md +16 -6
|
@@ -60,10 +60,11 @@ export function registerNotificationDelivery(
|
|
|
60
60
|
summary: `Suppressed ${count} log-match notifications because output was too fast.`,
|
|
61
61
|
attention: "context",
|
|
62
62
|
};
|
|
63
|
-
sendProcessNotificationMessage(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
sendProcessNotificationMessage(
|
|
64
|
+
pi,
|
|
65
|
+
details,
|
|
66
|
+
attentionToSendOptions(details.attention),
|
|
67
|
+
);
|
|
67
68
|
};
|
|
68
69
|
|
|
69
70
|
const flushSuppressedSummary = () => {
|
|
@@ -25,7 +25,10 @@ const DEFAULT_ATTENTION: Record<
|
|
|
25
25
|
"onSuccess" | "onFailure" | "onKilled",
|
|
26
26
|
Attention
|
|
27
27
|
> = {
|
|
28
|
-
|
|
28
|
+
// Keep in sync with DEFAULT_NOTIFY_CONFIG in tools/notify.ts. Success
|
|
29
|
+
// defaults to a turn because "context" is only seen by an agent that is
|
|
30
|
+
// still streaming when the process ends.
|
|
31
|
+
onSuccess: "turn",
|
|
29
32
|
onFailure: "turn",
|
|
30
33
|
// External kills surface as context by default (see DEFAULT_NOTIFY_CONFIG
|
|
31
34
|
// in tools/notify.ts for rationale). Intentional stops are classified
|
|
@@ -54,7 +54,8 @@ export function registerProcessTool(
|
|
|
54
54
|
"Manage long-running background processes: start, list, stop, write to stdin, update watches, clear finished entries, and inspect recent output. After starting a process, do not wait - notifications bring you back on exit and on log matches.",
|
|
55
55
|
promptGuidelines: [
|
|
56
56
|
"process tool: use process start for long-running commands (dev servers, watchers, builds) instead of shell background patterns like &, nohup, or setsid; give each process a specific name and check process list first when a duplicate would be noisy.",
|
|
57
|
-
"process tool: after process start, do not sleep, poll, or hold your turn. End your turn or move on.
|
|
57
|
+
"process tool: after process start, do not sleep, poll, or hold your turn. End your turn or move on. Exits and notify.logMatches matches bring you back.",
|
|
58
|
+
"process tool: attention turn wakes you when idle; context only reaches you if you are still working; ignore never notifies. Keep turn for anything whose result you need.",
|
|
58
59
|
"process tool: use notify.logMatches to get brought back on readiness or error signals instead of polling process output. If a watch is too noisy, use process update (watches.mode append/replace/remove/clear) to fix it without restarting.",
|
|
59
60
|
"process tool: for the full lifecycle (start, list, output, update, write, stop, clear), notify options, use cases, and noisy-watch handling, read the pi-processes skill.",
|
|
60
61
|
],
|
|
@@ -14,7 +14,13 @@ export const MAX_NOTIFY_LOG_MATCHERS = MAX_LOG_MATCHERS_PER_PROCESS;
|
|
|
14
14
|
export const MAX_NOTIFY_PATTERN_LENGTH = MAX_LOG_MATCH_PATTERN_LENGTH;
|
|
15
15
|
|
|
16
16
|
const DEFAULT_NOTIFY_CONFIG = {
|
|
17
|
-
|
|
17
|
+
// A backgrounded process usually outlives the turn that started it, and
|
|
18
|
+
// "context" only reaches the agent if it happens to still be streaming when
|
|
19
|
+
// the process ends. Builds, tests, and other one-shot commands are started
|
|
20
|
+
// precisely because the agent needs the result, so success defaults to a
|
|
21
|
+
// turn. Long-running servers rarely exit 0, and callers that do not want the
|
|
22
|
+
// interruption can pass onSuccess: "context".
|
|
23
|
+
onSuccess: "turn",
|
|
18
24
|
onFailure: "turn",
|
|
19
25
|
// External kills (outside this manager) surface as context by default so
|
|
20
26
|
// the agent and user learn that a managed process disappeared. Intentional
|
|
@@ -36,11 +42,14 @@ export function normalizeNotifyConfig(input: unknown): NotifyConfig {
|
|
|
36
42
|
|
|
37
43
|
return {
|
|
38
44
|
onSuccess:
|
|
39
|
-
normalizeAttention(input.onSuccess, "notify.onSuccess") ??
|
|
45
|
+
normalizeAttention(input.onSuccess, "notify.onSuccess") ??
|
|
46
|
+
DEFAULT_NOTIFY_CONFIG.onSuccess,
|
|
40
47
|
onFailure:
|
|
41
|
-
normalizeAttention(input.onFailure, "notify.onFailure") ??
|
|
48
|
+
normalizeAttention(input.onFailure, "notify.onFailure") ??
|
|
49
|
+
DEFAULT_NOTIFY_CONFIG.onFailure,
|
|
42
50
|
onKilled:
|
|
43
|
-
normalizeAttention(input.onKilled, "notify.onKilled") ??
|
|
51
|
+
normalizeAttention(input.onKilled, "notify.onKilled") ??
|
|
52
|
+
DEFAULT_NOTIFY_CONFIG.onKilled,
|
|
44
53
|
logMatches: normalizeLogMatches(logMatches),
|
|
45
54
|
};
|
|
46
55
|
}
|
|
@@ -110,28 +110,25 @@ const WatchUpdateItemParams = Type.Object({
|
|
|
110
110
|
),
|
|
111
111
|
on: Type.Optional(
|
|
112
112
|
StringEnum(PROCESS_NOTIFY_ATTENTIONS, {
|
|
113
|
-
description: "
|
|
113
|
+
description: "Attention for this match. Defaults to turn.",
|
|
114
114
|
}),
|
|
115
115
|
),
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
-
const
|
|
118
|
+
const NotifyProperties = {
|
|
119
119
|
onSuccess: Type.Optional(
|
|
120
120
|
StringEnum(PROCESS_NOTIFY_ATTENTIONS, {
|
|
121
|
-
description:
|
|
122
|
-
"Agent attention when the process exits successfully. Defaults to context.",
|
|
121
|
+
description: "Attention on clean exit. Defaults to turn.",
|
|
123
122
|
}),
|
|
124
123
|
),
|
|
125
124
|
onFailure: Type.Optional(
|
|
126
125
|
StringEnum(PROCESS_NOTIFY_ATTENTIONS, {
|
|
127
|
-
description:
|
|
128
|
-
"Agent attention when the process fails or crashes. Defaults to turn.",
|
|
126
|
+
description: "Attention on failure or crash. Defaults to turn.",
|
|
129
127
|
}),
|
|
130
128
|
),
|
|
131
129
|
onKilled: Type.Optional(
|
|
132
130
|
StringEnum(PROCESS_NOTIFY_ATTENTIONS, {
|
|
133
|
-
description:
|
|
134
|
-
"Agent attention when the process is killed. Defaults to context.",
|
|
131
|
+
description: "Attention on external kill. Defaults to context.",
|
|
135
132
|
}),
|
|
136
133
|
),
|
|
137
134
|
logMatches: Type.Optional(
|
|
@@ -141,6 +138,11 @@ const NotifyParams = Type.Object({
|
|
|
141
138
|
"Log match notifications. Supports at most 20 matchers, with each pattern limited to 500 characters.",
|
|
142
139
|
}),
|
|
143
140
|
),
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const NotifyParams = Type.Object(NotifyProperties, {
|
|
144
|
+
description:
|
|
145
|
+
"Notify settings. Attention: turn wakes an idle agent, context only reaches an agent still working, ignore never notifies.",
|
|
144
146
|
});
|
|
145
147
|
|
|
146
148
|
export const ProcessesParams = Type.Object({
|
package/package.json
CHANGED
|
@@ -15,9 +15,11 @@ A started process runs in the background and the manager brings you back when so
|
|
|
15
15
|
2. End your turn or move on to other work. Do not call `process output` in a loop waiting for "ready".
|
|
16
16
|
3. The process notifies you when:
|
|
17
17
|
- a `logMatches` pattern hits (readiness, error, progress),
|
|
18
|
-
- the process exits successfully (`onSuccess`, default `
|
|
18
|
+
- the process exits successfully (`onSuccess`, default `turn`),
|
|
19
19
|
- the process fails or crashes (`onFailure`, default `turn`),
|
|
20
|
-
- the process is killed
|
|
20
|
+
- the process is killed externally (`onKilled`, default `context`, which does not wake an idle agent).
|
|
21
|
+
|
|
22
|
+
Stopping a process yourself never notifies.
|
|
21
23
|
4. When a watch is too noisy or wrong, fix it with `process update` — do not restart the process just to change watches.
|
|
22
24
|
5. `process stop` obsolete live processes and `process clear` finished entries when they are no longer useful.
|
|
23
25
|
|
|
@@ -50,6 +52,8 @@ Good:
|
|
|
50
52
|
}
|
|
51
53
|
```
|
|
52
54
|
|
|
55
|
+
`onSuccess: "context"` here because a dev server exiting cleanly needs no reaction. Keep the default `turn` for builds, tests, and other one-shot commands whose result you need.
|
|
56
|
+
|
|
53
57
|
Optional `cwd` sets the working directory for the spawned command. Omit it to inherit the agent's current working directory.
|
|
54
58
|
|
|
55
59
|
Empty `logMatches` patterns (literal or regex) are rejected at start and update time. Use `mode: "regex"` only when literal matching is not enough, scope by `stream` to cut noise, and use `repeat: true` when a matcher should fire more than once.
|
|
@@ -214,9 +218,9 @@ Good:
|
|
|
214
218
|
|
|
215
219
|
Exit attention:
|
|
216
220
|
|
|
217
|
-
- `notify.onSuccess` —
|
|
218
|
-
- `notify.onFailure` —
|
|
219
|
-
- `notify.onKilled` —
|
|
221
|
+
- `notify.onSuccess` — clean exit. Defaults to `turn`.
|
|
222
|
+
- `notify.onFailure` — failure or crash. Defaults to `turn`.
|
|
223
|
+
- `notify.onKilled` — killed from outside the tool. Defaults to `context`. Stopping a process yourself never notifies.
|
|
220
224
|
|
|
221
225
|
Log match watches (`notify.logMatches`, up to 20, each pattern up to 500 chars):
|
|
222
226
|
|
|
@@ -226,7 +230,13 @@ Log match watches (`notify.logMatches`, up to 20, each pattern up to 500 chars):
|
|
|
226
230
|
- `repeat` — `false` (default) fires once; `true` fires on every match.
|
|
227
231
|
- `on` — `turn`, `context`, or `ignore`. Overrides the default attention for that watch. Defaults to `turn`.
|
|
228
232
|
|
|
229
|
-
|
|
233
|
+
Attention levels:
|
|
234
|
+
|
|
235
|
+
- `turn` — starts an agent turn. Reaches you even when you are idle.
|
|
236
|
+
- `context` — recorded in the transcript, no turn. It reaches you only if you are still working when the event fires; an idle agent is not woken and sees it on the next user message.
|
|
237
|
+
- `ignore` — recorded, never notifies.
|
|
238
|
+
|
|
239
|
+
Use `context` only when nothing needs to happen in response.
|
|
230
240
|
|
|
231
241
|
## Use cases
|
|
232
242
|
|