agentic-pi 0.2.3 → 0.2.5
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 +123 -2
- package/dist/args.d.ts +30 -0
- package/dist/args.js +51 -0
- package/dist/args.js.map +1 -1
- package/dist/extensions/file-search/index.d.ts +66 -0
- package/dist/extensions/file-search/index.js +86 -0
- package/dist/extensions/file-search/index.js.map +1 -0
- package/dist/run.d.ts +42 -0
- package/dist/run.js +23 -0
- package/dist/run.js.map +1 -1
- package/dist/runner.js +88 -1
- package/dist/runner.js.map +1 -1
- package/dist/telemetry/config.d.ts +59 -0
- package/dist/telemetry/config.js +70 -0
- package/dist/telemetry/config.js.map +1 -0
- package/dist/telemetry/index.d.ts +49 -0
- package/dist/telemetry/index.js +45 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/mapper.d.ts +80 -0
- package/dist/telemetry/mapper.js +334 -0
- package/dist/telemetry/mapper.js.map +1 -0
- package/dist/telemetry/sdk.d.ts +13 -0
- package/dist/telemetry/sdk.js +147 -0
- package/dist/telemetry/sdk.js.map +1 -0
- package/dist/telemetry/semconv.d.ts +72 -0
- package/dist/telemetry/semconv.js +73 -0
- package/dist/telemetry/semconv.js.map +1 -0
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -246,6 +246,114 @@ When skipped (no keys / `--no-web-search`), `status: "skipped"` carries a
|
|
|
246
246
|
(explicit provider whose key is missing, or an unknown provider name)
|
|
247
247
|
surface as a warning before the run starts.
|
|
248
248
|
|
|
249
|
+
### 9. Default file search via FFF
|
|
250
|
+
|
|
251
|
+
agentic-pi bundles [`@ff-labs/pi-fff`](https://github.com/dmtrKovalenko/fff/tree/main/packages/pi-fff)
|
|
252
|
+
— a Rust-backed, git-aware, frecency-ranked, SIMD-accelerated fuzzy file/content
|
|
253
|
+
search — as the **default** file-search backend. It ships as a dependency and is
|
|
254
|
+
loaded for **every** run with no per-host `pi install` required.
|
|
255
|
+
|
|
256
|
+
**`override` mode by default.** FFF registers under Pi's built-in tool names
|
|
257
|
+
(`find`, `grep`, `multi_grep`), transparently replacing the built-ins. The agent
|
|
258
|
+
gets faster, git-aware search with zero prompt changes. Switch behaviour with
|
|
259
|
+
`--file-search-mode`:
|
|
260
|
+
|
|
261
|
+
| Mode | Tool names | Notes |
|
|
262
|
+
| --- | --- | --- |
|
|
263
|
+
| `override` (default) | `find`, `grep`, `multi_grep` | Transparent replacement of Pi's built-ins. |
|
|
264
|
+
| `tools-only` | `fffind`, `ffgrep`, `fff-multi-grep` | Added alongside Pi's built-ins; the agent chooses. |
|
|
265
|
+
| `tools-and-ui` | same as `tools-only` | Adds `@`-mention autocomplete — useless headless; not recommended. |
|
|
266
|
+
|
|
267
|
+
The CLI flag maps to FFF's `PI_FFF_MODE` env var. An explicit `PI_FFF_MODE` in the
|
|
268
|
+
environment wins over the flag. Pass `--no-file-search` to disable FFF entirely and
|
|
269
|
+
fall back to Pi's built-in `find`/`grep`.
|
|
270
|
+
|
|
271
|
+
**Host-process execution.** Like web search, FFF runs in the agentic-pi process,
|
|
272
|
+
**not** inside the Gondolin guest. Under `--sandbox gondolin`, `read`/`write`/`edit`/
|
|
273
|
+
`bash` route through the VM while `find`/`grep` (FFF) run host-side against the
|
|
274
|
+
bind-mounted workspace. Paths align (cwd is the mount), and FFF only touches the
|
|
275
|
+
local filesystem — no egress or secret exposure.
|
|
276
|
+
|
|
277
|
+
**Native binary.** FFF is a native Rust library (`@ff-labs/fff-node`) shipped as
|
|
278
|
+
prebuilt per-platform binaries (`fff-bin-linux-x64-gnu`/`-musl`, `darwin`, `win32`).
|
|
279
|
+
npm auto-selects the correct one at install time. In containers, run `npm install`
|
|
280
|
+
on the target platform — do **not** copy `node_modules` across glibc↔musl.
|
|
281
|
+
|
|
282
|
+
**Safe by default.** If pi-fff can't be resolved or its native binary fails to load
|
|
283
|
+
on the platform, the run is **not** aborted — file search skips with
|
|
284
|
+
`reason: "resolve-failed"` (surfaced as a warning) and the agent falls back to Pi's
|
|
285
|
+
built-in `find`/`grep`.
|
|
286
|
+
|
|
287
|
+
**Event stream.** A third `extension_status` event mirrors the others:
|
|
288
|
+
|
|
289
|
+
```jsonl
|
|
290
|
+
{"type":"extension_status","extension":"file-search","status":"configured","mode":"override","toolCount":3,"sessionId":"…","timestamp":"…"}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
When disabled or unavailable, `status: "skipped"` carries a `reason` of
|
|
294
|
+
`disabled-by-flag` or `resolve-failed`.
|
|
295
|
+
|
|
296
|
+
### 10. Optional OpenTelemetry export via `--otel`
|
|
297
|
+
|
|
298
|
+
agentic-pi can export **traces and metrics** for its run to any OTLP-compatible
|
|
299
|
+
collector, using the standard OpenTelemetry JS SDK and the standard `OTEL_*`
|
|
300
|
+
environment variables. This is meant for orchestrators (e.g. lastlight) that
|
|
301
|
+
forward `OTEL_*` config into a sandboxed agentic-pi process so Pi's own activity
|
|
302
|
+
shows up in their observability stack.
|
|
303
|
+
|
|
304
|
+
**Off unless explicitly enabled.** Enablement precedence (highest first):
|
|
305
|
+
|
|
306
|
+
1. `--no-otel` → force-disabled (wins over everything).
|
|
307
|
+
2. `--otel` → enabled.
|
|
308
|
+
3. env `AGENTIC_PI_OTEL_ENABLED=1` (when neither flag is passed) → enabled.
|
|
309
|
+
4. otherwise → disabled.
|
|
310
|
+
|
|
311
|
+
A bare `OTEL_EXPORTER_OTLP_ENDPOINT` does **not** enable telemetry on its own —
|
|
312
|
+
enablement is always intentional. Configure the destination with the usual
|
|
313
|
+
`OTEL_EXPORTER_OTLP_ENDPOINT` / `OTEL_EXPORTER_OTLP_HEADERS` /
|
|
314
|
+
`OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` (etc.) variables, or `--otel-endpoint` as a
|
|
315
|
+
base-URL escape hatch.
|
|
316
|
+
|
|
317
|
+
**Span tree** (one-shot run → a short-lived root span is correct):
|
|
318
|
+
|
|
319
|
+
```
|
|
320
|
+
agentic_pi.session (root; gen_ai.conversation.id = sessionId)
|
|
321
|
+
└── agentic_pi.turn
|
|
322
|
+
├── chat <model> (per assistant message; tokens, cost, finish reason)
|
|
323
|
+
└── execute_tool <name> (per tool call; status, duration)
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**Metrics**: `gen_ai.client.token.usage`, `gen_ai.client.operation.duration`,
|
|
327
|
+
`agentic_pi.cost.usd`, `agentic_pi.tool.duration`, `agentic_pi.tool.invocations`,
|
|
328
|
+
`agentic_pi.tool.failures`, `agentic_pi.turns`. Attribute names follow the OTEL
|
|
329
|
+
GenAI semantic conventions where stable, namespaced under `agentic_pi.*` otherwise.
|
|
330
|
+
|
|
331
|
+
**Metadata-only by default.** Raw prompt/message/tool-result content is **never**
|
|
332
|
+
exported unless you pass `--otel-include-content` (or set
|
|
333
|
+
`AGENTIC_PI_OTEL_INCLUDE_CONTENT=1`), in which case content is bounded and
|
|
334
|
+
truncated. Metric dimensions are always metadata (bounded cardinality).
|
|
335
|
+
|
|
336
|
+
**Trace correlation.** If a W3C `TRACEPARENT` env var is present, the session
|
|
337
|
+
span is parented to it, so a sandboxed agentic-pi run correlates with the
|
|
338
|
+
caller's trace across the process/container boundary.
|
|
339
|
+
|
|
340
|
+
**Safe by default.** Telemetry never affects the run's exit code, never writes to
|
|
341
|
+
stdout/stderr (SDK diagnostics route to the warning channel), and degrades to a
|
|
342
|
+
warning if the collector is unreachable. When requested, a final
|
|
343
|
+
`extension_status` event mirrors the others:
|
|
344
|
+
|
|
345
|
+
```jsonl
|
|
346
|
+
{"type":"extension_status","extension":"telemetry","status":"configured","includeContent":false,"sessionId":"…","timestamp":"…"}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
A silent default run (no `--otel`) emits no telemetry event at all.
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
# Export to a local collector (e.g. otel-desktop-viewer, Jaeger, Grafana Alloy)
|
|
353
|
+
echo "summarize the repo" | OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \
|
|
354
|
+
node dist/cli.js run --model openai/gpt-5.4-nano --otel --no-session
|
|
355
|
+
```
|
|
356
|
+
|
|
249
357
|
## When to use this
|
|
250
358
|
|
|
251
359
|
- You have an orchestrator that calls a coding agent once per workflow
|
|
@@ -261,8 +369,9 @@ surface as a warning before the run starts.
|
|
|
261
369
|
- You want generic MCP support. Pi has none by design and agentic-pi inherits
|
|
262
370
|
that decision; only the GitHub tool surface is built-in.
|
|
263
371
|
- You want a different tool surface (Linear, GitLab, internal APIs). Fork the
|
|
264
|
-
`extensions/github/` directory as a template
|
|
265
|
-
|
|
372
|
+
`extensions/github/` directory as a template. agentic-pi bundles specific Pi
|
|
373
|
+
extensions (GitHub, web search, FFF file search) but does not (yet) load
|
|
374
|
+
arbitrary operator-supplied extensions as a runtime plugin system.
|
|
266
375
|
|
|
267
376
|
## Usage
|
|
268
377
|
|
|
@@ -307,7 +416,14 @@ GITHUB_TOKEN=ghp_…
|
|
|
307
416
|
| `--no-network` | Disable sandbox HTTP egress entirely. Ignored when `--sandbox=none`. |
|
|
308
417
|
| `--web-search-provider <p>` | Force web-search provider: `tavily` \| `brave` \| `exa`. Default: auto-detect by env. See section 8. |
|
|
309
418
|
| `--no-web-search` | Disable the web-search extension (no `web_search`/`web_fetch` tools). |
|
|
419
|
+
| `--no-file-search` | Disable the bundled FFF file-search extension; fall back to Pi's built-in `find`/`grep`. |
|
|
420
|
+
| `--file-search-mode <m>` | FFF mode: `override` (default) \| `tools-only` \| `tools-and-ui`. Overridden by the `PI_FFF_MODE` env var. See section 9. |
|
|
310
421
|
| `--web-search-max-calls <n>` | Cap combined `web_search` + `web_fetch` calls per run. Default: 30. |
|
|
422
|
+
| `--otel` | Enable OpenTelemetry traces + metrics export. Off by default. Requires an OTLP endpoint via `OTEL_EXPORTER_OTLP_ENDPOINT` (or `--otel-endpoint`). See section 10. |
|
|
423
|
+
| `--no-otel` | Force-disable OTEL even if `AGENTIC_PI_OTEL_ENABLED=1`. |
|
|
424
|
+
| `--otel-include-content` | Attach prompt/message/tool content to spans (bounded + truncated). Default: metadata-only. |
|
|
425
|
+
| `--otel-service-name <n>` | Override `OTEL_SERVICE_NAME` (default: `agentic-pi`). |
|
|
426
|
+
| `--otel-endpoint <url>` | Override `OTEL_EXPORTER_OTLP_ENDPOINT` base URL. |
|
|
311
427
|
|
|
312
428
|
Reads the prompt from stdin. Emits JSONL on stdout. Exits 0 on `agent_end`,
|
|
313
429
|
1 on fatal error.
|
|
@@ -319,6 +435,7 @@ Reads the prompt from stdin. Emits JSONL on stdout. Exits 0 on `agent_end`,
|
|
|
319
435
|
{"type":"sandbox_status","backend":"none","status":{"backend":"none"},"sessionId":"<uuid>","timestamp":"…"}
|
|
320
436
|
{"type":"extension_status","extension":"github","status":"configured","profile":"read","toolCount":18,"sessionId":"<uuid>","timestamp":"…"}
|
|
321
437
|
{"type":"extension_status","extension":"web-search","status":"configured","provider":"tavily","toolCount":2,"maxCalls":30,"sessionId":"<uuid>","timestamp":"…"}
|
|
438
|
+
{"type":"extension_status","extension":"file-search","status":"configured","mode":"override","toolCount":3,"sessionId":"<uuid>","timestamp":"…"}
|
|
322
439
|
{"type":"agent_start","sessionId":"<uuid>","timestamp":"…"}
|
|
323
440
|
{"type":"turn_start","sessionId":"<uuid>","timestamp":"…"}
|
|
324
441
|
{"type":"message_start","message":{…},"sessionId":"<uuid>","timestamp":"…"}
|
|
@@ -399,6 +516,7 @@ console.log(result.records.length); // full event log
|
|
|
399
516
|
| `sandbox` | `{backend, status}` \| `undefined` | Mirror of the `sandbox_status` event. |
|
|
400
517
|
| `github` | `{status, reason, profile, toolCount}` \| `undefined` | Mirror of the GitHub `extension_status` event. |
|
|
401
518
|
| `webSearch` | `{status, reason, provider, toolCount, maxCalls}` \| `undefined` | Mirror of the web-search `extension_status` event. |
|
|
519
|
+
| `fileSearch` | `{status, reason, mode, toolCount}` \| `undefined` | Mirror of the FFF file-search `extension_status` event. |
|
|
402
520
|
| `records` | `EmitterRecord[]` | Every JSONL record in order. Same shape that the CLI writes. |
|
|
403
521
|
| `warnings` | `string[]` | Warnings that would have gone to stderr in CLI mode. |
|
|
404
522
|
|
|
@@ -450,6 +568,7 @@ which walks `test/` for `*.test.ts`.
|
|
|
450
568
|
| `test/extensions/github/profiles.test.ts` | Profile → tool allowlist (counts, superset structure, scope tiering) | — |
|
|
451
569
|
| `test/extensions/github/credentials.test.ts` | `assertSafeToken` and `credentialsFilePath` validation | — |
|
|
452
570
|
| `test/extensions/web-search/*.test.ts` | Provider selection, extension wiring, safe-fetch rails, HTML extraction, rate limiter, per-provider normalization (all with injected `fetchImpl`) | — |
|
|
571
|
+
| `test/extensions/file-search/index.test.ts` | FFF extension wiring: mode → tool names, package resolution, disabled-by-flag + resolve-failed skips | — |
|
|
453
572
|
| `test/sandbox/preflight.test.ts` | Preflight returns a structured ok\|error result | — |
|
|
454
573
|
| `test/run.integration.test.ts` | Programmatic `run()`: RunResult populated, onEvent fires for every record, **child-process check confirms zero stdout/stderr leak from library** | `OPENAI_API_KEY` not set |
|
|
455
574
|
| `test/run-sandbox.integration.test.ts` | `run({ sandbox: "gondolin" })` boots a VM, agent's `write` tool produces a host file via the mount | `OPENAI_API_KEY` not set OR QEMU/preflight unavailable |
|
|
@@ -521,6 +640,8 @@ src/
|
|
|
521
640
|
credentials.ts git credential-store file writer (mode 600)
|
|
522
641
|
profiles.ts 4 profiles → tool name allowlists
|
|
523
642
|
tools.ts 31 defineTool() registrations
|
|
643
|
+
extensions/file-search/
|
|
644
|
+
index.ts loadFileSearchExtension() — resolves bundled @ff-labs/pi-fff
|
|
524
645
|
sandbox/
|
|
525
646
|
index.ts buildSandbox(backend) dispatcher
|
|
526
647
|
preflight.ts QEMU + accelerator detection (refuses to start if hung)
|
package/dist/args.d.ts
CHANGED
|
@@ -76,6 +76,36 @@ export interface RunConfig {
|
|
|
76
76
|
* Set via `--web-search-max-calls <n>`.
|
|
77
77
|
*/
|
|
78
78
|
webSearchMaxCalls?: number;
|
|
79
|
+
/**
|
|
80
|
+
* File-search extension (FFF) toggle. Default: true — bundled and
|
|
81
|
+
* enabled for every run. Pass `--no-file-search` to fall back to Pi's
|
|
82
|
+
* built-in find/grep.
|
|
83
|
+
*/
|
|
84
|
+
fileSearch: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* FFF mode. Default: "override" (FFF replaces built-in find/grep under
|
|
87
|
+
* the same names). Set via `--file-search-mode <override|tools-only|tools-and-ui>`.
|
|
88
|
+
*/
|
|
89
|
+
fileSearchMode?: "override" | "tools-only" | "tools-and-ui";
|
|
90
|
+
/**
|
|
91
|
+
* OpenTelemetry traces + metrics export. Tri-state:
|
|
92
|
+
* - `true` (`--otel`) → enabled.
|
|
93
|
+
* - `false` (`--no-otel`) → force-disabled (wins over env).
|
|
94
|
+
* - `undefined` (unset) → enabled iff env AGENTIC_PI_OTEL_ENABLED is truthy.
|
|
95
|
+
* Off by default. Requires an OTLP endpoint via OTEL_EXPORTER_OTLP_ENDPOINT
|
|
96
|
+
* (or `--otel-endpoint`). Standard OTEL_* env vars are honored by the SDK.
|
|
97
|
+
*/
|
|
98
|
+
otel?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Export raw prompt/message/tool content on spans (bounded + truncated).
|
|
101
|
+
* Default: false (metadata-only). Set via `--otel-include-content` or env
|
|
102
|
+
* AGENTIC_PI_OTEL_INCLUDE_CONTENT.
|
|
103
|
+
*/
|
|
104
|
+
otelIncludeContent?: boolean;
|
|
105
|
+
/** Override OTEL_SERVICE_NAME (default: "agentic-pi"). */
|
|
106
|
+
otelServiceName?: string;
|
|
107
|
+
/** Override OTEL_EXPORTER_OTLP_ENDPOINT (escape hatch; prefer the env var). */
|
|
108
|
+
otelEndpoint?: string;
|
|
79
109
|
}
|
|
80
110
|
export declare function printHelp(): void;
|
|
81
111
|
export declare function parseArgs(argv: string[]): RunConfig;
|
package/dist/args.js
CHANGED
|
@@ -43,6 +43,22 @@ Flags:
|
|
|
43
43
|
--web-search-max-calls <n> Cap combined web_search + web_fetch calls per run.
|
|
44
44
|
Default: 30. When exceeded, further calls return a
|
|
45
45
|
structured error result.
|
|
46
|
+
--no-file-search Disable the bundled FFF file-search extension; fall
|
|
47
|
+
back to Pi's built-in find/grep.
|
|
48
|
+
--file-search-mode <m> FFF mode: override | tools-only | tools-and-ui.
|
|
49
|
+
Default: override (FFF replaces built-in find/grep
|
|
50
|
+
under the same names). Overridden by PI_FFF_MODE env.
|
|
51
|
+
--otel Enable OpenTelemetry traces + metrics export.
|
|
52
|
+
Off by default. Requires an OTLP endpoint via
|
|
53
|
+
OTEL_EXPORTER_OTLP_ENDPOINT (or --otel-endpoint).
|
|
54
|
+
Honors standard OTEL_* env vars. Can also be
|
|
55
|
+
enabled with AGENTIC_PI_OTEL_ENABLED=1.
|
|
56
|
+
--no-otel Force-disable OTEL even if AGENTIC_PI_OTEL_ENABLED
|
|
57
|
+
is set (highest precedence).
|
|
58
|
+
--otel-include-content Attach prompt/message/tool content to spans
|
|
59
|
+
(bounded + truncated). Default: metadata-only.
|
|
60
|
+
--otel-service-name <n> Override OTEL_SERVICE_NAME (default: agentic-pi).
|
|
61
|
+
--otel-endpoint <url> Override OTEL_EXPORTER_OTLP_ENDPOINT base URL.
|
|
46
62
|
--sandbox-image <name> Image to boot when --sandbox=gondolin. Values:
|
|
47
63
|
'default' (recommended) — bundled agentic-pi-dev image
|
|
48
64
|
with git/gh/node/python/rust baked in (auto-downloaded).
|
|
@@ -64,6 +80,7 @@ export function parseArgs(argv) {
|
|
|
64
80
|
dangerouslySkipPermissions: false,
|
|
65
81
|
sandbox: "none",
|
|
66
82
|
webSearch: true,
|
|
83
|
+
fileSearch: true,
|
|
67
84
|
};
|
|
68
85
|
for (let i = 0; i < argv.length; i++) {
|
|
69
86
|
const arg = argv[i];
|
|
@@ -176,6 +193,40 @@ export function parseArgs(argv) {
|
|
|
176
193
|
config.webSearchMaxCalls = n;
|
|
177
194
|
break;
|
|
178
195
|
}
|
|
196
|
+
case "--no-file-search":
|
|
197
|
+
config.fileSearch = false;
|
|
198
|
+
break;
|
|
199
|
+
case "--file-search-mode": {
|
|
200
|
+
const v = next();
|
|
201
|
+
if (v !== "override" && v !== "tools-only" && v !== "tools-and-ui") {
|
|
202
|
+
throw new Error(`invalid --file-search-mode '${v}'. Expected: override | tools-only | tools-and-ui`);
|
|
203
|
+
}
|
|
204
|
+
config.fileSearchMode = v;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case "--otel":
|
|
208
|
+
config.otel = true;
|
|
209
|
+
break;
|
|
210
|
+
case "--no-otel":
|
|
211
|
+
config.otel = false;
|
|
212
|
+
break;
|
|
213
|
+
case "--otel-include-content":
|
|
214
|
+
config.otelIncludeContent = true;
|
|
215
|
+
break;
|
|
216
|
+
case "--otel-service-name": {
|
|
217
|
+
const v = next().trim();
|
|
218
|
+
if (!v)
|
|
219
|
+
throw new Error("--otel-service-name requires a value");
|
|
220
|
+
config.otelServiceName = v;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
case "--otel-endpoint": {
|
|
224
|
+
const v = next().trim();
|
|
225
|
+
if (!v)
|
|
226
|
+
throw new Error("--otel-endpoint requires a value");
|
|
227
|
+
config.otelEndpoint = v;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
179
230
|
case "-h":
|
|
180
231
|
case "--help":
|
|
181
232
|
printHelp();
|
package/dist/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyGH,MAAM,UAAU,SAAS;IACvB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+DtB,CAAC,CAAC;AACH,CAAC;AAED,MAA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CAAC,uCAAuC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-search extension entry point.
|
|
3
|
+
*
|
|
4
|
+
* Bundles FFF (`@ff-labs/pi-fff`) — a Rust-backed, git-aware,
|
|
5
|
+
* frecency-ranked fuzzy file/content search — as agentic-pi's default
|
|
6
|
+
* file-search backend, so every run gets it without a per-host
|
|
7
|
+
* `pi install`.
|
|
8
|
+
*
|
|
9
|
+
* Unlike the `github` and `web-search` extensions, this one does NOT
|
|
10
|
+
* contribute a `customTools` array. pi-fff is a full Pi extension
|
|
11
|
+
* (registers tools + an `@`-mention enhancer via an ExtensionFactory), so
|
|
12
|
+
* it is loaded through Pi's resource loader, not the SDK's `customTools`
|
|
13
|
+
* channel. This module's job is to:
|
|
14
|
+
*
|
|
15
|
+
* 1. Resolve the installed pi-fff package directory (the value the
|
|
16
|
+
* runner hands to `DefaultResourceLoader.additionalExtensionPaths`).
|
|
17
|
+
* 2. Decide the FFF mode the runner publishes via the `PI_FFF_MODE` env.
|
|
18
|
+
*
|
|
19
|
+
* Mirrors the other extensions' "safe by default" contract: if the
|
|
20
|
+
* package can't be resolved (missing / incompatible native binary), we
|
|
21
|
+
* skip with a reason rather than aborting the run, and the agent falls
|
|
22
|
+
* back to Pi's built-in `find`/`grep`.
|
|
23
|
+
*/
|
|
24
|
+
/** FFF mode. `override` replaces Pi's built-in find/grep under the same names. */
|
|
25
|
+
export type FileSearchMode = "override" | "tools-only" | "tools-and-ui";
|
|
26
|
+
export declare const VALID_FILE_SEARCH_MODES: FileSearchMode[];
|
|
27
|
+
export declare const DEFAULT_FILE_SEARCH_MODE: FileSearchMode;
|
|
28
|
+
export type FileSearchSkipReason = "disabled-by-flag" | "resolve-failed";
|
|
29
|
+
export interface FileSearchExtensionConfig {
|
|
30
|
+
/** When false, the extension is force-skipped (disabled-by-flag). Default: true. */
|
|
31
|
+
fileSearch?: boolean;
|
|
32
|
+
/** FFF mode. Default: "override". */
|
|
33
|
+
fileSearchMode?: FileSearchMode;
|
|
34
|
+
/**
|
|
35
|
+
* Resolver override (injected by tests). Returns the absolute path to the
|
|
36
|
+
* installed `@ff-labs/pi-fff` package directory, or throws.
|
|
37
|
+
*/
|
|
38
|
+
resolvePackageDir?: () => string;
|
|
39
|
+
}
|
|
40
|
+
export interface FileSearchExtensionResult {
|
|
41
|
+
status: "configured" | "skipped";
|
|
42
|
+
reason?: FileSearchSkipReason;
|
|
43
|
+
message?: string;
|
|
44
|
+
/** The FFF mode in effect (echoed for observability). */
|
|
45
|
+
mode?: FileSearchMode;
|
|
46
|
+
/**
|
|
47
|
+
* Absolute path to the pi-fff package directory. The runner passes this
|
|
48
|
+
* to `DefaultResourceLoader.additionalExtensionPaths`. Undefined when
|
|
49
|
+
* skipped.
|
|
50
|
+
*/
|
|
51
|
+
packageDir?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Tool names the agent will see, derived from `mode` (for the
|
|
54
|
+
* `extension_status` event only — the tools themselves are registered by
|
|
55
|
+
* pi-fff, not here).
|
|
56
|
+
*/
|
|
57
|
+
toolNames: string[];
|
|
58
|
+
}
|
|
59
|
+
export declare function loadFileSearchExtension(config?: FileSearchExtensionConfig): FileSearchExtensionResult;
|
|
60
|
+
/**
|
|
61
|
+
* True if the skip is something the user almost certainly wants surfaced
|
|
62
|
+
* as a warning. A resolve failure means file search was meant to work but
|
|
63
|
+
* the install/binary is broken; `disabled-by-flag` is an explicit choice
|
|
64
|
+
* and stays silent.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isMisconfigurationSkip(result: FileSearchExtensionResult): boolean;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-search extension entry point.
|
|
3
|
+
*
|
|
4
|
+
* Bundles FFF (`@ff-labs/pi-fff`) — a Rust-backed, git-aware,
|
|
5
|
+
* frecency-ranked fuzzy file/content search — as agentic-pi's default
|
|
6
|
+
* file-search backend, so every run gets it without a per-host
|
|
7
|
+
* `pi install`.
|
|
8
|
+
*
|
|
9
|
+
* Unlike the `github` and `web-search` extensions, this one does NOT
|
|
10
|
+
* contribute a `customTools` array. pi-fff is a full Pi extension
|
|
11
|
+
* (registers tools + an `@`-mention enhancer via an ExtensionFactory), so
|
|
12
|
+
* it is loaded through Pi's resource loader, not the SDK's `customTools`
|
|
13
|
+
* channel. This module's job is to:
|
|
14
|
+
*
|
|
15
|
+
* 1. Resolve the installed pi-fff package directory (the value the
|
|
16
|
+
* runner hands to `DefaultResourceLoader.additionalExtensionPaths`).
|
|
17
|
+
* 2. Decide the FFF mode the runner publishes via the `PI_FFF_MODE` env.
|
|
18
|
+
*
|
|
19
|
+
* Mirrors the other extensions' "safe by default" contract: if the
|
|
20
|
+
* package can't be resolved (missing / incompatible native binary), we
|
|
21
|
+
* skip with a reason rather than aborting the run, and the agent falls
|
|
22
|
+
* back to Pi's built-in `find`/`grep`.
|
|
23
|
+
*/
|
|
24
|
+
import { createRequire } from "node:module";
|
|
25
|
+
import { dirname } from "node:path";
|
|
26
|
+
export const VALID_FILE_SEARCH_MODES = [
|
|
27
|
+
"override",
|
|
28
|
+
"tools-only",
|
|
29
|
+
"tools-and-ui",
|
|
30
|
+
];
|
|
31
|
+
export const DEFAULT_FILE_SEARCH_MODE = "override";
|
|
32
|
+
/** Tool names FFF exposes per mode (see @ff-labs/pi-fff src/index.ts). */
|
|
33
|
+
function toolNamesForMode(mode) {
|
|
34
|
+
return mode === "override"
|
|
35
|
+
? ["find", "grep", "multi_grep"]
|
|
36
|
+
: ["fffind", "ffgrep", "fff-multi-grep"];
|
|
37
|
+
}
|
|
38
|
+
function defaultResolvePackageDir() {
|
|
39
|
+
// Resolve relative to this module so it works regardless of the
|
|
40
|
+
// consumer's cwd. `@ff-labs/pi-fff/package.json` is always present; its
|
|
41
|
+
// directory is what the loader's package resolver reads the `pi`
|
|
42
|
+
// manifest from.
|
|
43
|
+
const require = createRequire(import.meta.url);
|
|
44
|
+
return dirname(require.resolve("@ff-labs/pi-fff/package.json"));
|
|
45
|
+
}
|
|
46
|
+
export function loadFileSearchExtension(config = {}) {
|
|
47
|
+
if (config.fileSearch === false) {
|
|
48
|
+
return {
|
|
49
|
+
status: "skipped",
|
|
50
|
+
reason: "disabled-by-flag",
|
|
51
|
+
message: "file search disabled via --no-file-search",
|
|
52
|
+
toolNames: [],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const mode = config.fileSearchMode ?? DEFAULT_FILE_SEARCH_MODE;
|
|
56
|
+
const resolve = config.resolvePackageDir ?? defaultResolvePackageDir;
|
|
57
|
+
let packageDir;
|
|
58
|
+
try {
|
|
59
|
+
packageDir = resolve();
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
return {
|
|
63
|
+
status: "skipped",
|
|
64
|
+
reason: "resolve-failed",
|
|
65
|
+
message: `could not resolve @ff-labs/pi-fff: ${err.message}`,
|
|
66
|
+
mode,
|
|
67
|
+
toolNames: [],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
status: "configured",
|
|
72
|
+
mode,
|
|
73
|
+
packageDir,
|
|
74
|
+
toolNames: toolNamesForMode(mode),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* True if the skip is something the user almost certainly wants surfaced
|
|
79
|
+
* as a warning. A resolve failure means file search was meant to work but
|
|
80
|
+
* the install/binary is broken; `disabled-by-flag` is an explicit choice
|
|
81
|
+
* and stays silent.
|
|
82
|
+
*/
|
|
83
|
+
export function isMisconfigurationSkip(result) {
|
|
84
|
+
return result.status === "skipped" && result.reason === "resolve-failed";
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/file-search/index.ts"],"names":[],"m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C;QACb,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,gBAAgB;YACxB,OAAO,EAAE,sCAAuC,GAAa,CAAC,OAAO,EAAE;YACvE,IAAI;YACJ,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,YAAY;QACpB,IAAI;QACJ,UAAU;QACV,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAAC;KAClC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAiC;IACtE,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,gBAAgB,CAAC;AAC3E,CAAC"}
|
package/dist/run.d.ts
CHANGED
|
@@ -90,6 +90,31 @@ export interface RunOptions {
|
|
|
90
90
|
* payload (the agent can recover).
|
|
91
91
|
*/
|
|
92
92
|
webSearchMaxCalls?: number;
|
|
93
|
+
/**
|
|
94
|
+
* File-search extension (FFF) toggle. Default: `true` — bundled and
|
|
95
|
+
* enabled for every run. Set to `false` to fall back to Pi's built-in
|
|
96
|
+
* `find`/`grep`.
|
|
97
|
+
*/
|
|
98
|
+
fileSearch?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* FFF mode. Default: `"override"` (FFF replaces built-in `find`/`grep`
|
|
101
|
+
* under the same names). The `PI_FFF_MODE` env var, if set, wins.
|
|
102
|
+
*/
|
|
103
|
+
fileSearchMode?: "override" | "tools-only" | "tools-and-ui";
|
|
104
|
+
/**
|
|
105
|
+
* Enable OTEL traces + metrics export. Default: `false` (or env
|
|
106
|
+
* `AGENTIC_PI_OTEL_ENABLED=1`). `false` here force-disables. Requires an
|
|
107
|
+
* OTLP endpoint via `OTEL_EXPORTER_OTLP_ENDPOINT` or `otelEndpoint`.
|
|
108
|
+
* Standard `OTEL_*` env vars are honored by the SDK. Sandbox/env-driven
|
|
109
|
+
* callers can leave this unset and rely on `AGENTIC_PI_OTEL_ENABLED`.
|
|
110
|
+
*/
|
|
111
|
+
otel?: boolean;
|
|
112
|
+
/** Attach bounded raw content to spans. Default: `false` (metadata-only). */
|
|
113
|
+
otelIncludeContent?: boolean;
|
|
114
|
+
/** Override OTEL service name (default: "agentic-pi"). */
|
|
115
|
+
otelServiceName?: string;
|
|
116
|
+
/** Override the OTLP endpoint base URL (escape hatch; prefer the env var). */
|
|
117
|
+
otelEndpoint?: string;
|
|
93
118
|
/**
|
|
94
119
|
* Called for every emitted JSONL record in order. Same shape that the
|
|
95
120
|
* CLI writes to stdout, with `sessionId` and `timestamp` already injected.
|
|
@@ -170,6 +195,23 @@ export interface RunResult {
|
|
|
170
195
|
toolCount: number;
|
|
171
196
|
maxCalls?: number;
|
|
172
197
|
};
|
|
198
|
+
fileSearch?: {
|
|
199
|
+
status: "configured" | "skipped";
|
|
200
|
+
reason?: string;
|
|
201
|
+
message?: string;
|
|
202
|
+
mode?: string;
|
|
203
|
+
toolCount: number;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Mirror of the telemetry `extension_status` line. Present only when OTEL
|
|
207
|
+
* was requested (enabled or explicitly disabled); absent on a default run.
|
|
208
|
+
*/
|
|
209
|
+
telemetry?: {
|
|
210
|
+
status: "configured" | "skipped";
|
|
211
|
+
reason?: string;
|
|
212
|
+
message?: string;
|
|
213
|
+
includeContent?: boolean;
|
|
214
|
+
};
|
|
173
215
|
/** Every JSONL record the run emitted, in order. */
|
|
174
216
|
records: EmitterRecord[];
|
|
175
217
|
/** Warnings that would have gone to stderr in CLI mode. */
|
package/dist/run.js
CHANGED
|
@@ -49,6 +49,12 @@ export async function run(options) {
|
|
|
49
49
|
webSearch: options.webSearch ?? true,
|
|
50
50
|
webSearchProvider: options.webSearchProvider,
|
|
51
51
|
webSearchMaxCalls: options.webSearchMaxCalls,
|
|
52
|
+
fileSearch: options.fileSearch ?? true,
|
|
53
|
+
fileSearchMode: options.fileSearchMode,
|
|
54
|
+
otel: options.otel,
|
|
55
|
+
otelIncludeContent: options.otelIncludeContent,
|
|
56
|
+
otelServiceName: options.otelServiceName,
|
|
57
|
+
otelEndpoint: options.otelEndpoint,
|
|
52
58
|
};
|
|
53
59
|
const collector = new CollectorSink(options.onEvent);
|
|
54
60
|
const sink = options.extraSink
|
|
@@ -106,6 +112,23 @@ function buildResult(exitCode, records, warnings) {
|
|
|
106
112
|
maxCalls: r.maxCalls,
|
|
107
113
|
};
|
|
108
114
|
}
|
|
115
|
+
else if (r.extension === "file-search") {
|
|
116
|
+
result.fileSearch = {
|
|
117
|
+
status: r.status,
|
|
118
|
+
reason: r.reason,
|
|
119
|
+
message: r.message,
|
|
120
|
+
mode: r.mode,
|
|
121
|
+
toolCount: r.toolCount ?? 0,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
else if (r.extension === "telemetry") {
|
|
125
|
+
result.telemetry = {
|
|
126
|
+
status: r.status,
|
|
127
|
+
reason: r.reason,
|
|
128
|
+
message: r.message,
|
|
129
|
+
includeContent: r.includeContent,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
109
132
|
break;
|
|
110
133
|
case "message_end": {
|
|
111
134
|
// Accumulate assistant text. Pi's message structure:
|
package/dist/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH,OAAO,EACL,aAAa,EACb,OAAO,GAGR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAwB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH,OAAO,EACL,aAAa,EACb,OAAO,GAGR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAwB,MAAM,aAAa,CAAC;AA6M5D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,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