trissue-embedded 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +59 -2
- package/dist/adapters/THIRD_PARTY_NOTICES.md +303 -0
- package/dist/adapters/codex.LICENSE +190 -0
- package/dist/adapters/codex.mjs +58034 -0
- package/dist/index.js +1637 -0
- package/dist/types/acp-session.d.ts +20 -0
- package/dist/types/agent.d.ts +4 -0
- package/dist/types/claude-session.d.ts +33 -0
- package/dist/types/config.d.ts +52 -0
- package/dist/types/harnesses.d.ts +35 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/issue.d.ts +17 -0
- package/dist/types/models.d.ts +16 -0
- package/dist/types/prompt.d.ts +19 -0
- package/dist/types/send.d.ts +34 -0
- package/dist/types/session.d.ts +98 -0
- package/dist/types/source.d.ts +34 -0
- package/dist/types/transcript.d.ts +23 -0
- package/dist/types/triage.d.ts +45 -0
- package/dist/types/version.d.ts +2 -0
- package/package.json +26 -4
- package/trissue.schema.json +50 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AgentSession, type StartOptions, type TurnEnd } from "./session.ts";
|
|
2
|
+
/**
|
|
3
|
+
* An agent spoken to over the Agent Client Protocol. trissue refuses every
|
|
4
|
+
* permission request to edit, run, or fetch, and picks a read-only mode when
|
|
5
|
+
* the agent has one.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AcpSession extends AgentSession {
|
|
8
|
+
private readonly child;
|
|
9
|
+
private readonly connection;
|
|
10
|
+
private readonly sessionId;
|
|
11
|
+
private readonly exited;
|
|
12
|
+
private readonly modelSetter;
|
|
13
|
+
readonly canSetModel: boolean;
|
|
14
|
+
private constructor();
|
|
15
|
+
static start(options: StartOptions): Promise<AcpSession>;
|
|
16
|
+
protected promptTurn(text: string): Promise<TurnEnd>;
|
|
17
|
+
protected cancelTurn(): void;
|
|
18
|
+
protected applyModel(id: string): Promise<void>;
|
|
19
|
+
protected dispose(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AgentSession, StartOptions } from "./session.ts";
|
|
2
|
+
export { AgentError, AgentSession, StoppedError, type AgentEvent, type StartOptions } from "./session.ts";
|
|
3
|
+
/** Launches the agent and opens a read-only session in `cwd`. */
|
|
4
|
+
export declare function startAgent(options: StartOptions): Promise<AgentSession>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { LaunchSpec } from "./harnesses.ts";
|
|
2
|
+
import { AgentSession, type StartOptions, type TurnEnd } from "./session.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Arguments for `claude -p` that make it a read-only agent trissue drives over
|
|
5
|
+
* stdin and stdout. `--setting-sources user` ignores the repository's own
|
|
6
|
+
* `.claude` settings, so a downloaded repo can't add hooks that run commands.
|
|
7
|
+
*/
|
|
8
|
+
export declare function claudeLaunch(executable: string): LaunchSpec;
|
|
9
|
+
/**
|
|
10
|
+
* Claude Code, driven directly through `claude -p` and its stream-json
|
|
11
|
+
* protocol. trissue ships no Claude code of its own: it runs the `claude` the
|
|
12
|
+
* user installed.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ClaudeSession extends AgentSession {
|
|
15
|
+
private readonly child;
|
|
16
|
+
private readonly exited;
|
|
17
|
+
private readonly cwd;
|
|
18
|
+
readonly canSetModel = true;
|
|
19
|
+
private requestCount;
|
|
20
|
+
private readonly pending;
|
|
21
|
+
private turnEnded;
|
|
22
|
+
private cancelling;
|
|
23
|
+
private readonly toolNames;
|
|
24
|
+
private constructor();
|
|
25
|
+
static start(options: StartOptions): Promise<ClaudeSession>;
|
|
26
|
+
private send;
|
|
27
|
+
private control;
|
|
28
|
+
private receive;
|
|
29
|
+
protected promptTurn(text: string): Promise<TurnEnd>;
|
|
30
|
+
protected cancelTurn(): void;
|
|
31
|
+
protected applyModel(id: string): Promise<void>;
|
|
32
|
+
protected dispose(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** The file a repository puts at its root to configure trissue. */
|
|
2
|
+
export declare const CONFIG_FILE = ".trissue.json";
|
|
3
|
+
/** A place the user can send the issue by opening a URL. */
|
|
4
|
+
export interface LinkTarget {
|
|
5
|
+
/** Button text, like "Discord" or "Email the team". */
|
|
6
|
+
label: string;
|
|
7
|
+
/**
|
|
8
|
+
* The URL to open. `{title}`, `{body}` and `{issue}` are replaced with the
|
|
9
|
+
* URL-encoded issue title, body, or the whole copied issue text.
|
|
10
|
+
*/
|
|
11
|
+
url: string;
|
|
12
|
+
/** One sentence that says where the link goes. Shown before it opens. */
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ModelFilter {
|
|
16
|
+
/** Only these models may be used. Patterns match `harness/model`, `*` is a wildcard. */
|
|
17
|
+
allow?: string[];
|
|
18
|
+
/** These models may never be used. Checked after `allow`. */
|
|
19
|
+
block?: string[];
|
|
20
|
+
}
|
|
21
|
+
/** Everything a `.trissue.json` can set. Every field is optional. */
|
|
22
|
+
export interface TrissueConfig {
|
|
23
|
+
product?: {
|
|
24
|
+
/** Shown in the header as "<name> Triage". Defaults to the repository name. */
|
|
25
|
+
name?: string;
|
|
26
|
+
/** Hex color of the product name. */
|
|
27
|
+
color?: string;
|
|
28
|
+
};
|
|
29
|
+
/** Background color of the whole interface. Defaults to black. */
|
|
30
|
+
background?: string;
|
|
31
|
+
/** Text above the issue input. */
|
|
32
|
+
prompt?: string;
|
|
33
|
+
/** How the issue should be written. Replaces the default writing guide. */
|
|
34
|
+
instructions?: string;
|
|
35
|
+
/** Which models are allowed. */
|
|
36
|
+
models?: ModelFilter;
|
|
37
|
+
/** The checkmark next to "Use default model". Green unless set to monochrome. */
|
|
38
|
+
checkmark?: "green" | "monochrome";
|
|
39
|
+
/** Where GitHub issues are filed, as `owner/repo`. `false` hides GitHub filing. */
|
|
40
|
+
github?: string | false;
|
|
41
|
+
/** Labels added to GitHub issues. Labels that don't exist on the repo are skipped by GitHub. */
|
|
42
|
+
labels?: string[];
|
|
43
|
+
/** Extra places to send the issue. */
|
|
44
|
+
links?: LinkTarget[];
|
|
45
|
+
}
|
|
46
|
+
export declare class ConfigError extends Error {
|
|
47
|
+
name: string;
|
|
48
|
+
}
|
|
49
|
+
/** Checks untrusted JSON and returns it as a config, or throws a ConfigError naming the bad field. */
|
|
50
|
+
export declare function parseConfig(raw: unknown): TrissueConfig;
|
|
51
|
+
/** Reads `.trissue.json` from a folder. Returns null when the file doesn't exist. */
|
|
52
|
+
export declare function loadConfig(dir: string): Promise<TrissueConfig | null>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** How a harness's name is drawn. Brand colors are fixed; repositories can't change them. */
|
|
2
|
+
export interface HarnessBrand {
|
|
3
|
+
/** The name's color in the list. Several colors make a left-to-right gradient. */
|
|
4
|
+
color: string[];
|
|
5
|
+
/** Text color when the harness is selected and `color` becomes the background. */
|
|
6
|
+
selectedText: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LaunchSpec {
|
|
9
|
+
command: string;
|
|
10
|
+
args: string[];
|
|
11
|
+
env: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
/** A coding agent on this computer that trissue can run over ACP. */
|
|
14
|
+
export interface Harness {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
/** Null for harnesses without brand colors; they draw in the interface's text color. */
|
|
18
|
+
brand: HarnessBrand | null;
|
|
19
|
+
/** "claude" drives `claude -p` directly; everything else speaks ACP. */
|
|
20
|
+
protocol: "acp" | "claude";
|
|
21
|
+
/** The installed program trissue found. */
|
|
22
|
+
executable: string;
|
|
23
|
+
launch: LaunchSpec;
|
|
24
|
+
}
|
|
25
|
+
/** Looks a program up on PATH, like `which`. */
|
|
26
|
+
export declare function findExecutable(name: string, path?: string): string | null;
|
|
27
|
+
/** The harnesses installed on this computer, brand harnesses first. */
|
|
28
|
+
export declare function detectHarnesses(path?: string): Harness[];
|
|
29
|
+
/** Every harness trissue knows, installed or not. For docs and tests. */
|
|
30
|
+
export declare function knownHarnesses(): {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
bins: string[];
|
|
34
|
+
branded: boolean;
|
|
35
|
+
}[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { AgentError, AgentSession, StoppedError, startAgent, type AgentEvent, type StartOptions } from "./agent.ts";
|
|
2
|
+
export { VERSION } from "./version.ts";
|
|
3
|
+
export { CONFIG_FILE, ConfigError, loadConfig, parseConfig, type LinkTarget, type ModelFilter, type TrissueConfig } from "./config.ts";
|
|
4
|
+
export { detectHarnesses, findExecutable, knownHarnesses, type Harness, type HarnessBrand, type LaunchSpec } from "./harnesses.ts";
|
|
5
|
+
export { NoIssueError, RejectedError, formatIssue, parseIssue, type Issue } from "./issue.ts";
|
|
6
|
+
export { filterModels, hasModelFilter, isModelAllowed, type ModelOption } from "./models.ts";
|
|
7
|
+
export { DEFAULT_INSTRUCTIONS, buildPrompt, buildSteerPrompt, type PromptInput } from "./prompt.ts";
|
|
8
|
+
export { GITHUB_LOGIN_ARGS, SendError, buildLink, copyIssue, copyText, fileGitHubIssue, gitHubStatus, hasClipboard, linkIncludesIssue, openUrl, type GitHubStatus, } from "./send.ts";
|
|
9
|
+
export { SourceError, fetchSource, resolveSource, type FetchedSource, type RepoSource } from "./source.ts";
|
|
10
|
+
export { TriageError, chooseModel, pickHarness, runTriage, type TriageOptions, type TriageResult } from "./triage.ts";
|
|
11
|
+
export { Transcript, type TranscriptEntry } from "./transcript.ts";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Issue {
|
|
2
|
+
title: string;
|
|
3
|
+
/** Markdown. */
|
|
4
|
+
body: string;
|
|
5
|
+
}
|
|
6
|
+
/** The agent turned the task down, usually because the repository's instructions looked malicious. */
|
|
7
|
+
export declare class RejectedError extends Error {
|
|
8
|
+
name: string;
|
|
9
|
+
}
|
|
10
|
+
/** The agent finished but didn't write an issue in the required form. */
|
|
11
|
+
export declare class NoIssueError extends Error {
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
/** Reads the issue out of the agent's final message. Throws when it rejected the task or wrote no issue. */
|
|
15
|
+
export declare function parseIssue(text: string): Issue;
|
|
16
|
+
/** The issue as plain text, the way "Copy issue" puts it on the clipboard. */
|
|
17
|
+
export declare function formatIssue(issue: Issue): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ModelFilter } from "./config.ts";
|
|
2
|
+
export interface ModelOption {
|
|
3
|
+
/** The value the agent uses for this model. */
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Whether the repository allows a model. Patterns match `harness/model` (for
|
|
10
|
+
* example `claude/*` or `*\/gpt-5*`); a pattern without a slash matches the
|
|
11
|
+
* model id alone.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isModelAllowed(filter: ModelFilter | undefined, harnessId: string, modelId: string): boolean;
|
|
14
|
+
/** Whether a filter limits models at all. */
|
|
15
|
+
export declare function hasModelFilter(filter: ModelFilter | undefined): boolean;
|
|
16
|
+
export declare function filterModels(filter: ModelFilter | undefined, harnessId: string, models: ModelOption[]): ModelOption[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FetchedSource } from "./source.ts";
|
|
2
|
+
/**
|
|
3
|
+
* How issues are written unless the repository sets `instructions`.
|
|
4
|
+
* Adapted from the file-pr and leaving-pr-comments skills in t3dotgg/tstack.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_INSTRUCTIONS = "Write the issue the way a maintainer wants to read it.\n\nTitle: one short, human sentence about what the user sees go wrong. Not the\ncause, not an implementation detail.\n\nBAD: Null check missing in SessionStore.restore()\nGOOD: The app forgets my open tabs after a restart\n\nOpen the body with the problem in plain words, based on what the user said.\nThen say what you found:\n\n- The likely cause, with links to the exact lines at the commit you read.\n- How sure you are, and why. Keep verified facts apart from your judgment.\n- Steps to reproduce, if you know them.\n- Anything the maintainer should check that you couldn't.\n\nLead with the conclusion. Cite code, not guesses. No filler, no thanks, no\nheadings for a two-line body. If you found nothing, say so plainly; a short\nhonest issue beats a long wrong one.\n\nBefore you finish, check the title and body for secrets and private details\n(tokens, emails, home folder paths, hostnames) and remove them.";
|
|
7
|
+
export interface PromptInput {
|
|
8
|
+
/** What the user typed. */
|
|
9
|
+
issue: string;
|
|
10
|
+
source: FetchedSource;
|
|
11
|
+
/** The repository's `instructions`, or undefined for the default guide. */
|
|
12
|
+
instructions?: string;
|
|
13
|
+
harnessName: string;
|
|
14
|
+
modelName?: string;
|
|
15
|
+
}
|
|
16
|
+
/** The full prompt sent to the agent. */
|
|
17
|
+
export declare function buildPrompt(input: PromptInput): string;
|
|
18
|
+
/** The prompt sent when the user steers the agent partway through. */
|
|
19
|
+
export declare function buildSteerPrompt(text: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { LinkTarget } from "./config.ts";
|
|
2
|
+
import { type Issue } from "./issue.ts";
|
|
3
|
+
export declare class SendError extends Error {
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export type GitHubStatus = {
|
|
7
|
+
state: "missing";
|
|
8
|
+
} | {
|
|
9
|
+
state: "signed-out";
|
|
10
|
+
} | {
|
|
11
|
+
state: "signed-in";
|
|
12
|
+
login: string;
|
|
13
|
+
};
|
|
14
|
+
/** Whether the GitHub CLI is installed and signed in to github.com. */
|
|
15
|
+
export declare function gitHubStatus(): Promise<GitHubStatus>;
|
|
16
|
+
/** The command that signs the GitHub CLI in. It is interactive and needs the terminal. */
|
|
17
|
+
export declare const GITHUB_LOGIN_ARGS: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Files the issue with `gh issue create` and returns its URL. Labels the
|
|
20
|
+
* repository doesn't have are left off, because gh refuses unknown labels.
|
|
21
|
+
*/
|
|
22
|
+
export declare function fileGitHubIssue(repo: string, issue: Issue, labels?: string[]): Promise<string>;
|
|
23
|
+
/** Whether this computer has a clipboard program trissue can use. */
|
|
24
|
+
export declare function hasClipboard(): boolean;
|
|
25
|
+
/** Puts text on the system clipboard. */
|
|
26
|
+
export declare function copyText(text: string): Promise<void>;
|
|
27
|
+
/** Copies the issue as "Title: …" and "Issue Content: …". */
|
|
28
|
+
export declare function copyIssue(issue: Issue): Promise<void>;
|
|
29
|
+
/** Fills a link's `{title}`, `{body}` and `{issue}` with the URL-encoded issue. */
|
|
30
|
+
export declare function buildLink(link: LinkTarget, issue: Issue): string;
|
|
31
|
+
/** Whether a link carries the issue in it. */
|
|
32
|
+
export declare function linkIncludesIssue(link: LinkTarget): boolean;
|
|
33
|
+
/** Opens a URL in the default browser or mail app. */
|
|
34
|
+
export declare function openUrl(url: string): Promise<void>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import type { Harness, LaunchSpec } from "./harnesses.ts";
|
|
3
|
+
import type { ModelOption } from "./models.ts";
|
|
4
|
+
/** Something the agent did, in the order it happened. */
|
|
5
|
+
export type AgentEvent = {
|
|
6
|
+
type: "text";
|
|
7
|
+
channel: "thought" | "message";
|
|
8
|
+
text: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: "tool";
|
|
11
|
+
id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
kind: string;
|
|
14
|
+
status: string;
|
|
15
|
+
}
|
|
16
|
+
/** A tool call trissue refused, because it could change or leave the computer. */
|
|
17
|
+
| {
|
|
18
|
+
type: "blocked";
|
|
19
|
+
id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
kind: string;
|
|
22
|
+
} | {
|
|
23
|
+
type: "steer";
|
|
24
|
+
text: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: "notice";
|
|
27
|
+
text: string;
|
|
28
|
+
};
|
|
29
|
+
export declare class AgentError extends Error {
|
|
30
|
+
name: string;
|
|
31
|
+
}
|
|
32
|
+
/** The user stopped the agent. */
|
|
33
|
+
export declare class StoppedError extends Error {
|
|
34
|
+
name: string;
|
|
35
|
+
constructor();
|
|
36
|
+
}
|
|
37
|
+
export interface StartOptions {
|
|
38
|
+
harness: Harness;
|
|
39
|
+
/** The folder the agent investigates. */
|
|
40
|
+
cwd: string;
|
|
41
|
+
onEvent?: (event: AgentEvent) => void;
|
|
42
|
+
/** Overrides how the agent is launched. For tests and custom setups. */
|
|
43
|
+
launch?: LaunchSpec;
|
|
44
|
+
}
|
|
45
|
+
/** How a turn ended: finished, or cancelled by trissue (to steer or stop). */
|
|
46
|
+
export type TurnEnd = "end" | "cancelled";
|
|
47
|
+
/** A running agent process, with its last stderr kept for error messages. */
|
|
48
|
+
export interface AgentProcess {
|
|
49
|
+
child: ChildProcess;
|
|
50
|
+
/** Rejects with an AgentError when the process fails to start or exits. Never resolves. */
|
|
51
|
+
exited: Promise<never>;
|
|
52
|
+
}
|
|
53
|
+
export declare function spawnAgent(name: string, spec: LaunchSpec, cwd: string): AgentProcess;
|
|
54
|
+
/**
|
|
55
|
+
* One agent and one conversation with it. Start it with `startAgent`,
|
|
56
|
+
* optionally pick a model, then `run` the prompt. The agent can only read the
|
|
57
|
+
* repository.
|
|
58
|
+
*/
|
|
59
|
+
export declare abstract class AgentSession {
|
|
60
|
+
readonly harness: Harness;
|
|
61
|
+
/** Models the agent offers, before any repository filter. Empty when it doesn't list them. */
|
|
62
|
+
readonly models: ModelOption[];
|
|
63
|
+
protected modelId: string | undefined;
|
|
64
|
+
private running;
|
|
65
|
+
private pendingSteer;
|
|
66
|
+
private stopped;
|
|
67
|
+
/** Everything the agent has said (not its thinking), across turns. */
|
|
68
|
+
private said;
|
|
69
|
+
private readonly listener;
|
|
70
|
+
protected constructor(harness: Harness, models: ModelOption[], modelId: string | undefined, onEvent: ((event: AgentEvent) => void) | undefined);
|
|
71
|
+
/** Sends one prompt and resolves when the agent's turn ends. Throws AgentError on failure. */
|
|
72
|
+
protected abstract promptTurn(text: string): Promise<TurnEnd>;
|
|
73
|
+
/** Asks the agent to end the current turn; `promptTurn` then resolves "cancelled". */
|
|
74
|
+
protected abstract cancelTurn(): void;
|
|
75
|
+
protected abstract applyModel(id: string): Promise<void>;
|
|
76
|
+
/** Ends the agent process. */
|
|
77
|
+
protected abstract dispose(): void;
|
|
78
|
+
/** Whether the agent lets trissue pick the model. */
|
|
79
|
+
abstract readonly canSetModel: boolean;
|
|
80
|
+
protected emit(event: AgentEvent): void;
|
|
81
|
+
/** The model the session uses now, if the agent says. */
|
|
82
|
+
get currentModel(): ModelOption | undefined;
|
|
83
|
+
setModel(id: string): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Sends the prompt and waits until the agent is done. Returns everything the
|
|
86
|
+
* agent said, across steered turns.
|
|
87
|
+
*/
|
|
88
|
+
run(prompt: string): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* Sends the user's words to the agent mid-task. The current turn is
|
|
91
|
+
* cancelled and a new one starts with the steering, in the same conversation.
|
|
92
|
+
*/
|
|
93
|
+
steer(text: string): void;
|
|
94
|
+
/** Stops the agent. `run` rejects with StoppedError. */
|
|
95
|
+
stop(): void;
|
|
96
|
+
/** Ends the session and the agent process. */
|
|
97
|
+
close(): void;
|
|
98
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Where the repository being triaged comes from. */
|
|
2
|
+
export interface RepoSource {
|
|
3
|
+
kind: "local" | "remote";
|
|
4
|
+
/** The owner or organization, like "MileniumHQ". Empty when a local folder has no remote. */
|
|
5
|
+
org: string;
|
|
6
|
+
/** The repository name, like "Paperboard". */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Where it was downloaded from, like "github.com", or "this computer" for a local folder. */
|
|
9
|
+
origin: string;
|
|
10
|
+
/** Clone URL for remote sources. */
|
|
11
|
+
url?: string;
|
|
12
|
+
/** Branch, tag or commit to check out. */
|
|
13
|
+
ref?: string;
|
|
14
|
+
/** `owner/repo` when the repository lives on github.com. */
|
|
15
|
+
github?: string;
|
|
16
|
+
}
|
|
17
|
+
/** A source that is on disk and ready to investigate. */
|
|
18
|
+
export interface FetchedSource extends RepoSource {
|
|
19
|
+
dir: string;
|
|
20
|
+
/** The checked-out commit. */
|
|
21
|
+
commit: string;
|
|
22
|
+
/** Deletes the download. Does nothing for local folders. */
|
|
23
|
+
dispose(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare class SourceError extends Error {
|
|
26
|
+
name: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Turns what the user typed into a source. Accepts `owner/repo` (GitHub),
|
|
30
|
+
* `host/owner/repo`, a clone URL, or a local folder. Nothing is downloaded yet.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveSource(spec: string | undefined, ref?: string): Promise<RepoSource>;
|
|
33
|
+
/** Downloads a remote source into a temporary folder, or checks a local one. */
|
|
34
|
+
export declare function fetchSource(source: RepoSource): Promise<FetchedSource>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AgentEvent } from "./agent.ts";
|
|
2
|
+
export interface TranscriptEntry {
|
|
3
|
+
/** Stable for the life of the entry, so a UI can keep its rows. */
|
|
4
|
+
id: string;
|
|
5
|
+
kind: "thought" | "message" | "tool" | "blocked" | "steer" | "notice";
|
|
6
|
+
text: string;
|
|
7
|
+
/** Tool calls: pending, in_progress, completed or failed. */
|
|
8
|
+
status?: string;
|
|
9
|
+
/** Tool calls: read, search, edit, execute… */
|
|
10
|
+
toolKind?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Turns the agent's event stream into readable entries: text chunks join the
|
|
14
|
+
* entry before them, and tool updates change their tool's entry in place.
|
|
15
|
+
*/
|
|
16
|
+
export declare class Transcript {
|
|
17
|
+
readonly entries: TranscriptEntry[];
|
|
18
|
+
private readonly tools;
|
|
19
|
+
private count;
|
|
20
|
+
/** Applies an event. Returns the entry it created or changed. */
|
|
21
|
+
apply(event: AgentEvent): TranscriptEntry;
|
|
22
|
+
private push;
|
|
23
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type AgentEvent, type AgentSession } from "./agent.ts";
|
|
2
|
+
import { type TrissueConfig } from "./config.ts";
|
|
3
|
+
import { type Harness } from "./harnesses.ts";
|
|
4
|
+
import { type Issue } from "./issue.ts";
|
|
5
|
+
import { type FetchedSource } from "./source.ts";
|
|
6
|
+
export declare class TriageError extends Error {
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
export interface TriageOptions {
|
|
10
|
+
/** What the user says is wrong. */
|
|
11
|
+
issue: string;
|
|
12
|
+
/** `owner/repo`, a clone URL, or a folder. Ignored when `source` is given. */
|
|
13
|
+
repo?: string;
|
|
14
|
+
/** Branch, tag or commit to check out when downloading. */
|
|
15
|
+
ref?: string;
|
|
16
|
+
/** An already fetched source. The caller disposes it. */
|
|
17
|
+
source?: FetchedSource;
|
|
18
|
+
/** Harness id, like "claude". Defaults to the first one installed. */
|
|
19
|
+
harness?: string;
|
|
20
|
+
/** Model id. Defaults to the agent's default model. */
|
|
21
|
+
model?: string;
|
|
22
|
+
onEvent?: (event: AgentEvent) => void;
|
|
23
|
+
/** Aborting stops the agent; the promise rejects with StoppedError. */
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
export interface TriageResult {
|
|
27
|
+
issue: Issue;
|
|
28
|
+
config: TrissueConfig | null;
|
|
29
|
+
source: FetchedSource;
|
|
30
|
+
harness: Harness;
|
|
31
|
+
model?: string;
|
|
32
|
+
}
|
|
33
|
+
/** Picks a harness by id from the installed ones, or the first installed one. */
|
|
34
|
+
export declare function pickHarness(id?: string): Harness;
|
|
35
|
+
/**
|
|
36
|
+
* Picks the model a session will use under the repository's filter: the
|
|
37
|
+
* requested one, else the agent's default. Throws when the filter allows neither.
|
|
38
|
+
*/
|
|
39
|
+
export declare function chooseModel(session: AgentSession, config: TrissueConfig | null, requested?: string): Promise<string | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* The whole flow without an interface: fetch the repository, start the
|
|
42
|
+
* agent, investigate, and return the written issue. Sending it is up to the
|
|
43
|
+
* caller (see `fileGitHubIssue`, `copyIssue`, `buildLink`).
|
|
44
|
+
*/
|
|
45
|
+
export declare function runTriage(options: TriageOptions): Promise<TriageResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trissue-embedded",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "The trissue engine for apps: run the coding agent on the user's computer to investigate an issue and write it up.",
|
|
5
|
+
"keywords": ["issues", "bug report", "triage", "agent", "acp", "claude code", "codex"],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Pxl",
|
|
8
|
+
"repository": { "type": "git", "url": "git+https://github.com/pxlkt/trissue.git", "directory": "packages/embedded" },
|
|
9
|
+
"homepage": "https://github.com/pxlkt/trissue#readme",
|
|
10
|
+
"bugs": "https://github.com/pxlkt/trissue/issues",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": { "types": "./dist/types/index.d.ts", "default": "./dist/index.js" },
|
|
14
|
+
"./trissue.schema.json": "./trissue.schema.json"
|
|
15
|
+
},
|
|
16
|
+
"files": ["dist", "trissue.schema.json"],
|
|
17
|
+
"engines": { "node": ">=20" },
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "bun scripts/build.ts"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@agentclientprotocol/sdk": "2.8.0",
|
|
23
|
+
"zod": "^4.0.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@agentclientprotocol/codex-acp": "2.8.0"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "trissue configuration",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"definitions": {
|
|
7
|
+
"color": { "type": "string", "pattern": "^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$" }
|
|
8
|
+
},
|
|
9
|
+
"properties": {
|
|
10
|
+
"$schema": { "type": "string" },
|
|
11
|
+
"product": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"properties": {
|
|
15
|
+
"name": { "type": "string", "minLength": 1, "description": "Shown as \"<name> Triage\". Defaults to the repo name." },
|
|
16
|
+
"color": { "$ref": "#/definitions/color", "description": "Color of the product name." }
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"background": { "$ref": "#/definitions/color", "description": "Background of the interface. Defaults to black." },
|
|
20
|
+
"prompt": { "type": "string", "minLength": 1, "description": "Text above the issue input." },
|
|
21
|
+
"instructions": { "type": "string", "minLength": 1, "description": "How issues should be written. Replaces the default guide." },
|
|
22
|
+
"models": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"additionalProperties": false,
|
|
25
|
+
"properties": {
|
|
26
|
+
"allow": { "type": "array", "items": { "type": "string", "minLength": 1 }, "description": "Only these models. Patterns match agent/model or the model id; * is a wildcard." },
|
|
27
|
+
"block": { "type": "array", "items": { "type": "string", "minLength": 1 }, "description": "Never these models." }
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"checkmark": { "enum": ["green", "monochrome"], "description": "The checkmark next to \"Use default model\"." },
|
|
31
|
+
"github": {
|
|
32
|
+
"oneOf": [{ "type": "string", "pattern": "^[\\w.-]+/[\\w.-]+$" }, { "const": false }],
|
|
33
|
+
"description": "owner/repo to file issues on, or false to hide GitHub filing."
|
|
34
|
+
},
|
|
35
|
+
"labels": { "type": "array", "items": { "type": "string", "minLength": 1 }, "description": "Labels for GitHub issues. Ones the repo doesn't have are skipped." },
|
|
36
|
+
"links": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"items": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"additionalProperties": false,
|
|
41
|
+
"required": ["label", "url"],
|
|
42
|
+
"properties": {
|
|
43
|
+
"label": { "type": "string", "minLength": 1 },
|
|
44
|
+
"url": { "type": "string", "pattern": "^(https?:|mailto:)", "description": "{title}, {body} and {issue} become the URL-encoded issue." },
|
|
45
|
+
"description": { "type": "string", "minLength": 1, "description": "Where the link goes. Shown before it opens." }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|