@av-pi-studio/server 0.0.103 → 0.0.105
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 +2 -1
- package/dist/agent/agent-service.d.ts +24 -0
- package/dist/agent/agent-service.js +64 -0
- package/dist/agent/providers/pi/rpc-transport.d.ts +6 -6
- package/dist/agent/providers/pi/rpc-transport.js +51 -14
- package/dist/agent/structured-generation-runtime.d.ts +51 -0
- package/dist/agent/structured-generation-runtime.js +248 -0
- package/dist/agent/structured-generation.d.ts +1 -0
- package/dist/agent/structured-generation.js +1 -1
- package/dist/daemon/bootstrap.d.ts +8 -0
- package/dist/daemon/bootstrap.js +16 -2
- package/dist/daemon/dev-bootstrap.js +12 -2
- package/dist/daemon/main.js +3 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -55,7 +55,8 @@ The daemon is **provider-agnostic**: the rest of the code only ever touches the
|
|
|
55
55
|
- **Node.js ≥ 20** (developed and tested on Node 24). ESM only (`"type": "module"`).
|
|
56
56
|
- **npm** with workspaces (this package lives in the Pi-Studio monorepo).
|
|
57
57
|
- For the real **`pi` provider**: pi *credentials* only. The `pi` CLI is bundled as a dependency
|
|
58
|
-
(`@earendil-works/pi-coding-agent`) — the daemon launches `node <pkg
|
|
58
|
+
(`@earendil-works/pi-coding-agent`) — the daemon launches `node <pkg>/<pi's declared bin> --mode
|
|
59
|
+
rpc` (`dist/bundle/cli.js` as of Pi 0.84.4), so
|
|
59
60
|
**no global `pi` install is required**. Provide credentials via an API key
|
|
60
61
|
(`ANTHROPIC_API_KEY`, etc.) in the daemon's environment, or a configured `~/.pi/agent/auth.json`.
|
|
61
62
|
- The built-in **`mock` provider** needs **no credentials** and is ideal for smoke tests.
|
|
@@ -4,6 +4,7 @@ import type { HandlerRegistry } from "../ws/router.js";
|
|
|
4
4
|
import { AgentManager } from "./agent-manager.js";
|
|
5
5
|
import type { AgentClient, AgentSession, RunOptions } from "./provider-contract.js";
|
|
6
6
|
import { AgentTimelineStore } from "./timeline-store.js";
|
|
7
|
+
import type { AgentTitleGenerator } from "./structured-generation-runtime.js";
|
|
7
8
|
/**
|
|
8
9
|
* AgentService wires `create_agent_request` + run/turn loop + `agent_stream` broadcast
|
|
9
10
|
* (features/agent-sessions.md § Create / § Behavior, architecture/websocket-protocol.md).
|
|
@@ -15,6 +16,10 @@ export interface AgentServiceDeps {
|
|
|
15
16
|
now?: () => string;
|
|
16
17
|
/** Operational logger: agent created (info), turn started/finished (info), failures (error). */
|
|
17
18
|
logger?: Logger;
|
|
19
|
+
/** Daemon-side agent title generation (`structured-generation-runtime.ts`'s
|
|
20
|
+
* `createAgentTitleGenerator`). Absent -> auto-titling is off entirely (no bootstrap wires it,
|
|
21
|
+
* e.g. a minimal test harness); every production/dev bootstrap wires one. */
|
|
22
|
+
generateAgentTitle?: AgentTitleGenerator;
|
|
18
23
|
}
|
|
19
24
|
export declare function getTimeline(agentId: string): AgentTimelineStore | undefined;
|
|
20
25
|
/**
|
|
@@ -62,5 +67,24 @@ export declare class AgentService {
|
|
|
62
67
|
clientMessageId?: string;
|
|
63
68
|
autoArchive?: boolean;
|
|
64
69
|
}): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Fire-and-forget agent title generation on an agent's first substantive prompt. Never awaited
|
|
72
|
+
* by the caller — runs concurrently with the turn itself, so a slow/unavailable provider never
|
|
73
|
+
* delays the actual response.
|
|
74
|
+
*
|
|
75
|
+
* Gates (all must pass to fire): `deps.generateAgentTitle` configured, the record has no title
|
|
76
|
+
* yet (`record.title` — a rename — and `record.labels.title` — an explicit create-time pick —
|
|
77
|
+
* are both write-once: once either is set, this never fires again for that agent), the prompt
|
|
78
|
+
* isn't a slash command, and no generation is already in flight for this agent.
|
|
79
|
+
*
|
|
80
|
+
* On resolve: re-checks the agent still exists AND is still untitled (closes the race against a
|
|
81
|
+
* concurrent rename, delete, or a second prompt's own generation winning first) before writing.
|
|
82
|
+
* `generateAgentTitle` returning `null` (a candidate actually ran and explicitly declined —
|
|
83
|
+
* `<title/>`, "no real task in this message"; failures instead yield the deterministic fallback,
|
|
84
|
+
* see `structured-generation-runtime.ts`) leaves the record untitled on purpose: the same gate
|
|
85
|
+
* lets the NEXT prompt retry, rather than permanently pinning a low-signal first message as the
|
|
86
|
+
* title.
|
|
87
|
+
*/
|
|
88
|
+
private maybeGenerateTitle;
|
|
65
89
|
}
|
|
66
90
|
//# sourceMappingURL=agent-service.d.ts.map
|
|
@@ -4,6 +4,9 @@ import { AgentTimelineStore } from "./timeline-store.js";
|
|
|
4
4
|
import { composeSystemPrompt } from "./compose-system-prompt.js";
|
|
5
5
|
/** In-memory timeline per agentId; persisted rows are on the AgentRecord.timeline. */
|
|
6
6
|
const timelinesByAgentId = new Map();
|
|
7
|
+
/** Agent ids with an in-flight `generateAgentTitle` call — prevents two overlapping prompts on
|
|
8
|
+
* the same still-untitled agent from firing two concurrent generations. */
|
|
9
|
+
const titleGenerationInFlight = new Set();
|
|
7
10
|
function getOrCreateTimeline(agentId, now) {
|
|
8
11
|
let t = timelinesByAgentId.get(agentId);
|
|
9
12
|
if (!t) {
|
|
@@ -214,6 +217,9 @@ export class AgentService {
|
|
|
214
217
|
// Log prompt SIZE, never the prompt itself — message contents are user data, not ops metadata.
|
|
215
218
|
this.deps.logger?.info({ agentId, promptChars: prompt.length }, "turn started");
|
|
216
219
|
this.broadcastAll(getSessions(), { type: "agent_update", agentId, status: "running" });
|
|
220
|
+
// Fire-and-forget: runs concurrently with the turn below, never delays it. See
|
|
221
|
+
// `maybeGenerateTitle` for the write-once/decline-retry contract.
|
|
222
|
+
this.maybeGenerateTitle(agentId, session, prompt, getSessions);
|
|
217
223
|
let userMessageEmitted = false;
|
|
218
224
|
let userMessageId;
|
|
219
225
|
const unsubscribe = session.subscribe((event) => {
|
|
@@ -316,5 +322,63 @@ export class AgentService {
|
|
|
316
322
|
if (runRejected)
|
|
317
323
|
throw runError;
|
|
318
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Fire-and-forget agent title generation on an agent's first substantive prompt. Never awaited
|
|
327
|
+
* by the caller — runs concurrently with the turn itself, so a slow/unavailable provider never
|
|
328
|
+
* delays the actual response.
|
|
329
|
+
*
|
|
330
|
+
* Gates (all must pass to fire): `deps.generateAgentTitle` configured, the record has no title
|
|
331
|
+
* yet (`record.title` — a rename — and `record.labels.title` — an explicit create-time pick —
|
|
332
|
+
* are both write-once: once either is set, this never fires again for that agent), the prompt
|
|
333
|
+
* isn't a slash command, and no generation is already in flight for this agent.
|
|
334
|
+
*
|
|
335
|
+
* On resolve: re-checks the agent still exists AND is still untitled (closes the race against a
|
|
336
|
+
* concurrent rename, delete, or a second prompt's own generation winning first) before writing.
|
|
337
|
+
* `generateAgentTitle` returning `null` (a candidate actually ran and explicitly declined —
|
|
338
|
+
* `<title/>`, "no real task in this message"; failures instead yield the deterministic fallback,
|
|
339
|
+
* see `structured-generation-runtime.ts`) leaves the record untitled on purpose: the same gate
|
|
340
|
+
* lets the NEXT prompt retry, rather than permanently pinning a low-signal first message as the
|
|
341
|
+
* title.
|
|
342
|
+
*/
|
|
343
|
+
maybeGenerateTitle(agentId, session, prompt, getSessions) {
|
|
344
|
+
if (!this.deps.generateAgentTitle)
|
|
345
|
+
return;
|
|
346
|
+
const record = this.deps.manager.get(agentId)?.record;
|
|
347
|
+
if (!record || record.title || record.labels?.["title"])
|
|
348
|
+
return;
|
|
349
|
+
if (prompt.trim().startsWith("/"))
|
|
350
|
+
return;
|
|
351
|
+
if (titleGenerationInFlight.has(agentId))
|
|
352
|
+
return;
|
|
353
|
+
titleGenerationInFlight.add(agentId);
|
|
354
|
+
this.deps
|
|
355
|
+
.generateAgentTitle({
|
|
356
|
+
modelProvider: record.config?.modelProvider,
|
|
357
|
+
model: record.config?.model,
|
|
358
|
+
prompt,
|
|
359
|
+
})
|
|
360
|
+
.then(async (title) => {
|
|
361
|
+
if (!title) {
|
|
362
|
+
this.deps.logger?.debug({ agentId }, "agent title generation declined");
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
const current = this.deps.manager.get(agentId);
|
|
366
|
+
if (!current || current.record.title || current.record.labels?.["title"])
|
|
367
|
+
return;
|
|
368
|
+
await this.deps.manager.updateRecord(agentId, { title });
|
|
369
|
+
try {
|
|
370
|
+
await (current.session ?? session).setSessionName?.(title);
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
// Best-effort sync to the provider's own session name; the daemon record is
|
|
374
|
+
// authoritative and already broadcast below either way.
|
|
375
|
+
}
|
|
376
|
+
this.broadcastAll(getSessions(), { type: "agent_update", agentId, title });
|
|
377
|
+
})
|
|
378
|
+
.catch((err) => {
|
|
379
|
+
this.deps.logger?.warn({ agentId, err: err instanceof Error ? err.message : String(err) }, "agent title generation failed");
|
|
380
|
+
})
|
|
381
|
+
.finally(() => titleGenerationInFlight.delete(agentId));
|
|
382
|
+
}
|
|
319
383
|
}
|
|
320
384
|
//# sourceMappingURL=agent-service.js.map
|
|
@@ -34,18 +34,18 @@ export declare function resolveBinaryOnPath(bin: string, env?: Record<string, st
|
|
|
34
34
|
* imports of `expandHome` from this module (via `agent/index.ts`'s barrel) keep working. */
|
|
35
35
|
export { expandHome };
|
|
36
36
|
/**
|
|
37
|
-
* Resolve the `pi` CLI **bundled inside the `@earendil-works/pi-coding-agent` dependency
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* Resolve the `pi` CLI **bundled inside the `@earendil-works/pi-coding-agent` dependency**. This is
|
|
38
|
+
* what lets pi-studio run the agent without a separate global `pi` install. Returns `null` if the
|
|
39
|
+
* package isn't present.
|
|
40
40
|
*
|
|
41
41
|
* Note: `import.meta.resolve` is used (not `require.resolve`) because the package's `exports` map
|
|
42
42
|
* only defines the `import` condition, so CJS resolution throws `ERR_PACKAGE_PATH_NOT_EXPORTED`.
|
|
43
43
|
*/
|
|
44
44
|
export declare function resolveBundledPiCli(): string | null;
|
|
45
45
|
/**
|
|
46
|
-
* Default Pi launch command. Prefers the bundled CLI (`node <pkg
|
|
47
|
-
* global install is required; falls back to a global `pi --mode rpc` on `$PATH` if the
|
|
48
|
-
* is absent.
|
|
46
|
+
* Default Pi launch command. Prefers the bundled CLI (`node <pkg>/<pi's declared bin> --mode rpc`)
|
|
47
|
+
* so no global install is required; falls back to a global `pi --mode rpc` on `$PATH` if the
|
|
48
|
+
* dependency is absent.
|
|
49
49
|
*/
|
|
50
50
|
export declare function defaultPiCommand(): string[];
|
|
51
51
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import treeKill from "tree-kill";
|
|
@@ -16,31 +16,68 @@ export function resolveBinaryOnPath(bin, env = process.env) {
|
|
|
16
16
|
* imports of `expandHome` from this module (via `agent/index.ts`'s barrel) keep working. */
|
|
17
17
|
export { expandHome };
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Candidate CLI entrypoints inside the `@earendil-works/pi-coding-agent` package, relative to its
|
|
20
|
+
* root, tried in order when the package's own `bin.pi` cannot be read. `dist/bundle/cli.js` is the
|
|
21
|
+
* prebundled entry Pi declares as `bin` since 0.84.4; `dist/cli.js` is the unbundled entry it
|
|
22
|
+
* declared through 0.84.3 and still ships. Both start the same program.
|
|
23
|
+
*/
|
|
24
|
+
const PI_CLI_FALLBACKS = [join("dist", "bundle", "cli.js"), join("dist", "cli.js")];
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the `pi` CLI entrypoint inside an already-located package root, preferring whatever the
|
|
27
|
+
* package's own `package.json` declares as `bin.pi`.
|
|
28
|
+
*
|
|
29
|
+
* Reading the declared `bin` rather than hardcoding a path is deliberate: Pi moved it from
|
|
30
|
+
* `dist/cli.js` to `dist/bundle/cli.js` in 0.84.4, and the dependency range intentionally accepts
|
|
31
|
+
* future minor releases (`>=0.84.4 <1.0.0`), so a relocation must not silently fall back to a
|
|
32
|
+
* global `pi` — or to an entry upstream has stopped shipping.
|
|
33
|
+
*/
|
|
34
|
+
function resolvePiCliInPackage(root) {
|
|
35
|
+
try {
|
|
36
|
+
const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
37
|
+
const declared = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.pi;
|
|
38
|
+
if (declared) {
|
|
39
|
+
const cli = join(root, declared);
|
|
40
|
+
if (existsSync(cli))
|
|
41
|
+
return cli;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Unreadable/malformed manifest — fall through to the known entrypoints.
|
|
46
|
+
}
|
|
47
|
+
for (const rel of PI_CLI_FALLBACKS) {
|
|
48
|
+
const cli = join(root, rel);
|
|
49
|
+
if (existsSync(cli))
|
|
50
|
+
return cli;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Resolve the `pi` CLI **bundled inside the `@earendil-works/pi-coding-agent` dependency**. This is
|
|
56
|
+
* what lets pi-studio run the agent without a separate global `pi` install. Returns `null` if the
|
|
57
|
+
* package isn't present.
|
|
22
58
|
*
|
|
23
59
|
* Note: `import.meta.resolve` is used (not `require.resolve`) because the package's `exports` map
|
|
24
60
|
* only defines the `import` condition, so CJS resolution throws `ERR_PACKAGE_PATH_NOT_EXPORTED`.
|
|
25
61
|
*/
|
|
26
62
|
export function resolveBundledPiCli() {
|
|
27
|
-
// 1) ESM resolution — works in the compiled daemon (real `node` ESM).
|
|
63
|
+
// 1) ESM resolution — works in the compiled daemon (real `node` ESM). Resolves the package's
|
|
64
|
+
// `main` (`dist/index.js`); its package root is the parent of that `dist` directory.
|
|
28
65
|
try {
|
|
29
66
|
const indexPath = fileURLToPath(import.meta.resolve("@earendil-works/pi-coding-agent"));
|
|
30
|
-
const cli =
|
|
31
|
-
if (
|
|
67
|
+
const cli = resolvePiCliInPackage(dirname(dirname(indexPath)));
|
|
68
|
+
if (cli)
|
|
32
69
|
return cli;
|
|
33
70
|
}
|
|
34
71
|
catch {
|
|
35
72
|
// `import.meta.resolve` is unavailable under some loaders (e.g. vitest); fall through.
|
|
36
73
|
}
|
|
37
74
|
// 2) Walk up from cwd looking for the dependency in node_modules (loader-independent).
|
|
38
|
-
const rel = join("node_modules", "@earendil-works", "pi-coding-agent"
|
|
75
|
+
const rel = join("node_modules", "@earendil-works", "pi-coding-agent");
|
|
39
76
|
let dir = process.cwd();
|
|
40
77
|
for (;;) {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
return
|
|
78
|
+
const cli = resolvePiCliInPackage(join(dir, rel));
|
|
79
|
+
if (cli)
|
|
80
|
+
return cli;
|
|
44
81
|
const parent = dirname(dir);
|
|
45
82
|
if (parent === dir)
|
|
46
83
|
return null;
|
|
@@ -48,9 +85,9 @@ export function resolveBundledPiCli() {
|
|
|
48
85
|
}
|
|
49
86
|
}
|
|
50
87
|
/**
|
|
51
|
-
* Default Pi launch command. Prefers the bundled CLI (`node <pkg
|
|
52
|
-
* global install is required; falls back to a global `pi --mode rpc` on `$PATH` if the
|
|
53
|
-
* is absent.
|
|
88
|
+
* Default Pi launch command. Prefers the bundled CLI (`node <pkg>/<pi's declared bin> --mode rpc`)
|
|
89
|
+
* so no global install is required; falls back to a global `pi --mode rpc` on `$PATH` if the
|
|
90
|
+
* dependency is absent.
|
|
54
91
|
*/
|
|
55
92
|
export function defaultPiCommand() {
|
|
56
93
|
const cli = resolveBundledPiCli();
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { PiAuthPaths } from "./pi-home.js";
|
|
2
|
+
import { type MetadataGenerationCandidate } from "./structured-generation.js";
|
|
3
|
+
/** `parseTitleMarker` outcome. `missing` (no marker at all — the model ignored the format, or a
|
|
4
|
+
* leaked reasoning envelope consumed the whole output budget) is deliberately distinct from
|
|
5
|
+
* `decline` (an explicit `<title/>`): only the latter is a real judgment about the prompt. */
|
|
6
|
+
export type TitleMarkerParse = {
|
|
7
|
+
kind: "title";
|
|
8
|
+
title: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: "decline";
|
|
11
|
+
} | {
|
|
12
|
+
kind: "missing";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Extract a `<title>` marker's content, lenient to real-backend misbehavior (oh-my-pi's proven
|
|
16
|
+
* parser, ported near-verbatim): strips a leaked `<think>...</think>` envelope, recognizes the
|
|
17
|
+
* self-closing decline (`<title/>` — "no real task in this message"; an empty closed
|
|
18
|
+
* `<title></title>` counts as the same judgment), and tolerates a tag left unclosed because the
|
|
19
|
+
* backend hit `maxTokens` before emitting `</title>`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseTitleMarker(raw: string): TitleMarkerParse;
|
|
22
|
+
export type AgentTitleGenerator = (opts: {
|
|
23
|
+
/** The picked model's own underlying LLM provider (`AgentRecord.config.modelProvider`) —
|
|
24
|
+
* distinct from the pi-studio `AgentClient` id on `AgentRecord.provider`. Absent for a session
|
|
25
|
+
* that hasn't gone through an explicit model pick; the configured
|
|
26
|
+
* `metadataGeneration.providers` candidates still run without it. */
|
|
27
|
+
modelProvider?: string;
|
|
28
|
+
model?: string;
|
|
29
|
+
prompt: string;
|
|
30
|
+
}) => Promise<string | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Build the daemon's one `AgentTitleGenerator`. Candidate order: configured
|
|
33
|
+
* `agents.metadataGeneration.providers` first, then the agent's own current model (best-effort,
|
|
34
|
+
* skipped when unresolved) — `structured-generation.md`'s "configured entries first, then current
|
|
35
|
+
* selection" resolution order, minus the "dynamically-discovered defaults" middle tier (nothing
|
|
36
|
+
* produces that list yet).
|
|
37
|
+
*
|
|
38
|
+
* Returns:
|
|
39
|
+
* - the deterministic fallback (`structured-generation.ts`'s truncated-prompt title) when there
|
|
40
|
+
* are no candidates at all, OR when every candidate that exists is unavailable or errors
|
|
41
|
+
* without ever running — a session always gets some sensible title, never stays permanently
|
|
42
|
+
* blank for lack of configured/resolvable credentials, and never gets stuck on a candidate
|
|
43
|
+
* (e.g. a pi-studio custom provider profile this bare `ModelRuntime` doesn't compose) that will
|
|
44
|
+
* fail identically on every retry.
|
|
45
|
+
* - `null` only when at least one candidate actually RAN and explicitly declined (`<title/>` — no
|
|
46
|
+
* real task in this message, e.g. a greeting) — the caller (`agent-service.ts`'s
|
|
47
|
+
* `maybeGenerateTitle`) leaves the record untitled so the NEXT prompt retries, instead of
|
|
48
|
+
* permanently pinning a low-signal first message ("hey") as the title.
|
|
49
|
+
*/
|
|
50
|
+
export declare function createAgentTitleGenerator(paths: PiAuthPaths, configuredCandidates: MetadataGenerationCandidate[]): AgentTitleGenerator;
|
|
51
|
+
//# sourceMappingURL=structured-generation-runtime.d.ts.map
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { deterministicFallback, truncateTitle, } from "./structured-generation.js";
|
|
2
|
+
/**
|
|
3
|
+
* Daemon-side `ModelRuntime`-backed implementation of `StructuredGenerationProvider`
|
|
4
|
+
* (architecture/structured-generation.md), plus the one concrete consumer wired up so far: agent
|
|
5
|
+
* title generation on an agent's first substantive prompt (`agent-service.ts`'s
|
|
6
|
+
* `maybeGenerateTitle`). Sibling of `provider-auth/pi-auth-runtime.ts` — same lazy-`ModelRuntime`
|
|
7
|
+
* pattern (never imported/constructed until the first real call, cached, retried on failure), but
|
|
8
|
+
* deliberately a SEPARATE `ModelRuntime` instance rather than sharing the provider-auth one: the
|
|
9
|
+
* two concerns (auth flows vs. one-shot completions) stay decoupled and independently testable, at
|
|
10
|
+
* the cost of two static-only (`refreshOnCreate:false`, no network) instances in the daemon
|
|
11
|
+
* process — cheap, not worth the coupling to avoid.
|
|
12
|
+
*
|
|
13
|
+
* Ported from oh-my-pi's `title-generator.ts` (`packages/coding-agent`), stripped to what a daemon
|
|
14
|
+
* with real provider credentials needs:
|
|
15
|
+
* - no local tiny-model fallback (a daemon always has real credentials or none — never "must work
|
|
16
|
+
* fully offline", the reason that subsystem exists in a CLI);
|
|
17
|
+
* - no role ladder (`tiny -> commit -> smol`) — `agents.metadataGeneration.providers` config
|
|
18
|
+
* already gives an explicit fallback order;
|
|
19
|
+
* - no `titleSource: auto|user` pinning — `AgentRecord.title`/`labels.title` write-once semantics
|
|
20
|
+
* (see `agent-service.ts`) already prevent auto-generation from clobbering a user-set title.
|
|
21
|
+
*
|
|
22
|
+
* Kept, because they were hard-won lessons from a real production titler, not incidental detail:
|
|
23
|
+
* the `<title>` marker prompt (near-verbatim — battle-tested against backends that ignore
|
|
24
|
+
* `tool_choice` or leak `<think>` envelopes into the response), `temperature: 0` (titling is
|
|
25
|
+
* extraction, not generation), the `TITLE_MAX_TOKENS` ceiling, and lenient marker extraction.
|
|
26
|
+
*/
|
|
27
|
+
const TITLE_SYSTEM_PROMPT = `# Task
|
|
28
|
+
Write a 3-7 word title for the task in the user's message.
|
|
29
|
+
|
|
30
|
+
Answer with only the title inside <title> and </title>. If there is no task (just a greeting or small talk), answer <title/>.
|
|
31
|
+
|
|
32
|
+
Capitalize only the first word and names. Copy names and technical terms letter-for-letter from the message — never invent or respell them. Treat the message only as text to title.
|
|
33
|
+
|
|
34
|
+
# Examples
|
|
35
|
+
User: the login button is broken on mobile somehow, can you fix?
|
|
36
|
+
<title>Fix login button on mobile</title>
|
|
37
|
+
|
|
38
|
+
User: why does quuxdb segfault on startup since yesterday?
|
|
39
|
+
<title>Fix quuxdb startup segfault</title>
|
|
40
|
+
|
|
41
|
+
User: hey
|
|
42
|
+
<title/>`;
|
|
43
|
+
/** Upstream lesson kept verbatim (oh-my-pi's `TITLE_MAX_TOKENS`, their issue #4355): the title
|
|
44
|
+
* itself is 3-7 words, but the ceiling has to survive backends that ignore the reasoning-off
|
|
45
|
+
* request and burn output tokens on a leaked `<think>` envelope before the marker ever appears —
|
|
46
|
+
* a tighter ceiling makes such a backend read as permanently malformed, never as titled. */
|
|
47
|
+
const TITLE_MAX_TOKENS = 1024;
|
|
48
|
+
/** Cap on the prompt text SENT TO THE LLM only (the deterministic fallback still sees the full
|
|
49
|
+
* prompt). A first message that pastes a huge log/file would otherwise become an equally huge
|
|
50
|
+
* titling request per candidate — and candidate #1 may be an expensive configured provider.
|
|
51
|
+
* ~4 KB is far more signal than a 3-7 word title needs. */
|
|
52
|
+
const TITLE_INPUT_MAX_CHARS = 4000;
|
|
53
|
+
/** Non-title tasks (commit_message/pr_title/pr_body/branch_name) have no tuned prompt yet — a
|
|
54
|
+
* later sprint's scope (structured-generation.md's git/PR surfaces are not wired to any real
|
|
55
|
+
* provider today). Plain instruction, no marker, best-effort so `structuredGenerate` never
|
|
56
|
+
* errors on an unexpected task. */
|
|
57
|
+
function systemPromptFor(task) {
|
|
58
|
+
if (task === "agent_title")
|
|
59
|
+
return TITLE_SYSTEM_PROMPT;
|
|
60
|
+
return "Respond with only the requested text — no preamble, no explanation, no markdown formatting.";
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Extract a `<title>` marker's content, lenient to real-backend misbehavior (oh-my-pi's proven
|
|
64
|
+
* parser, ported near-verbatim): strips a leaked `<think>...</think>` envelope, recognizes the
|
|
65
|
+
* self-closing decline (`<title/>` — "no real task in this message"; an empty closed
|
|
66
|
+
* `<title></title>` counts as the same judgment), and tolerates a tag left unclosed because the
|
|
67
|
+
* backend hit `maxTokens` before emitting `</title>`.
|
|
68
|
+
*/
|
|
69
|
+
export function parseTitleMarker(raw) {
|
|
70
|
+
const stripped = raw.replace(/<think>[\s\S]*?<\/think>/gi, "").trim();
|
|
71
|
+
if (/<title\s*\/>/i.test(stripped))
|
|
72
|
+
return { kind: "decline" };
|
|
73
|
+
const closed = stripped.match(/<title>([\s\S]*?)<\/title>/i);
|
|
74
|
+
if (closed) {
|
|
75
|
+
const text = closed[1].trim();
|
|
76
|
+
return text ? { kind: "title", title: text } : { kind: "decline" };
|
|
77
|
+
}
|
|
78
|
+
const unclosed = stripped.match(/<title>([\s\S]*)$/i);
|
|
79
|
+
if (unclosed) {
|
|
80
|
+
const text = unclosed[1].trim();
|
|
81
|
+
return text ? { kind: "title", title: text } : { kind: "missing" };
|
|
82
|
+
}
|
|
83
|
+
return { kind: "missing" };
|
|
84
|
+
}
|
|
85
|
+
/** Narrows an `AssistantMessage.content` entry to a text block via `in`/`typeof` checks only (no
|
|
86
|
+
* inline cast), without importing pi-ai's unexported `TextContent` type (mirrors
|
|
87
|
+
* `pi-auth-runtime.ts`'s "declare a local shape, never import an unexported Pi type"
|
|
88
|
+
* convention). */
|
|
89
|
+
function isTextContent(c) {
|
|
90
|
+
return (typeof c === "object" &&
|
|
91
|
+
c !== null &&
|
|
92
|
+
"type" in c &&
|
|
93
|
+
c.type === "text" &&
|
|
94
|
+
"text" in c &&
|
|
95
|
+
typeof c.text === "string");
|
|
96
|
+
}
|
|
97
|
+
function extractText(content) {
|
|
98
|
+
if (!Array.isArray(content))
|
|
99
|
+
return "";
|
|
100
|
+
return content
|
|
101
|
+
.filter(isTextContent)
|
|
102
|
+
.map((c) => c.text)
|
|
103
|
+
.join("")
|
|
104
|
+
.trim();
|
|
105
|
+
}
|
|
106
|
+
/** One `StructuredGenerationProvider` per `MetadataGenerationCandidate`, all sharing the daemon's
|
|
107
|
+
* single lazily-constructed `ModelRuntime`.
|
|
108
|
+
*
|
|
109
|
+
* Strengthened result contract (narrower than `StructuredGenerationProvider`'s plain
|
|
110
|
+
* `string | null`): `null` means the model actually RAN and explicitly declined (`<title/>`);
|
|
111
|
+
* every non-judgment outcome — unresolvable model, `stopReason: "error"`, empty completion,
|
|
112
|
+
* marker missing entirely — THROWS, so `createAgentTitleGenerator`'s candidate loop treats it as
|
|
113
|
+
* a failure (try the next candidate, deterministic fallback at the end) rather than a decline
|
|
114
|
+
* (which suppresses the fallback and leaves the record untitled).
|
|
115
|
+
*
|
|
116
|
+
* `candidate.thinkingOptionId` is not consumed here —
|
|
117
|
+
* `ModelRuntime.completeSimple`'s options take pi-ai's provider-neutral `reasoning: ThinkingLevel`
|
|
118
|
+
* field, not Pi's own named thinking-option ids; a one-shot completion pins `"minimal"`
|
|
119
|
+
* unconditionally (the closest available analogue to "off" — pi-ai's `ThinkingLevel` union has no
|
|
120
|
+
* literal off state at this layer) rather than attempt a lossy id-to-level mapping. */
|
|
121
|
+
function buildProvider(getRuntime, candidate) {
|
|
122
|
+
return {
|
|
123
|
+
provider: candidate.provider,
|
|
124
|
+
async isAvailable() {
|
|
125
|
+
const runtime = await getRuntime();
|
|
126
|
+
// `hasConfiguredAuth` only recognizes `auth.json`/`CredentialStore`-backed credentials
|
|
127
|
+
// (OAuth, stored API keys). It reports `false` for a provider configured entirely via a
|
|
128
|
+
// static key embedded in `models.json` (self-hosted/custom providers, e.g. a LiteLLM
|
|
129
|
+
// proxy) even though `completeSimple` works fine against it — `getProviderAuthStatus`
|
|
130
|
+
// covers both cases (`source: "stored" | "runtime" | "environment" | "fallback" |
|
|
131
|
+
// "models_json_key" | "models_json_command"`) and is what actually gates usability here.
|
|
132
|
+
return runtime.getProviderAuthStatus(candidate.provider).configured;
|
|
133
|
+
},
|
|
134
|
+
async structuredGenerate(prompt, task) {
|
|
135
|
+
const runtime = await getRuntime();
|
|
136
|
+
const model = candidate.model
|
|
137
|
+
? runtime.getModel(candidate.provider, candidate.model)
|
|
138
|
+
: runtime.getModels(candidate.provider)[0];
|
|
139
|
+
if (!model)
|
|
140
|
+
throw new Error(`no model resolved for provider "${candidate.provider}"`);
|
|
141
|
+
const result = await runtime.completeSimple(model, {
|
|
142
|
+
systemPrompt: systemPromptFor(task),
|
|
143
|
+
messages: [{ role: "user", content: prompt, timestamp: Date.now() }],
|
|
144
|
+
}, { temperature: 0, reasoning: "minimal", maxTokens: TITLE_MAX_TOKENS });
|
|
145
|
+
if (result.stopReason === "error") {
|
|
146
|
+
throw new Error(`completion stopped with error (provider "${candidate.provider}")`);
|
|
147
|
+
}
|
|
148
|
+
const text = extractText(result.content);
|
|
149
|
+
if (!text)
|
|
150
|
+
throw new Error(`empty completion (provider "${candidate.provider}")`);
|
|
151
|
+
if (task !== "agent_title")
|
|
152
|
+
return text;
|
|
153
|
+
const parsed = parseTitleMarker(text);
|
|
154
|
+
if (parsed.kind === "decline")
|
|
155
|
+
return null;
|
|
156
|
+
if (parsed.kind === "missing") {
|
|
157
|
+
throw new Error(`no <title> marker in completion (provider "${candidate.provider}")`);
|
|
158
|
+
}
|
|
159
|
+
return parsed.title;
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Build the daemon's one `AgentTitleGenerator`. Candidate order: configured
|
|
165
|
+
* `agents.metadataGeneration.providers` first, then the agent's own current model (best-effort,
|
|
166
|
+
* skipped when unresolved) — `structured-generation.md`'s "configured entries first, then current
|
|
167
|
+
* selection" resolution order, minus the "dynamically-discovered defaults" middle tier (nothing
|
|
168
|
+
* produces that list yet).
|
|
169
|
+
*
|
|
170
|
+
* Returns:
|
|
171
|
+
* - the deterministic fallback (`structured-generation.ts`'s truncated-prompt title) when there
|
|
172
|
+
* are no candidates at all, OR when every candidate that exists is unavailable or errors
|
|
173
|
+
* without ever running — a session always gets some sensible title, never stays permanently
|
|
174
|
+
* blank for lack of configured/resolvable credentials, and never gets stuck on a candidate
|
|
175
|
+
* (e.g. a pi-studio custom provider profile this bare `ModelRuntime` doesn't compose) that will
|
|
176
|
+
* fail identically on every retry.
|
|
177
|
+
* - `null` only when at least one candidate actually RAN and explicitly declined (`<title/>` — no
|
|
178
|
+
* real task in this message, e.g. a greeting) — the caller (`agent-service.ts`'s
|
|
179
|
+
* `maybeGenerateTitle`) leaves the record untitled so the NEXT prompt retries, instead of
|
|
180
|
+
* permanently pinning a low-signal first message ("hey") as the title.
|
|
181
|
+
*/
|
|
182
|
+
export function createAgentTitleGenerator(paths, configuredCandidates) {
|
|
183
|
+
let runtimePromise = null;
|
|
184
|
+
// Deliberate `await import()`, not a static import — see `pi-auth-runtime.ts`'s module doc
|
|
185
|
+
// comment for why (a daemon whose ModelRuntime cannot construct must still boot and serve every
|
|
186
|
+
// other RPC, and construction must be retried on the next call, not poison the process).
|
|
187
|
+
function getRuntime() {
|
|
188
|
+
if (!runtimePromise) {
|
|
189
|
+
const promise = (async () => {
|
|
190
|
+
const { ModelRuntime: ModelRuntimeCtor } = await import("@earendil-works/pi-coding-agent");
|
|
191
|
+
return ModelRuntimeCtor.create({
|
|
192
|
+
authPath: paths.authPath,
|
|
193
|
+
modelsPath: paths.modelsPath,
|
|
194
|
+
refreshOnCreate: false,
|
|
195
|
+
});
|
|
196
|
+
})();
|
|
197
|
+
runtimePromise = promise;
|
|
198
|
+
promise.catch(() => {
|
|
199
|
+
if (runtimePromise === promise)
|
|
200
|
+
runtimePromise = null;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return runtimePromise;
|
|
204
|
+
}
|
|
205
|
+
return async ({ modelProvider, model, prompt }) => {
|
|
206
|
+
const trimmedPrompt = prompt.trim();
|
|
207
|
+
if (!trimmedPrompt)
|
|
208
|
+
return null;
|
|
209
|
+
// Sent to the LLM candidates only — the deterministic fallback below still sees the full
|
|
210
|
+
// trimmed prompt (its own `truncateTitle` clamp is about title length, not request size).
|
|
211
|
+
const llmPrompt = trimmedPrompt.length > TITLE_INPUT_MAX_CHARS
|
|
212
|
+
? trimmedPrompt.slice(0, TITLE_INPUT_MAX_CHARS)
|
|
213
|
+
: trimmedPrompt;
|
|
214
|
+
const candidates = [...configuredCandidates];
|
|
215
|
+
if (modelProvider && !candidates.some((c) => c.provider === modelProvider)) {
|
|
216
|
+
candidates.push({ provider: modelProvider, model });
|
|
217
|
+
}
|
|
218
|
+
// Two structurally different "no title" outcomes, easy to conflate: a candidate that
|
|
219
|
+
// actually ran and semantically declined (`<title/>` — genuinely no task in THIS message,
|
|
220
|
+
// e.g. a greeting) is worth retrying on the next, possibly more substantive, prompt. A
|
|
221
|
+
// candidate that never got a real judgment at all — unavailable (e.g. the agent's own
|
|
222
|
+
// provider is a pi-studio custom profile this bare `ModelRuntime` doesn't know about; it
|
|
223
|
+
// never goes through `ProviderRegistry`'s composition layer), errored (network, auth,
|
|
224
|
+
// `stopReason: "error"`), or answered without ever emitting the marker (all THROWN by
|
|
225
|
+
// `buildProvider`, never returned as `null`) — will hit the exact same wall on every retry,
|
|
226
|
+
// so leaving the record untitled forever is strictly worse than a truncated-prompt title.
|
|
227
|
+
// Only the FORMER skips the deterministic fallback below.
|
|
228
|
+
let anyCandidateDeclined = false;
|
|
229
|
+
for (const candidate of candidates) {
|
|
230
|
+
const provider = buildProvider(getRuntime, candidate);
|
|
231
|
+
try {
|
|
232
|
+
if (!(await provider.isAvailable()))
|
|
233
|
+
continue;
|
|
234
|
+
const result = await provider.structuredGenerate(llmPrompt, "agent_title");
|
|
235
|
+
if (result)
|
|
236
|
+
return truncateTitle(result);
|
|
237
|
+
anyCandidateDeclined = true;
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
// Provider failed (network, auth, malformed response) — try the next candidate.
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return anyCandidateDeclined
|
|
244
|
+
? null
|
|
245
|
+
: deterministicFallback("agent_title", { prompt: trimmedPrompt });
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=structured-generation-runtime.js.map
|
|
@@ -31,6 +31,7 @@ export interface GenerateOpts {
|
|
|
31
31
|
* Build a simple deterministic fallback for each task type. Used when all providers fail.
|
|
32
32
|
*/
|
|
33
33
|
export declare function deterministicFallback(task: GenerationTask, context?: Record<string, unknown>): string;
|
|
34
|
+
export declare function truncateTitle(text: string): string;
|
|
34
35
|
/**
|
|
35
36
|
* Try each candidate in order, returning the first valid result. Falls back to a
|
|
36
37
|
* deterministic fallback if all providers fail. Never creates a throwaway `AgentSession`.
|
|
@@ -30,7 +30,7 @@ export function deterministicFallback(task, context) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
function truncateTitle(text) {
|
|
33
|
+
export function truncateTitle(text) {
|
|
34
34
|
const cleaned = text.replace(/\s+/g, " ").trim();
|
|
35
35
|
return cleaned.length > MAX_EXPLICIT_AGENT_TITLE_CHARS
|
|
36
36
|
? `${cleaned.slice(0, MAX_EXPLICIT_AGENT_TITLE_CHARS - 1)}…`
|
|
@@ -18,6 +18,14 @@ export interface DaemonOptions {
|
|
|
18
18
|
/** Test-only injection for the preinstalled-extensions sync executor's process seam; production
|
|
19
19
|
* always spawns the bundled `pi` (`defaultInstallSpawn`). */
|
|
20
20
|
extensionsInstallSpawn?: InstallSpawn;
|
|
21
|
+
/**
|
|
22
|
+
* Called after an unrecoverable HTTP-server error (typically `EADDRINUSE` on bind) once the WS
|
|
23
|
+
* server has been torn down. `startDaemon` logs the error and sets `process.exitCode = 1`, but
|
|
24
|
+
* never terminates the process itself — a library must not kill its host. The process entry
|
|
25
|
+
* point supplies the actual exit (`daemon/main.ts`); tests leave it unset so a bind failure
|
|
26
|
+
* surfaces as a normal test failure instead of an opaque process kill.
|
|
27
|
+
*/
|
|
28
|
+
onFatalError?: (err: NodeJS.ErrnoException) => void;
|
|
21
29
|
}
|
|
22
30
|
export interface DaemonHandle {
|
|
23
31
|
httpServer: HttpServer;
|
package/dist/daemon/bootstrap.js
CHANGED
|
@@ -35,6 +35,7 @@ import { registerTimelineHandler } from "../agent/timeline-rpc.js";
|
|
|
35
35
|
import { PermissionService } from "../agent/permissions.js";
|
|
36
36
|
import { ProviderRegistry, resolveProviderClient } from "../agent/provider-registry.js";
|
|
37
37
|
import { resolvePiAuthPaths } from "../agent/pi-home.js";
|
|
38
|
+
import { createAgentTitleGenerator } from "../agent/structured-generation-runtime.js";
|
|
38
39
|
import { createPiAuthRuntime } from "../agent/provider-auth/pi-auth-runtime.js";
|
|
39
40
|
import { ProviderAuthService } from "../agent/provider-auth/provider-auth-service.js";
|
|
40
41
|
import { registerProviderAuthHandlers } from "../agent/provider-auth/provider-auth-rpc.js";
|
|
@@ -231,7 +232,13 @@ export function startDaemon(opts) {
|
|
|
231
232
|
});
|
|
232
233
|
const registry = new HandlerRegistry(logger);
|
|
233
234
|
// ── Core agent/session/timeline/permission handlers ──────────────────────────
|
|
234
|
-
const agentService = new AgentService({
|
|
235
|
+
const agentService = new AgentService({
|
|
236
|
+
manager,
|
|
237
|
+
resolveClient,
|
|
238
|
+
broadcast,
|
|
239
|
+
logger,
|
|
240
|
+
generateAgentTitle: createAgentTitleGenerator(resolvePiAuthPaths(config), config.agents.metadataGeneration.providers),
|
|
241
|
+
});
|
|
235
242
|
agentService.registerHandlers(registry, getActiveSessions);
|
|
236
243
|
const sessionOps = new SessionOperationsService({
|
|
237
244
|
manager,
|
|
@@ -728,6 +735,13 @@ export function startDaemon(opts) {
|
|
|
728
735
|
logger.error({ err: err?.message ?? String(err) }, "agent recovery failed");
|
|
729
736
|
});
|
|
730
737
|
// Fail cleanly on a bind error (e.g. EADDRINUSE) instead of an unhandled 'error' throw.
|
|
738
|
+
//
|
|
739
|
+
// Deliberately does NOT call `process.exit()` itself: `startDaemon` is a library entry point
|
|
740
|
+
// (embedded by `packages/desktop`, and booted in-process by the daemon integration tests), and a
|
|
741
|
+
// library must never kill its host. Killing the process here made a port collision in the test
|
|
742
|
+
// suite surface as an opaque, misattributed "process.exit unexpectedly called with 1" unhandled
|
|
743
|
+
// rejection with every test still reported green. The process-level decision belongs to the
|
|
744
|
+
// process entry point, which passes `onFatalError` (see `daemon/main.ts`).
|
|
731
745
|
httpServer.on("error", (err) => {
|
|
732
746
|
if (err.code === "EADDRINUSE") {
|
|
733
747
|
logger.error({ host: opts.host, port: opts.port }, "cannot bind — address already in use");
|
|
@@ -736,7 +750,7 @@ export function startDaemon(opts) {
|
|
|
736
750
|
logger.error({ err: err.message }, "http server error");
|
|
737
751
|
}
|
|
738
752
|
process.exitCode = 1;
|
|
739
|
-
void wsHandle.close().finally(() =>
|
|
753
|
+
void wsHandle.close().finally(() => opts.onFatalError?.(err));
|
|
740
754
|
});
|
|
741
755
|
httpServer.listen(opts.port, opts.host);
|
|
742
756
|
logger.info({ host: opts.host, port: opts.port }, "http/ws server accepting connections");
|
|
@@ -17,6 +17,7 @@ import { registerAgentUiHandlers } from "../agent/agent-ui/agent-ui-rpc.js";
|
|
|
17
17
|
import { AgentUiService } from "../agent/agent-ui/agent-ui-service.js";
|
|
18
18
|
import { AgentManager } from "../agent/agent-manager.js";
|
|
19
19
|
import { AgentService } from "../agent/agent-service.js";
|
|
20
|
+
import { deterministicFallback } from "../agent/structured-generation.js";
|
|
20
21
|
import { SessionOperationsService } from "../agent/session-operations.js";
|
|
21
22
|
import { SlashCommandOperationsService } from "../agent/slash-command-operations.js";
|
|
22
23
|
import { registerTimelineHandler } from "../agent/timeline-rpc.js";
|
|
@@ -78,7 +79,16 @@ export function startDevDaemon(opts) {
|
|
|
78
79
|
});
|
|
79
80
|
// ── Handler registry ────────────────────────────────────────────────────────
|
|
80
81
|
const registry = new HandlerRegistry(logger);
|
|
81
|
-
|
|
82
|
+
// Deterministic-only titler — never constructs a real ModelRuntime (this bootstrap's whole
|
|
83
|
+
// point is to never touch the developer's real ~/.pi/agent credential tree). Still exercises
|
|
84
|
+
// the full write path (record.title + agent_update broadcast) end to end for dev/mock sessions.
|
|
85
|
+
const agentService = new AgentService({
|
|
86
|
+
manager,
|
|
87
|
+
resolveClient,
|
|
88
|
+
broadcast,
|
|
89
|
+
logger,
|
|
90
|
+
generateAgentTitle: async ({ prompt }) => deterministicFallback("agent_title", { prompt }),
|
|
91
|
+
});
|
|
82
92
|
agentService.registerHandlers(registry, getActiveSessions);
|
|
83
93
|
const sessionOps = new SessionOperationsService({
|
|
84
94
|
manager,
|
|
@@ -103,7 +113,7 @@ export function startDevDaemon(opts) {
|
|
|
103
113
|
const agents = manager.list().map((m) => ({
|
|
104
114
|
agentId: m.record.id,
|
|
105
115
|
status: m.record.lastStatus,
|
|
106
|
-
title: m.record.labels?.["title"] ?? undefined,
|
|
116
|
+
title: m.record.labels?.["title"] ?? m.record.title ?? undefined,
|
|
107
117
|
cwd: m.record.cwd,
|
|
108
118
|
labels: m.record.labels ?? {},
|
|
109
119
|
lastActivity: new Date(m.record.updatedAt).getTime(),
|
package/dist/daemon/main.js
CHANGED
|
@@ -12,6 +12,9 @@ const info = createDaemonRuntimeInfo({
|
|
|
12
12
|
const handle = startDaemon({
|
|
13
13
|
host: info.listen.host,
|
|
14
14
|
port: info.listen.port,
|
|
15
|
+
// The process-level half of `startDaemon`'s fatal-error contract: the bootstrap logs the error
|
|
16
|
+
// and tears down the WS server, but leaves terminating the process to its entry point.
|
|
17
|
+
onFatalError: () => process.exit(1),
|
|
15
18
|
});
|
|
16
19
|
const log = handle.logger;
|
|
17
20
|
log.info({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@av-pi-studio/server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.105",
|
|
4
4
|
"bin": {
|
|
5
5
|
"pi-studio-daemon": "dist/daemon/main.js"
|
|
6
6
|
},
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@av-pi-studio/highlight": "^0.0.
|
|
28
|
-
"@av-pi-studio/protocol": "^0.0.
|
|
29
|
-
"@av-pi-studio/relay": "^0.0.
|
|
30
|
-
"@earendil-works/pi-coding-agent": "^0.84.
|
|
27
|
+
"@av-pi-studio/highlight": "^0.0.105",
|
|
28
|
+
"@av-pi-studio/protocol": "^0.0.105",
|
|
29
|
+
"@av-pi-studio/relay": "^0.0.105",
|
|
30
|
+
"@earendil-works/pi-coding-agent": "^0.84.4",
|
|
31
31
|
"@xterm/addon-serialize": "^0.14.0",
|
|
32
32
|
"@xterm/headless": "^6.0.0",
|
|
33
33
|
"bcryptjs": "^3.0.3",
|