@phigon/observer 8.2.0 → 8.3.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.
- package/README.md +194 -11
- package/dist/bin/guardian-runner-darwin-amd64 +0 -0
- package/dist/bin/guardian-runner-darwin-arm64 +0 -0
- package/dist/bin/guardian-runner-linux-amd64 +0 -0
- package/dist/bin/guardian-runner-linux-arm64 +0 -0
- package/dist/bin/guardian-runner-windows-amd64.exe +0 -0
- package/dist/bin/guardian-runner-windows-arm64.exe +0 -0
- package/dist/src/abortable-delay.d.ts +10 -0
- package/dist/src/abortable-delay.d.ts.map +1 -0
- package/dist/src/abortable-delay.js +21 -0
- package/dist/src/abortable-delay.js.map +1 -0
- package/dist/src/activity/adapters/claude.d.ts.map +1 -1
- package/dist/src/activity/adapters/claude.js +9 -1
- package/dist/src/activity/adapters/claude.js.map +1 -1
- package/dist/src/activity/adapters/openai-compatible.d.ts.map +1 -1
- package/dist/src/activity/adapters/openai-compatible.js +9 -1
- package/dist/src/activity/adapters/openai-compatible.js.map +1 -1
- package/dist/src/activity/collector.d.ts +31 -1
- package/dist/src/activity/collector.d.ts.map +1 -1
- package/dist/src/activity/collector.js +337 -77
- package/dist/src/activity/collector.js.map +1 -1
- package/dist/src/activity/ingest.d.ts +9 -0
- package/dist/src/activity/ingest.d.ts.map +1 -1
- package/dist/src/activity/ingest.js +92 -3
- package/dist/src/activity/ingest.js.map +1 -1
- package/dist/src/activity/json-document-source.d.ts +15 -0
- package/dist/src/activity/json-document-source.d.ts.map +1 -1
- package/dist/src/activity/json-document-source.js +19 -2
- package/dist/src/activity/json-document-source.js.map +1 -1
- package/dist/src/activity/native-capabilities.d.ts.map +1 -1
- package/dist/src/activity/native-capabilities.js +8 -12
- package/dist/src/activity/native-capabilities.js.map +1 -1
- package/dist/src/activity/opencode-sqlite-source.js +1 -0
- package/dist/src/activity/opencode-sqlite-source.js.map +1 -1
- package/dist/src/activity/source-reader.d.ts +44 -3
- package/dist/src/activity/source-reader.d.ts.map +1 -1
- package/dist/src/activity/source-reader.js +325 -86
- package/dist/src/activity/source-reader.js.map +1 -1
- package/dist/src/agent-action-executor.d.ts +5 -0
- package/dist/src/agent-action-executor.d.ts.map +1 -1
- package/dist/src/agent-action-executor.js +9 -6
- package/dist/src/agent-action-executor.js.map +1 -1
- package/dist/src/atomic-replace.d.ts +7 -0
- package/dist/src/atomic-replace.d.ts.map +1 -1
- package/dist/src/atomic-replace.js +28 -3
- package/dist/src/atomic-replace.js.map +1 -1
- package/dist/src/bridge-journal.d.ts +32 -0
- package/dist/src/bridge-journal.d.ts.map +1 -0
- package/dist/src/bridge-journal.js +113 -0
- package/dist/src/bridge-journal.js.map +1 -0
- package/dist/src/cli.d.ts +7 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +490 -43
- package/dist/src/cli.js.map +1 -1
- package/dist/src/collection-notice.d.ts +34 -0
- package/dist/src/collection-notice.d.ts.map +1 -0
- package/dist/src/collection-notice.js +73 -0
- package/dist/src/collection-notice.js.map +1 -0
- package/dist/src/config.d.ts +26 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +88 -33
- package/dist/src/config.js.map +1 -1
- package/dist/src/content-redaction.d.ts +17 -1
- package/dist/src/content-redaction.d.ts.map +1 -1
- package/dist/src/content-redaction.js +44 -3
- package/dist/src/content-redaction.js.map +1 -1
- package/dist/src/credential-store.d.ts +20 -1
- package/dist/src/credential-store.d.ts.map +1 -1
- package/dist/src/credential-store.js +27 -3
- package/dist/src/credential-store.js.map +1 -1
- package/dist/src/discovery/engine.d.ts.map +1 -1
- package/dist/src/discovery/engine.js +1 -11
- package/dist/src/discovery/engine.js.map +1 -1
- package/dist/src/doctor-check.d.ts +51 -0
- package/dist/src/doctor-check.d.ts.map +1 -0
- package/dist/src/doctor-check.js +174 -0
- package/dist/src/doctor-check.js.map +1 -0
- package/dist/src/enroll.d.ts +86 -0
- package/dist/src/enroll.d.ts.map +1 -0
- package/dist/src/enroll.js +245 -0
- package/dist/src/enroll.js.map +1 -0
- package/dist/src/entry.d.ts +3 -0
- package/dist/src/entry.d.ts.map +1 -0
- package/dist/src/entry.js +14 -0
- package/dist/src/entry.js.map +1 -0
- package/dist/src/event-queue.d.ts +13 -1
- package/dist/src/event-queue.d.ts.map +1 -1
- package/dist/src/event-queue.js +50 -5
- package/dist/src/event-queue.js.map +1 -1
- package/dist/src/event-spool.d.ts +61 -3
- package/dist/src/event-spool.d.ts.map +1 -1
- package/dist/src/event-spool.js +290 -41
- package/dist/src/event-spool.js.map +1 -1
- package/dist/src/generated/phigon/v1/identity_pb.d.ts +7 -0
- package/dist/src/generated/phigon/v1/identity_pb.d.ts.map +1 -1
- package/dist/src/generated/phigon/v1/identity_pb.js +1 -1
- package/dist/src/generated/phigon/v1/identity_pb.js.map +1 -1
- package/dist/src/guardian-decision-journal.d.ts.map +1 -1
- package/dist/src/guardian-decision-journal.js +4 -20
- package/dist/src/guardian-decision-journal.js.map +1 -1
- package/dist/src/guardian-managed-exec.js +6 -19
- package/dist/src/guardian-managed-exec.js.map +1 -1
- package/dist/src/guardian-process-monitor.d.ts +1 -0
- package/dist/src/guardian-process-monitor.d.ts.map +1 -1
- package/dist/src/guardian-process-monitor.js +74 -26
- package/dist/src/guardian-process-monitor.js.map +1 -1
- package/dist/src/health.d.ts +19 -1
- package/dist/src/health.d.ts.map +1 -1
- package/dist/src/health.js +22 -1
- package/dist/src/health.js.map +1 -1
- package/dist/src/historical-identity-store.d.ts +8 -1
- package/dist/src/historical-identity-store.d.ts.map +1 -1
- package/dist/src/historical-identity-store.js +26 -9
- package/dist/src/historical-identity-store.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/installation.d.ts +2 -0
- package/dist/src/installation.d.ts.map +1 -1
- package/dist/src/installation.js +3 -1
- package/dist/src/installation.js.map +1 -1
- package/dist/src/instance-lock.d.ts +45 -0
- package/dist/src/instance-lock.d.ts.map +1 -0
- package/dist/src/instance-lock.js +243 -0
- package/dist/src/instance-lock.js.map +1 -0
- package/dist/src/machine-command-executor.d.ts +2 -2
- package/dist/src/machine-command-executor.d.ts.map +1 -1
- package/dist/src/machine-command-executor.js +7 -20
- package/dist/src/machine-command-executor.js.map +1 -1
- package/dist/src/node-version.d.ts +8 -0
- package/dist/src/node-version.d.ts.map +1 -0
- package/dist/src/node-version.js +17 -0
- package/dist/src/node-version.js.map +1 -0
- package/dist/src/observer-log.d.ts +50 -0
- package/dist/src/observer-log.d.ts.map +1 -0
- package/dist/src/observer-log.js +141 -0
- package/dist/src/observer-log.js.map +1 -0
- package/dist/src/pair.d.ts +68 -1
- package/dist/src/pair.d.ts.map +1 -1
- package/dist/src/pair.js +204 -66
- package/dist/src/pair.js.map +1 -1
- package/dist/src/private-directory.d.ts +6 -0
- package/dist/src/private-directory.d.ts.map +1 -1
- package/dist/src/private-directory.js +33 -2
- package/dist/src/private-directory.js.map +1 -1
- package/dist/src/proxy.d.ts +68 -0
- package/dist/src/proxy.d.ts.map +1 -0
- package/dist/src/proxy.js +209 -0
- package/dist/src/proxy.js.map +1 -0
- package/dist/src/purge.d.ts +17 -0
- package/dist/src/purge.d.ts.map +1 -0
- package/dist/src/purge.js +84 -0
- package/dist/src/purge.js.map +1 -0
- package/dist/src/remove-machine.d.ts +5 -1
- package/dist/src/remove-machine.d.ts.map +1 -1
- package/dist/src/remove-machine.js +28 -14
- package/dist/src/remove-machine.js.map +1 -1
- package/dist/src/server-authority.d.ts +5 -2
- package/dist/src/server-authority.d.ts.map +1 -1
- package/dist/src/server-authority.js +10 -6
- package/dist/src/server-authority.js.map +1 -1
- package/dist/src/server-clock.d.ts +32 -0
- package/dist/src/server-clock.d.ts.map +1 -0
- package/dist/src/server-clock.js +72 -0
- package/dist/src/server-clock.js.map +1 -0
- package/dist/src/service-command.d.ts +20 -0
- package/dist/src/service-command.d.ts.map +1 -0
- package/dist/src/service-command.js +136 -0
- package/dist/src/service-command.js.map +1 -0
- package/dist/src/service.d.ts +98 -0
- package/dist/src/service.d.ts.map +1 -0
- package/dist/src/service.js +472 -0
- package/dist/src/service.js.map +1 -0
- package/dist/src/stream-client.d.ts +18 -0
- package/dist/src/stream-client.d.ts.map +1 -1
- package/dist/src/stream-client.js +91 -16
- package/dist/src/stream-client.js.map +1 -1
- package/dist/src/stream-state.d.ts +2 -0
- package/dist/src/stream-state.d.ts.map +1 -1
- package/dist/src/stream-state.js +3 -1
- package/dist/src/stream-state.js.map +1 -1
- package/dist/src/user-notices.d.ts +11 -0
- package/dist/src/user-notices.d.ts.map +1 -1
- package/dist/src/user-notices.js +24 -0
- package/dist/src/user-notices.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -66,7 +66,9 @@ exactly what runs on your computers and what leaves them.
|
|
|
66
66
|
| | Any other agent | [Register it](#custom-agents) | Bridge |
|
|
67
67
|
|
|
68
68
|
*Built in* means the observer reads the agent's own records. *Bridge* means the
|
|
69
|
-
agent (or a small wrapper) pipes NDJSON to `phigon-observer ingest`.
|
|
69
|
+
agent (or a small wrapper) pipes NDJSON to `phigon-observer ingest`. The
|
|
70
|
+
observer deletes each bridge file once the workspace has received it, and any
|
|
71
|
+
bridge file after seven days.
|
|
70
72
|
|
|
71
73
|
## How it works
|
|
72
74
|
|
|
@@ -90,7 +92,7 @@ telemetry. The wire protocol is in [`proto/`](proto).
|
|
|
90
92
|
|
|
91
93
|
## Quick start
|
|
92
94
|
|
|
93
|
-
You need **Node.js 24 or newer** and a Phigon workspace. Installed releases
|
|
95
|
+
You need **Node.js 24.5 or newer** and a Phigon workspace. Installed releases
|
|
94
96
|
include the Guardian runner for Windows, macOS and Linux on x64 and Arm64; Go is
|
|
95
97
|
only needed to build from source.
|
|
96
98
|
|
|
@@ -117,13 +119,112 @@ phigon-observer pair --code YOUR-CODE --consent-profile full
|
|
|
117
119
|
phigon-observer run --profile full
|
|
118
120
|
```
|
|
119
121
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
To keep collecting after the terminal closes and after every restart, install
|
|
123
|
+
the observer as a background service for the signed-in user:
|
|
122
124
|
|
|
123
125
|
```sh
|
|
124
|
-
phigon-observer
|
|
126
|
+
phigon-observer service install --profile metadata # or --profile full
|
|
125
127
|
```
|
|
126
128
|
|
|
129
|
+
Closing the Phigon app does not stop it. Check the installation and connection
|
|
130
|
+
at any time:
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
phigon-observer service status
|
|
134
|
+
phigon-observer doctor --check
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Background service
|
|
138
|
+
|
|
139
|
+
`service install` runs `phigon-observer run` in the background as the
|
|
140
|
+
signed-in user, not as SYSTEM or root, because it reads that user's agent
|
|
141
|
+
records. It starts when the user signs in and again if it stops:
|
|
142
|
+
|
|
143
|
+
| System | What is installed | Restart |
|
|
144
|
+
| --- | --- | --- |
|
|
145
|
+
| Windows | A Task Scheduler task, "Phigon Observer", that runs at sign-in without a window | Started again within a minute |
|
|
146
|
+
| macOS | A LaunchAgent, `~/Library/LaunchAgents/com.phigon.observer.plist` | launchd keeps it running (`KeepAlive`) |
|
|
147
|
+
| Linux | A systemd user unit, `~/.config/systemd/user/phigon-observer.service` | `Restart=on-failure` |
|
|
148
|
+
|
|
149
|
+
- The service runs the same Node.js and observer that ran `service install`,
|
|
150
|
+
with the same data directory. The settings it needs (`PHIGON_*`, `PATH`,
|
|
151
|
+
the proxy variables, `NODE_EXTRA_CA_CERTS` and the agents' folder settings)
|
|
152
|
+
are saved to `service-settings.json` in the data directory, which only this
|
|
153
|
+
user can read. Settings whose names suggest a secret (token, password and
|
|
154
|
+
similar) are never saved, and the service definition holds no settings at
|
|
155
|
+
all, only the paths of Node.js, the observer and that file. A proxy address
|
|
156
|
+
that includes a user name and password is saved there as it is, so prefer a
|
|
157
|
+
proxy that does not need one in the address.
|
|
158
|
+
- `service install` refuses until the computer is paired and its owner (or,
|
|
159
|
+
with an enrollment code, its company) has consented, and `--profile full`
|
|
160
|
+
needs full-activity consent. Running it
|
|
161
|
+
again replaces the earlier definition, so run it again after moving
|
|
162
|
+
Node.js or changing settings.
|
|
163
|
+
- `service status` says whether the service is installed and whether an
|
|
164
|
+
observer is running with its data directory. `service uninstall` stops it
|
|
165
|
+
and removes it.
|
|
166
|
+
- A data directory other than the default gets its own service, named with a
|
|
167
|
+
short code made from its path.
|
|
168
|
+
- On Linux the service runs while the user is signed in (a desktop or SSH
|
|
169
|
+
session). To keep it running after sign-out, an administrator can run
|
|
170
|
+
`loginctl enable-linger <user>`.
|
|
171
|
+
- What the service prints goes to `logs/observer.log` in the data directory.
|
|
172
|
+
|
|
173
|
+
### Rolling out to many computers with an enrollment code
|
|
174
|
+
|
|
175
|
+
A company that installs the observer with device management (Intune, Jamf or
|
|
176
|
+
a Linux configuration tool) uses a reusable **enrollment code** (`phe_…`)
|
|
177
|
+
from its administrator instead of one pairing code per computer. With an
|
|
178
|
+
enrollment code **the company gives consent for its computers, and nobody at
|
|
179
|
+
the computer is asked**. The administrator chose the profile, metadata or
|
|
180
|
+
full activity, when creating the code; the server answers with it, and the
|
|
181
|
+
observer stores it with the key and keeps collection within it exactly as it
|
|
182
|
+
does for a profile an owner chose.
|
|
183
|
+
|
|
184
|
+
Enroll as the signed-in user, with the code in the environment so it does
|
|
185
|
+
not show in process lists, then install the background service:
|
|
186
|
+
|
|
187
|
+
```sh
|
|
188
|
+
PHIGON_ENROLLMENT_CODE="$(cat /path/to/code)" phigon-observer pair \
|
|
189
|
+
--control-plane-url https://phigon.corp.example:8443 \
|
|
190
|
+
--grpc-url https://phigon.corp.example:9443 --json
|
|
191
|
+
phigon-observer service install
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
- `--enrollment-code <code>` works too, but anyone on the computer can see a
|
|
195
|
+
command line. `--server-ca-sha256 <fingerprint>` and `--name <name>` work
|
|
196
|
+
as with pairing; `--consent-profile` and `--accept-consent` are refused.
|
|
197
|
+
- The code is never printed, logged or saved, and `service install` never
|
|
198
|
+
copies `PHIGON_ENROLLMENT_CODE` into its settings.
|
|
199
|
+
- A computer already paired with the same server keeps its machine and key,
|
|
200
|
+
and its consent becomes the company's.
|
|
201
|
+
- A busy server (HTTP 429 or 503) is asked again up to three times, after
|
|
202
|
+
the wait it asks for, within five minutes in all.
|
|
203
|
+
- `doctor` shows who consented, the owner or the company and the code's
|
|
204
|
+
label, as a `Consent:` line and as `consent` in `--json` (`doctor --check`
|
|
205
|
+
too).
|
|
206
|
+
- When it starts collecting, the observer tells the person at the computer
|
|
207
|
+
once with a system notification: "Phigon is recording AI agent activity",
|
|
208
|
+
what the profile records, the code's label and "Ask your IT team for
|
|
209
|
+
details". It tells them again when the profile changes. A computer whose
|
|
210
|
+
owner paired it gets no such notice, because the owner accepted the
|
|
211
|
+
profile at the keyboard. `PHIGON_USER_NOTICES=false` turns it off, and it
|
|
212
|
+
cannot show without the user's desktop session; it is remembered only once
|
|
213
|
+
shown, so it is tried again at the next start.
|
|
214
|
+
|
|
215
|
+
A failed enrollment prints the server's sentence and exits with a code a
|
|
216
|
+
script can act on (with `--json`, also an `{"enrolled": false, "error": …}`
|
|
217
|
+
object):
|
|
218
|
+
|
|
219
|
+
| Exit code | Meaning |
|
|
220
|
+
| --- | --- |
|
|
221
|
+
| `20` | The server was busy, unavailable or unreachable. Try again later. |
|
|
222
|
+
| `21` | The code expired, was revoked, is used up or was made under an earlier policy. Ask for a new code. |
|
|
223
|
+
| `22` | Not an enrollment code, or cut short. |
|
|
224
|
+
| `23` | This computer enrolled with this code before and was removed since. Ask for a new code. |
|
|
225
|
+
| `24` | This computer is already connected to the workspace. Check it with `doctor`. |
|
|
226
|
+
| `1` | Anything else, such as a bad setting. |
|
|
227
|
+
|
|
127
228
|
## What is collected
|
|
128
229
|
|
|
129
230
|
What the observer sends is always the overlap of your workspace's policy and
|
|
@@ -148,18 +249,41 @@ settings. A full description is in
|
|
|
148
249
|
| Command | What it does |
|
|
149
250
|
| --- | --- |
|
|
150
251
|
| `pair --code <code> --consent-profile <metadata\|full>` | Connects this computer to a workspace after local consent. |
|
|
252
|
+
| `pair` with `PHIGON_ENROLLMENT_CODE` (or `--enrollment-code <code>`) | Enrolls this computer with a company's enrollment code, under the company's consent, without asking; see [above](#rolling-out-to-many-computers-with-an-enrollment-code). |
|
|
151
253
|
| `run [--profile <metadata\|full>]` | Discovers agents and streams permitted activity. |
|
|
254
|
+
| `service install [--profile <metadata\|full>]`, `service uninstall`, `service status` | Runs the observer in the background for the signed-in user, from sign-in on. |
|
|
152
255
|
| `doctor [--profile <...>] [--json]` | Checks the setup without sending any data. |
|
|
256
|
+
| `doctor --check [--max-delivery-age <minutes>] [--json]` | Checks that collection is working, with an exit code for scripts. |
|
|
153
257
|
| `discover [--json]` | Prints a one-time, sanitized inventory of local agents. |
|
|
154
258
|
| `agent add \| list \| remove` | Manages custom agent definitions. |
|
|
155
259
|
| `ingest --agent <id\|custom> [--name <name>]` | Reads NDJSON activity from stdin (bridges). |
|
|
156
260
|
| `guardian status \| exec \| launch` | Guardian checks and managed execution. |
|
|
157
261
|
| `authorize-action --action <a> --resource <r>` | Asks Guardian whether one action may run. |
|
|
158
262
|
| `update [--check] [--yes]` | Checks for or installs a new release. |
|
|
159
|
-
| `remove-machine` |
|
|
263
|
+
| `remove-machine [--purge]` | Stops collection and revokes this computer's key. Activity already collected stays with the company until an administrator deletes the computer or it expires. `--purge` also removes the background service and the observer's local files; see [Uninstall](#uninstall). |
|
|
160
264
|
|
|
161
265
|
Run `phigon-observer help` for every flag.
|
|
162
266
|
|
|
267
|
+
### Checking a computer from scripts
|
|
268
|
+
|
|
269
|
+
`doctor --check` is meant for device management scripts. It sends no
|
|
270
|
+
activity: it reads the local state and asks the control plane's `/healthz`
|
|
271
|
+
(through the configured proxy and pinned authority, with a five-second
|
|
272
|
+
limit). It exits with the code of the first problem it finds:
|
|
273
|
+
|
|
274
|
+
| Exit code | Meaning |
|
|
275
|
+
| --- | --- |
|
|
276
|
+
| `0` | Everything checked out. |
|
|
277
|
+
| `1` | The check itself could not run, for example because of a bad setting. |
|
|
278
|
+
| `3` | This computer is not paired, or its pairing data cannot be read. |
|
|
279
|
+
| `4` | The owner's consent is missing or out of date. Pair again. |
|
|
280
|
+
| `5` | No observer is running with this data directory. |
|
|
281
|
+
| `6` | The workspace has not confirmed delivery for longer than `--max-delivery-age` minutes (default 15). A connected observer confirms at least once a minute, even when no agent is active. |
|
|
282
|
+
| `7` | The control plane did not answer. |
|
|
283
|
+
|
|
284
|
+
`--json` prints every check with its result. Plain `doctor` keeps exiting
|
|
285
|
+
`0`.
|
|
286
|
+
|
|
163
287
|
### A company's own Phigon server
|
|
164
288
|
|
|
165
289
|
The Phigon app can run a company's own server, and other computers on the
|
|
@@ -184,19 +308,49 @@ Settings are environment variables. The most common ones:
|
|
|
184
308
|
| `PHIGON_CONTROL_PLANE_URL`, `PHIGON_GRPC_URL` | Endpoints for a self-hosted workspace. Pairing saves them; the stream refuses to send credentials anywhere else. |
|
|
185
309
|
| `PHIGON_TLS_CA_FILE` | A private certificate authority for gRPC. Use `NODE_EXTRA_CA_CERTS` for HTTPS. Pairing with `--server-ca-sha256` sets up both for you. |
|
|
186
310
|
| `PHIGON_TLS_CLIENT_CERT_FILE`, `PHIGON_TLS_CLIENT_KEY_FILE` | Client certificate, when the workspace requires mutual TLS. |
|
|
187
|
-
| `PHIGON_COLLECT_*` | Turns individual content categories off
|
|
311
|
+
| `PHIGON_COLLECT_*` | Turns individual content categories off. Content can be turned on only under `--profile full` on a computer whose owner consented to full activity; otherwise `run` refuses to start. |
|
|
188
312
|
| `PHIGON_REDACT_PATH_PATTERNS` | Extra file path patterns to redact. |
|
|
189
313
|
| `PHIGON_<AGENT>_ACTIVITY_DIRS` | Extra record folders for an agent, e.g. `PHIGON_CLAUDE_ACTIVITY_DIRS`. |
|
|
190
314
|
| `PHIGON_REMOTE_ACTIONS_ENABLED` | Opt in to administrator-approved agent stop and force stop. Off by default. |
|
|
191
315
|
| `PHIGON_REMOTE_COMMANDS_ENABLED` | Opt in to administrator-reviewed system operations. Off by default. |
|
|
192
|
-
| `PHIGON_USER_NOTICES` | Set to `false` to stop telling the person at the computer when Phigon stops an agent, runs a command or restarts it. On by default. |
|
|
316
|
+
| `PHIGON_USER_NOTICES` | Set to `false` to stop telling the person at the computer when Phigon stops an agent, runs a command or restarts it, and, on a computer enrolled with a company's code, that collection started. On by default. |
|
|
193
317
|
| `PHIGON_UPDATE_CHECK` | Set to `false` to turn off the once-a-day update check. |
|
|
194
|
-
| `PHIGON_LOG_LEVEL` |
|
|
318
|
+
| `PHIGON_LOG_LEVEL` | What `run` prints and writes to its log: `debug`, `info` (default), `warn` or `error`. |
|
|
319
|
+
|
|
320
|
+
`run` also writes what it prints to `logs/observer.log` in the data directory,
|
|
321
|
+
so a background service leaves a record. The log is rotated at about 5 MB and
|
|
322
|
+
keeps three files. Like the terminal output, it never contains activity
|
|
323
|
+
content, credentials or secrets.
|
|
195
324
|
|
|
196
325
|
Never disable certificate verification. Interactive `pair` and `run` sessions
|
|
197
326
|
check npm for a new release at most once a day and ask before updating;
|
|
198
327
|
background services and `--json` commands never prompt or update on their own.
|
|
199
328
|
|
|
329
|
+
### Corporate proxies
|
|
330
|
+
|
|
331
|
+
The observer sends every HTTPS call (pairing, `remove-machine`, update checks,
|
|
332
|
+
Guardian, `doctor --check`) and the telemetry stream through the proxy that
|
|
333
|
+
`HTTPS_PROXY` names, or `HTTP_PROXY` when only that is set. `NO_PROXY` lists
|
|
334
|
+
hosts it reaches directly. Either case works; when both are set, the lowercase
|
|
335
|
+
name wins. A user name and password in the proxy address are supported and
|
|
336
|
+
never printed.
|
|
337
|
+
|
|
338
|
+
- `NO_PROXY` is a comma-separated list of host names. `example.com`,
|
|
339
|
+
`.example.com` and `*.example.com` each cover `example.com` and every host
|
|
340
|
+
under it, `*` turns the proxy off, and `host:port` applies to that port only.
|
|
341
|
+
- HTTPS passes through the proxy as a CONNECT tunnel, and TLS is negotiated
|
|
342
|
+
with the Phigon server inside it, so certificate checks, including the
|
|
343
|
+
authority pinned for a company's own server, still apply. A proxy that
|
|
344
|
+
inspects TLS must leave the Phigon endpoints alone; the observer never turns
|
|
345
|
+
certificate checks off.
|
|
346
|
+
- The telemetry stream uses the same settings, but it can use only an
|
|
347
|
+
`http://` proxy address, and it cannot check ports or address ranges in
|
|
348
|
+
`NO_PROXY`. Set `grpc_proxy` (and `no_grpc_proxy`) to give the stream
|
|
349
|
+
different ones.
|
|
350
|
+
- Node.js 24.14 or newer applies these settings by itself. On Node.js 24.5 to
|
|
351
|
+
24.13, also set `NODE_USE_ENV_PROXY=1` in the environment that starts the
|
|
352
|
+
observer.
|
|
353
|
+
|
|
200
354
|
## Custom agents
|
|
201
355
|
|
|
202
356
|
To monitor an agent without a built-in adapter, register its local signals once:
|
|
@@ -308,6 +462,32 @@ ones started outside `guardian launch`. Discovery happens after launch, so it
|
|
|
308
462
|
cannot undo earlier activity. A company that must prevent bypass also needs
|
|
309
463
|
operating-system application control and a controlled model provider proxy.
|
|
310
464
|
|
|
465
|
+
## Uninstall
|
|
466
|
+
|
|
467
|
+
To remove this computer from the workspace and delete everything the observer
|
|
468
|
+
keeps on it, then the program itself:
|
|
469
|
+
|
|
470
|
+
```sh
|
|
471
|
+
phigon-observer remove-machine --purge
|
|
472
|
+
npm uninstall --global @phigon/observer
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
`remove-machine --purge` does what `remove-machine` does (collection stops and
|
|
476
|
+
this computer's key is revoked), then stops and removes the background
|
|
477
|
+
service and deletes every file the observer keeps in its data directory,
|
|
478
|
+
including activity that was not delivered yet. It removes only files the
|
|
479
|
+
observer created, and the data directory itself once it is empty. It also
|
|
480
|
+
works on a computer that is no longer paired. If the workspace cannot be
|
|
481
|
+
reached, nothing is deleted and the service is started again.
|
|
482
|
+
|
|
483
|
+
Without `--purge`, `remove-machine` keeps the observer's local progress files
|
|
484
|
+
so the computer can be paired again where it left off. Use a separate
|
|
485
|
+
`service uninstall` to remove only the background service.
|
|
486
|
+
|
|
487
|
+
Either way, the activity the company already collected stays in the workspace
|
|
488
|
+
until an administrator deletes the computer or it expires under the retention
|
|
489
|
+
policy; removing the observer from a computer never erases it.
|
|
490
|
+
|
|
311
491
|
## Troubleshooting
|
|
312
492
|
|
|
313
493
|
- **Command not found:** put npm's global bin directory on `PATH` and reopen
|
|
@@ -315,7 +495,10 @@ operating-system application control and a controlled model provider proxy.
|
|
|
315
495
|
- **Expired pairing code:** generate a new one in **Connect machine**.
|
|
316
496
|
- **No conversations:** the metadata profile excludes content. Check with
|
|
317
497
|
`phigon-observer doctor --profile full --json`.
|
|
318
|
-
- **
|
|
498
|
+
- **Collection stops after a restart:** install the background service with
|
|
499
|
+
`phigon-observer service install`, and read `logs/observer.log` in the data
|
|
500
|
+
directory.
|
|
501
|
+
- **Disconnected:** keep the observer running and allow its HTTPS and gRPC endpoints.
|
|
319
502
|
Queued activity is delivered when the connection returns.
|
|
320
503
|
- **Older self-hosted pairing without a saved stream endpoint:** pass
|
|
321
504
|
`run --grpc-url https://stream.your-company.example` or set `PHIGON_GRPC_URL`.
|
|
@@ -329,7 +512,7 @@ More help: [setup guide](https://phigon.online/docs/get-started/),
|
|
|
329
512
|
|
|
330
513
|
## Building from source
|
|
331
514
|
|
|
332
|
-
You need Node.js 24+ and Go 1.26+.
|
|
515
|
+
You need Node.js 24.5+ and Go 1.26+.
|
|
333
516
|
|
|
334
517
|
```sh
|
|
335
518
|
npm ci
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wait `milliseconds`, or less once `signal` aborts. An abort ends the wait
|
|
3
|
+
* quietly; it never rejects.
|
|
4
|
+
*
|
|
5
|
+
* The observer's loops wait here for their whole lifetime, some every 100 ms,
|
|
6
|
+
* on one long-lived signal. The promise timer removes its abort listener when
|
|
7
|
+
* it fires, so finished waits leave nothing attached to that signal.
|
|
8
|
+
*/
|
|
9
|
+
export declare function abortableDelay(milliseconds: number, signal?: AbortSignal): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=abortable-delay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abortable-delay.d.ts","sourceRoot":"","sources":["../../src/abortable-delay.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
2
|
+
/**
|
|
3
|
+
* Wait `milliseconds`, or less once `signal` aborts. An abort ends the wait
|
|
4
|
+
* quietly; it never rejects.
|
|
5
|
+
*
|
|
6
|
+
* The observer's loops wait here for their whole lifetime, some every 100 ms,
|
|
7
|
+
* on one long-lived signal. The promise timer removes its abort listener when
|
|
8
|
+
* it fires, so finished waits leave nothing attached to that signal.
|
|
9
|
+
*/
|
|
10
|
+
export async function abortableDelay(milliseconds, signal) {
|
|
11
|
+
if (signal?.aborted === true)
|
|
12
|
+
return;
|
|
13
|
+
try {
|
|
14
|
+
await delay(milliseconds, undefined, signal === undefined ? {} : { signal });
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (!(error instanceof Error && error.name === "AbortError"))
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=abortable-delay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abortable-delay.js","sourceRoot":"","sources":["../../src/abortable-delay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,YAAoB,EACpB,MAAoB;IAEpB,IAAI,MAAM,EAAE,OAAO,KAAK,IAAI;QAAE,OAAO;IACrC,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,YAAY,EAAE,SAAS,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;YAAE,MAAM,KAAK,CAAC;IAC5E,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../../../src/activity/adapters/claude.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAGV,qBAAqB,EACtB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../../../src/activity/adapters/claude.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAGV,qBAAqB,EACtB,MAAM,aAAa,CAAC;AA4IrB,eAAO,MAAM,qBAAqB,EAAE,qBACP,CAAC"}
|
|
@@ -2,6 +2,8 @@ import { ActivityKind, AgentKind, } from "../../generated/phigon/v1/common_pb.js
|
|
|
2
2
|
import { LifecyclePhase, ToolPhase, } from "../../generated/phigon/v1/telemetry_pb.js";
|
|
3
3
|
import { activityDraft, errorDraft, lifecycleDraft, toolDrafts, } from "../normalize.js";
|
|
4
4
|
import { extractText, objectValue, recordObservedAt, stringField, } from "../record.js";
|
|
5
|
+
// A tool call whose result never arrives must not stay in memory forever.
|
|
6
|
+
const maxTrackedToolCalls = 4_096;
|
|
5
7
|
class ClaudeActivityAdapter {
|
|
6
8
|
id = "claude";
|
|
7
9
|
agentKind = AgentKind.CLAUDE;
|
|
@@ -57,8 +59,14 @@ class ClaudeActivityAdapter {
|
|
|
57
59
|
if (blockType === "tool_use") {
|
|
58
60
|
const id = stringField(item, "id");
|
|
59
61
|
const name = stringField(item, "name") || "tool";
|
|
60
|
-
if (id !== "")
|
|
62
|
+
if (id !== "") {
|
|
61
63
|
this.#toolNames.set(id, name);
|
|
64
|
+
if (this.#toolNames.size > maxTrackedToolCalls) {
|
|
65
|
+
const oldest = this.#toolNames.keys().next().value;
|
|
66
|
+
if (oldest !== undefined)
|
|
67
|
+
this.#toolNames.delete(oldest);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
62
70
|
drafts.push(...toolDrafts(this.agentKind, observedContext, {
|
|
63
71
|
invocationId: id,
|
|
64
72
|
toolName: name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../../../src/activity/adapters/claude.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,GACV,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,cAAc,EACd,SAAS,GACV,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,WAAW,GACZ,MAAM,cAAc,CAAC;AAOtB,MAAM,qBAAqB;IAChB,EAAE,GAAG,QAAQ,CAAC;IACd,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC;IAC7B,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEhD,KAAK,CAAC,MAAe,EAAE,OAAqB;QAC1C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;YACnC,IAAI,MAAM,KAAK,IAAI;gBAAE,OAAO,EAAE,CAAC;YAC/B,MAAM,eAAe,GAAG;gBACtB,GAAG,OAAO;gBACV,UAAU,EAAE,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC;aACz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AA0B,EAC9B,IAAI,EACJ,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,iBAAiB,EACrD,GAAG,IAAI,UAAU,CAClB,CAAC,CAAC;YACL,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,qBAAqB,GAChC,IAAI,qBAAqB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-compatible.d.ts","sourceRoot":"","sources":["../../../../src/activity/adapters/openai-compatible.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACf,MAAM,wCAAwC,CAAC;AAmBhD,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"openai-compatible.d.ts","sourceRoot":"","sources":["../../../../src/activity/adapters/openai-compatible.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACf,MAAM,wCAAwC,CAAC;AAmBhD,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAKrB,wBAAgB,6BAA6B,CAC3C,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,MAAM,GAClB,qBAAqB,CA0IvB"}
|
|
@@ -2,6 +2,8 @@ import { ActivityKind, } from "../../generated/phigon/v1/common_pb.js";
|
|
|
2
2
|
import { LifecyclePhase, ToolPhase, } from "../../generated/phigon/v1/telemetry_pb.js";
|
|
3
3
|
import { activityDraft, errorDraft, lifecycleDraft, toolDrafts, } from "../normalize.js";
|
|
4
4
|
import { arrayField, extractText, nestedField, objectValue, recordObservedAt, stringField, } from "../record.js";
|
|
5
|
+
// A tool call whose result never arrives must not stay in memory forever.
|
|
6
|
+
const maxTrackedToolCalls = 4_096;
|
|
5
7
|
export function createOpenAICompatibleAdapter(id, agentKind, displayName) {
|
|
6
8
|
const toolNames = new Map();
|
|
7
9
|
return {
|
|
@@ -74,8 +76,14 @@ export function createOpenAICompatibleAdapter(id, agentKind, displayName) {
|
|
|
74
76
|
const callID = stringField(call, "id") || stringField(call, "call_id");
|
|
75
77
|
const name = stringField(call, "name") ||
|
|
76
78
|
String(nestedField(call, "function", "name") ?? "tool");
|
|
77
|
-
if (callID !== "")
|
|
79
|
+
if (callID !== "") {
|
|
78
80
|
toolNames.set(callID, name);
|
|
81
|
+
if (toolNames.size > maxTrackedToolCalls) {
|
|
82
|
+
const oldest = toolNames.keys().next().value;
|
|
83
|
+
if (oldest !== undefined)
|
|
84
|
+
toolNames.delete(oldest);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
79
87
|
drafts.push(...toolDrafts(agentKind, observedContext, {
|
|
80
88
|
invocationId: callID,
|
|
81
89
|
toolName: name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-compatible.js","sourceRoot":"","sources":["../../../../src/activity/adapters/openai-compatible.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAEb,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,cAAc,EACd,SAAS,GACV,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,WAAW,GACZ,MAAM,cAAc,CAAC;AAMtB,MAAM,UAAU,6BAA6B,CAC3C,EAAU,EACV,SAAoB,EACpB,WAAmB;IAEnB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,OAAO;QACL,EAAE;QACF,SAAS;QACT,KAAK,CAAC,MAAM,EAAE,OAAO;YACnB,IA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AI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAC9D,MAAM,MAAM,GAAoB,EAAE,CAAC;gBACnC,MAAM,SAAS,GAAG;oBAChB,GAAG,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC;oBACpC,GAAG,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC;iBACpC,CAAC;gBACF,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;oBAC3C,MAAM,MAAM,GACV,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;oBAC1D,MAAM,IAAI,GACR,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;wBACzB,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,CAAC;oBAC1D,IAAI,MAAM,KAAK,EAAE;
|
|
1
|
+
{"version":3,"file":"openai-compatible.js","sourceRoot":"","sources":["../../../../src/activity/adapters/openai-compatible.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAEb,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,cAAc,EACd,SAAS,GACV,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,WAAW,GACZ,MAAM,cAAc,CAAC;AAMtB,0EAA0E;AAC1E,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAElC,MAAM,UAAU,6BAA6B,CAC3C,EAAU,EACV,SAAoB,EACpB,WAAmB;IAEnB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,OAAO;QACL,EAAE;QACF,SAAS;QACT,KAAK,CAAC,MAAM,EAAE,OA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M,CAAC;YAChB,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -3,7 +3,7 @@ import type { CollectionPolicy } from "../config.js";
|
|
|
3
3
|
import type { StoredMachineCredential } from "../credential-store.js";
|
|
4
4
|
import { type AgentIdentity, type AgentInventory } from "../generated/phigon/v1/identity_pb.js";
|
|
5
5
|
import { type EventEnvelope } from "../generated/phigon/v1/telemetry_pb.js";
|
|
6
|
-
import { JSONLSourceReader, type ActivitySource } from "./source-reader.js";
|
|
6
|
+
import { JSONLSourceReader, type ActivitySource, type SourceFailure } from "./source-reader.js";
|
|
7
7
|
export declare const historySyncQueueHeadroom = 1024;
|
|
8
8
|
export type ActivityCollectorMetrics = Readonly<{
|
|
9
9
|
sourceRecords: number;
|
|
@@ -15,6 +15,10 @@ export type ActivityCollectorMetrics = Readonly<{
|
|
|
15
15
|
lastSequence: bigint;
|
|
16
16
|
pendingCheckpoints: number;
|
|
17
17
|
backpressuredScans: number;
|
|
18
|
+
/** Scans whose records delivery refused; they are read again later. */
|
|
19
|
+
refusedDeliveries: number;
|
|
20
|
+
/** Sources or files currently skipped after a failure. */
|
|
21
|
+
failingSources: number;
|
|
18
22
|
}>;
|
|
19
23
|
export type HistorySyncSummary = Readonly<{
|
|
20
24
|
filesDiscovered: number;
|
|
@@ -28,6 +32,12 @@ export type ActivityCollectorOptions = Readonly<{
|
|
|
28
32
|
initialSequence: bigint;
|
|
29
33
|
initialAcknowledgedSequence?: bigint;
|
|
30
34
|
durableDelivery?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Makes every event emitted so far durable, for example by writing the
|
|
37
|
+
* buffered telemetry spool. With durable delivery a source checkpoint
|
|
38
|
+
* moves past an unacknowledged event only after this succeeds.
|
|
39
|
+
*/
|
|
40
|
+
flushDelivery?: () => void | Promise<void>;
|
|
31
41
|
emit: (event: EventEnvelope) => void;
|
|
32
42
|
sources?: readonly ActivitySource[];
|
|
33
43
|
additionalSources?: () => Promise<readonly ActivitySource[]>;
|
|
@@ -37,6 +47,16 @@ export type ActivityCollectorOptions = Readonly<{
|
|
|
37
47
|
canCollect?: () => boolean;
|
|
38
48
|
canSyncHistory?: () => boolean;
|
|
39
49
|
onSourceIdentity?: (identity: AgentIdentity) => void | Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Called when delivery first refuses an event after accepting the
|
|
52
|
+
* previous ones, for example because the spool is full.
|
|
53
|
+
*/
|
|
54
|
+
onDeliveryRefused?: (error: unknown) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Called when a source (or one of its files) starts failing. It is
|
|
57
|
+
* skipped for a while and retried; every other source keeps collecting.
|
|
58
|
+
*/
|
|
59
|
+
onSourceFailure?: (failure: SourceFailure) => void;
|
|
40
60
|
}>;
|
|
41
61
|
export declare class ActivityCollector {
|
|
42
62
|
#private;
|
|
@@ -48,12 +68,22 @@ export declare class ActivityCollector {
|
|
|
48
68
|
scanOnce(): Promise<ActivityCollectorMetrics>;
|
|
49
69
|
syncHistory(signal?: AbortSignal): Promise<HistorySyncSummary>;
|
|
50
70
|
run(signal: AbortSignal): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Deletes bridge files this observer is done with: an `ingest` file or a
|
|
73
|
+
* closed journal segment whose records were all read under a checkpoint
|
|
74
|
+
* the server has acknowledged through, or any of them after seven days.
|
|
75
|
+
* A file an `ingest` run is still writing, and each journal's newest
|
|
76
|
+
* segment, are never deleted while in use.
|
|
77
|
+
*/
|
|
78
|
+
pruneBridgeFiles(): Promise<void>;
|
|
51
79
|
/**
|
|
52
80
|
* Release the database connections the live reader keeps open. A later
|
|
53
81
|
* scan opens them again.
|
|
54
82
|
*/
|
|
55
83
|
close(): void;
|
|
56
84
|
metrics(): ActivityCollectorMetrics;
|
|
85
|
+
/** Sources and files skipped after a failure, by the live and history readers. */
|
|
86
|
+
sourceFailures(): readonly SourceFailure[];
|
|
57
87
|
sourceIdentities(): AgentIdentity[];
|
|
58
88
|
}
|
|
59
89
|
export declare function mergeInventoryWithSourceIdentities(inventory: AgentInventory, sourceIdentities: readonly AgentIdentity[]): AgentInventory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../../src/activity/collector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../../src/activity/collector.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAMtE,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,wCAAwC,CAAC;AA+BhD,OAAO,EAEL,iBAAiB,EAEjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAEnB,MAAM,oBAAoB,CAAC;AAe5B,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AA0C9C,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,uEAAuE;IACvE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,cAAc,EAAE,MAAM,CAAC;CACxB,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