@andorra-labs/code 0.1.16 → 0.1.18
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/dist/src/acp-agent.d.ts +6 -0
- package/dist/src/acp-agent.js +15 -4
- package/dist/src/agent-execution.js +108 -19
- package/dist/src/agent-mcp-catalog.js +1 -0
- package/dist/src/agent-mcp.d.ts +3 -0
- package/dist/src/agent-mcp.js +33 -1
- package/dist/src/andorra/entry.d.ts +10 -0
- package/dist/src/andorra/entry.js +18 -4
- package/dist/src/andorra/errors.js +3 -0
- package/dist/src/andorra/hosted.d.ts +2 -1
- package/dist/src/andorra/hosted.js +2 -1
- package/dist/src/andorra/notices.d.ts +5 -0
- package/dist/src/andorra/notices.js +7 -0
- package/dist/src/andorra/state.d.ts +3 -2
- package/dist/src/andorra/state.js +4 -4
- package/dist/src/andorra/terminal.js +7 -2
- package/dist/src/anthropic-credentials.js +2 -0
- package/dist/src/app-server/error.d.ts +5 -0
- package/dist/src/app-server/error.js +7 -0
- package/dist/src/app-server/protocol.d.ts +30 -44
- package/dist/src/app-server/protocol.js +5 -1
- package/dist/src/app-server/workspace.d.ts +108 -0
- package/dist/src/app-server/workspace.js +608 -11
- package/dist/src/app-server.d.ts +390 -33
- package/dist/src/app-server.js +3033 -565
- package/dist/src/attachments.d.ts +10 -0
- package/dist/src/attachments.js +102 -7
- package/dist/src/automation-tool.js +2 -1
- package/dist/src/bridge/cloud.d.ts +27 -0
- package/dist/src/bridge/cloud.js +187 -0
- package/dist/src/bridge/command.d.ts +30 -0
- package/dist/src/bridge/command.js +359 -0
- package/dist/src/bridge/control.d.ts +70 -0
- package/dist/src/bridge/control.js +238 -0
- package/dist/src/bridge/engines.d.ts +90 -0
- package/dist/src/bridge/engines.js +601 -0
- package/dist/src/bridge/github.d.ts +108 -0
- package/dist/src/bridge/github.js +378 -0
- package/dist/src/bridge/host-ops.d.ts +9 -0
- package/dist/src/bridge/host-ops.js +139 -0
- package/dist/src/bridge/host.d.ts +47 -0
- package/dist/src/bridge/host.js +543 -0
- package/dist/src/bridge/link.d.ts +38 -0
- package/dist/src/bridge/link.js +508 -0
- package/dist/src/bridge/login-link.d.ts +29 -0
- package/dist/src/bridge/login-link.js +54 -0
- package/dist/src/bridge/protocol.d.ts +136 -0
- package/dist/src/bridge/protocol.js +11 -0
- package/dist/src/bridge/store.d.ts +12 -0
- package/dist/src/bridge/store.js +61 -0
- package/dist/src/bridge/wording.d.ts +6 -0
- package/dist/src/bridge/wording.js +10 -0
- package/dist/src/browser-server.js +7 -1
- package/dist/src/browser-ui/tokens.css +1 -1
- package/dist/src/bug-report-attachments.d.ts +48 -0
- package/dist/src/bug-report-attachments.js +327 -0
- package/dist/src/bug-report.d.ts +23 -3
- package/dist/src/bug-report.js +72 -9
- package/dist/src/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/cli.d.ts +1 -3
- package/dist/src/cli.js +191 -35
- package/dist/src/codex-provider.js +1 -1
- package/dist/src/coding-tools.js +24 -17
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +14 -11
- package/dist/src/commands.d.ts +15 -3
- package/dist/src/commands.js +2 -1
- package/dist/src/compaction-phrases.js +1 -1
- package/dist/src/completion.js +89 -8
- package/dist/src/config.d.ts +71 -3
- package/dist/src/config.js +205 -78
- package/dist/src/context-budget.js +15 -2
- package/dist/src/deadline.js +13 -1
- package/dist/src/decision/DecisionEngine.d.ts +2 -0
- package/dist/src/decision/DecisionManager.d.ts +11 -0
- package/dist/src/decision/DecisionManager.js +36 -0
- package/dist/src/decision/applyTaskKind.d.ts +8 -0
- package/dist/src/decision/applyTaskKind.js +53 -0
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/hostedPolicy.js +2 -1
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +2 -0
- package/dist/src/decision/providers/AndorraDecisionProvider.js +12 -0
- package/dist/src/decision/requestPhrases.js +0 -1
- package/dist/src/decision/taskKind.d.ts +52 -0
- package/dist/src/decision/taskKind.js +76 -0
- package/dist/src/decision/types.d.ts +1 -1
- package/dist/src/default-graph.js +1 -1
- package/dist/src/efficiency.d.ts +5 -0
- package/dist/src/efficiency.js +5 -1
- package/dist/src/effort-routing.d.ts +27 -0
- package/dist/src/effort-routing.js +34 -0
- package/dist/src/evidence.d.ts +110 -0
- package/dist/src/evidence.js +195 -0
- package/dist/src/file-diff.d.ts +4 -0
- package/dist/src/file-diff.js +2 -1
- package/dist/src/github-app/agent-writes.d.ts +102 -0
- package/dist/src/github-app/agent-writes.js +320 -0
- package/dist/src/github-app/client.d.ts +368 -0
- package/dist/src/github-app/client.js +830 -0
- package/dist/src/github-app/event-source.d.ts +208 -0
- package/dist/src/github-app/event-source.js +684 -0
- package/dist/src/github-app/metrics.d.ts +32 -0
- package/dist/src/github-app/metrics.js +49 -0
- package/dist/src/github-app/review-loop.d.ts +274 -0
- package/dist/src/github-app/review-loop.js +1177 -0
- package/dist/src/github-app/review-node.d.ts +81 -0
- package/dist/src/github-app/review-node.js +205 -0
- package/dist/src/github-app/review-post.d.ts +73 -0
- package/dist/src/github-app/review-post.js +139 -0
- package/dist/src/github-app/review-text.d.ts +107 -0
- package/dist/src/github-app/review-text.js +1133 -0
- package/dist/src/github-app/review-threads.d.ts +47 -0
- package/dist/src/github-app/review-threads.js +107 -0
- package/dist/src/github-app/reviewer.d.ts +121 -0
- package/dist/src/github-app/reviewer.js +598 -0
- package/dist/src/github-app/store.d.ts +59 -0
- package/dist/src/github-app/store.js +148 -0
- package/dist/src/github-app/triggers.d.ts +141 -0
- package/dist/src/github-app/triggers.js +441 -0
- package/dist/src/github-names.d.ts +15 -0
- package/dist/src/github-names.js +15 -0
- package/dist/src/glob-search.d.ts +61 -0
- package/dist/src/glob-search.js +180 -0
- package/dist/src/graph-health.js +6 -1
- package/dist/src/graph-manager-chat.js +1 -1
- package/dist/src/graph-preview.d.ts +48 -0
- package/dist/src/graph-preview.js +56 -0
- package/dist/src/graph-provider-portability.js +2 -1
- package/dist/src/graph-runner.js +65 -4
- package/dist/src/graph-server.js +7 -5
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +121 -7
- package/dist/src/graph-ui/icons.js +2 -1
- package/dist/src/graph-ui/studio.js +15 -1
- package/dist/src/graph-ui/tokens.css +1 -1
- package/dist/src/graphs.d.ts +40 -1
- package/dist/src/graphs.js +164 -15
- package/dist/src/hardened-runtime.js +32 -21
- package/dist/src/image-input.d.ts +16 -0
- package/dist/src/image-input.js +41 -0
- package/dist/src/membership.d.ts +10 -0
- package/dist/src/membership.js +19 -4
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +6 -0
- package/dist/src/model-metadata.js +35 -15
- package/dist/src/model-override.d.ts +2 -1
- package/dist/src/model-override.js +9 -0
- package/dist/src/model-relay/local.d.ts +116 -0
- package/dist/src/model-relay/local.js +468 -0
- package/dist/src/model-relay/remote.d.ts +129 -0
- package/dist/src/model-relay/remote.js +252 -0
- package/dist/src/model-relay/runs.d.ts +34 -0
- package/dist/src/model-relay/runs.js +146 -0
- package/dist/src/model-relay/wire.d.ts +5 -0
- package/dist/src/model-relay/wire.js +5 -0
- package/dist/src/model-tiers.d.ts +3 -0
- package/dist/src/model-tiers.js +3 -3
- package/dist/src/project-registry.d.ts +21 -0
- package/dist/src/project-registry.js +74 -0
- package/dist/src/provider-engine.d.ts +13 -1
- package/dist/src/provider-engine.js +74 -0
- package/dist/src/provider-import.d.ts +0 -12
- package/dist/src/provider-import.js +7 -195
- package/dist/src/providers.d.ts +28 -2
- package/dist/src/providers.js +59 -12
- package/dist/src/pull-request-logs.d.ts +12 -1
- package/dist/src/pull-request-logs.js +14 -3
- package/dist/src/pull-requests.d.ts +338 -8
- package/dist/src/pull-requests.js +482 -53
- package/dist/src/react-runtime.js +99 -16
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +367 -90
- package/dist/src/remote/roots.d.ts +19 -0
- package/dist/src/remote/roots.js +45 -7
- package/dist/src/remote/types.d.ts +0 -44
- package/dist/src/run-control.d.ts +7 -0
- package/dist/src/run-control.js +23 -0
- package/dist/src/run-records.d.ts +7 -2
- package/dist/src/run-records.js +71 -6
- package/dist/src/runtime.d.ts +34 -2
- package/dist/src/runtime.js +18 -2
- package/dist/src/session-changes.d.ts +35 -0
- package/dist/src/session-changes.js +194 -6
- package/dist/src/session-monitor.js +2 -1
- package/dist/src/session-reaper.d.ts +1 -1
- package/dist/src/session-reaper.js +6 -1
- package/dist/src/session-summary.d.ts +2 -1
- package/dist/src/session-summary.js +2 -1
- package/dist/src/sessions.d.ts +35 -1
- package/dist/src/sessions.js +70 -4
- package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
- package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
- package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
- package/dist/src/skills/bundled/provenance.json +3 -3
- package/dist/src/skills/runtime-skills.js +1 -1
- package/dist/src/task-checkout.d.ts +141 -0
- package/dist/src/task-checkout.js +558 -0
- package/dist/src/telemetry/emitter.d.ts +15 -0
- package/dist/src/telemetry/emitter.js +35 -1
- package/dist/src/telemetry/schema.d.ts +25 -2
- package/dist/src/telemetry/schema.js +52 -4
- package/dist/src/telemetry/surface.d.ts +2 -1
- package/dist/src/telemetry/surface.js +4 -1
- package/dist/src/terminal-ui.d.ts +1 -0
- package/dist/src/terminal-ui.js +10 -3
- package/dist/src/test-edit-guard.d.ts +37 -0
- package/dist/src/test-edit-guard.js +216 -3
- package/dist/src/thinking-level-detect.d.ts +11 -0
- package/dist/src/thinking-level-detect.js +47 -0
- package/dist/src/thinking-levels.d.ts +30 -0
- package/dist/src/thinking-levels.js +124 -0
- package/dist/src/timers.d.ts +3 -0
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/tools.js +59 -9
- package/dist/src/transcript.js +1 -1
- package/dist/src/types.d.ts +34 -0
- package/package.json +6 -1
- package/dist/src/remote/cert.d.ts +0 -11
- package/dist/src/remote/cert.js +0 -87
- package/dist/src/remote/client.d.ts +0 -119
- package/dist/src/remote/client.js +0 -544
- package/dist/src/remote/command.d.ts +0 -4
- package/dist/src/remote/command.js +0 -194
- package/dist/src/remote/errors.d.ts +0 -11
- package/dist/src/remote/errors.js +0 -14
- package/dist/src/remote/network.d.ts +0 -22
- package/dist/src/remote/network.js +0 -102
- package/dist/src/remote/pairing.d.ts +0 -63
- package/dist/src/remote/pairing.js +0 -299
- package/dist/src/remote/pem.d.ts +0 -2
- package/dist/src/remote/pem.js +0 -7
- package/dist/src/remote/serve.d.ts +0 -68
- package/dist/src/remote/serve.js +0 -244
- package/dist/src/remote/server.d.ts +0 -21
- package/dist/src/remote/server.js +0 -406
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine's client for the account API's GitHub App routes (`design/specs/github-app.md`): the
|
|
3
|
+
* connection status, connecting and disconnecting, the engine's subscriptions, the inbox pull, and the
|
|
4
|
+
* agent's bot writes (which the service makes with an installation token it never hands out). Every call
|
|
5
|
+
* carries the Andorra sign-in's access token, as `src/membership.ts` and `src/bug-report.ts` do.
|
|
6
|
+
*/
|
|
7
|
+
export declare const GITHUB_COVERAGE_STATES: readonly ["covered", "signed-out", "not-connected", "not-installed", "not-covered", "suspended", "permissions-pending", "limit", "pending", "disabled", "unavailable"];
|
|
8
|
+
export type GitHubCoverage = typeof GITHUB_COVERAGE_STATES[number];
|
|
9
|
+
export declare const NOTICE_KINDS: readonly ["state", "head", "review", "comment", "thread", "checks", "coverage", "request"];
|
|
10
|
+
export type GitHubNoticeKind = typeof NOTICE_KINDS[number];
|
|
11
|
+
/** Where a `request` notice's comment is: the PR's conversation, a review thread, or a review's own text. */
|
|
12
|
+
export declare const MENTION_COMMENT_KINDS: readonly ["issue", "review_comment", "review"];
|
|
13
|
+
export type MentionCommentKind = typeof MENTION_COMMENT_KINDS[number];
|
|
14
|
+
export interface GitHubNotice {
|
|
15
|
+
id: string;
|
|
16
|
+
kind: GitHubNoticeKind;
|
|
17
|
+
action?: string;
|
|
18
|
+
owner?: string;
|
|
19
|
+
repo?: string;
|
|
20
|
+
repoId?: number;
|
|
21
|
+
number?: number;
|
|
22
|
+
actor?: string;
|
|
23
|
+
actorType?: string;
|
|
24
|
+
headSha?: string;
|
|
25
|
+
at?: string;
|
|
26
|
+
/** `request` only: the comment's GraphQL node id, never its text. */
|
|
27
|
+
commentId?: string;
|
|
28
|
+
commentKind?: MentionCommentKind;
|
|
29
|
+
/** `request` only: the comment's page on github.com, on the notice's own PR. */
|
|
30
|
+
commentUrl?: string;
|
|
31
|
+
/** `request` only, when the receiver sends it: when the comment was written (ISO). */
|
|
32
|
+
commentAt?: string;
|
|
33
|
+
}
|
|
34
|
+
/** A `request` notice as `parseNotice` accepts it: every field the receiver writes, checked, and no other. */
|
|
35
|
+
export type MentionNotice = GitHubNotice & {
|
|
36
|
+
kind: 'request';
|
|
37
|
+
owner: string;
|
|
38
|
+
repo: string;
|
|
39
|
+
repoId: number;
|
|
40
|
+
number: number;
|
|
41
|
+
actor: string;
|
|
42
|
+
actorType: 'User';
|
|
43
|
+
commentId: string;
|
|
44
|
+
commentKind: MentionCommentKind;
|
|
45
|
+
commentUrl: string;
|
|
46
|
+
};
|
|
47
|
+
export interface GitHubInstallation {
|
|
48
|
+
id: number;
|
|
49
|
+
account: string;
|
|
50
|
+
type: string;
|
|
51
|
+
selection: 'all' | 'selected';
|
|
52
|
+
suspended: boolean;
|
|
53
|
+
permissionsPending: boolean;
|
|
54
|
+
manageUrl?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface GitHubConnection {
|
|
57
|
+
login: string;
|
|
58
|
+
githubUserId: number;
|
|
59
|
+
linkedAt?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface GitHubAppStatus {
|
|
62
|
+
enabled: boolean;
|
|
63
|
+
allowed: boolean;
|
|
64
|
+
bot?: string;
|
|
65
|
+
installUrl?: string;
|
|
66
|
+
connection: GitHubConnection | null;
|
|
67
|
+
installations: GitHubInstallation[];
|
|
68
|
+
}
|
|
69
|
+
/** A repository the App can reach for the linked GitHub user; `push` is whether that user can push to it. */
|
|
70
|
+
export interface GitHubRepository {
|
|
71
|
+
id: number;
|
|
72
|
+
owner: string;
|
|
73
|
+
name: string;
|
|
74
|
+
private: boolean;
|
|
75
|
+
push: boolean;
|
|
76
|
+
}
|
|
77
|
+
/** `more`: the service left some repositories out for now (a large installation); asking again later lists further. */
|
|
78
|
+
export interface GitHubRepositoriesAnswer {
|
|
79
|
+
enabled: boolean;
|
|
80
|
+
connected: boolean;
|
|
81
|
+
repositories: GitHubRepository[];
|
|
82
|
+
more: boolean;
|
|
83
|
+
}
|
|
84
|
+
export interface SubscriptionRequest {
|
|
85
|
+
owner: string;
|
|
86
|
+
repo: string;
|
|
87
|
+
number: number;
|
|
88
|
+
headSha?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface SubscriptionCoverage {
|
|
91
|
+
owner: string;
|
|
92
|
+
repo: string;
|
|
93
|
+
number: number;
|
|
94
|
+
covered: boolean;
|
|
95
|
+
reason?: GitHubCoverage;
|
|
96
|
+
repoId?: number;
|
|
97
|
+
}
|
|
98
|
+
export type SubscriptionAnswer = {
|
|
99
|
+
enabled: false;
|
|
100
|
+
} | {
|
|
101
|
+
enabled: true;
|
|
102
|
+
coverage: SubscriptionCoverage[];
|
|
103
|
+
renewBy?: string;
|
|
104
|
+
};
|
|
105
|
+
export type EventsAnswer = {
|
|
106
|
+
enabled: false;
|
|
107
|
+
} | {
|
|
108
|
+
enabled: true;
|
|
109
|
+
events: GitHubNotice[];
|
|
110
|
+
cursor?: string;
|
|
111
|
+
more: boolean;
|
|
112
|
+
reset: boolean;
|
|
113
|
+
};
|
|
114
|
+
export type GitHubAppFailure =
|
|
115
|
+
/** No Andorra sign-in on this installation. */
|
|
116
|
+
'signed-out'
|
|
117
|
+
/** The service refused the token, and a fresh read of the sign-in did not change that. */
|
|
118
|
+
| 'unauthorized'
|
|
119
|
+
/** `403 not_allowed`: the account is outside the App's allowed group. */
|
|
120
|
+
| 'not-allowed' | 'forbidden' | 'rate-limited' | 'not-found' | 'invalid-request'
|
|
121
|
+
/** The service could not be reached, did not answer in time, or failed (5xx). */
|
|
122
|
+
| 'unavailable'
|
|
123
|
+
/** The service answered something this client does not understand. */
|
|
124
|
+
| 'invalid-answer';
|
|
125
|
+
export declare class GitHubAppError extends Error {
|
|
126
|
+
readonly code: GitHubAppFailure;
|
|
127
|
+
readonly retryAfterMs?: number | undefined;
|
|
128
|
+
constructor(code: GitHubAppFailure, message: string, retryAfterMs?: number | undefined);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The writes the service makes as the App's bot (`POST /v1/github/writes`). `react` is the 👀 on a comment that
|
|
132
|
+
* mentioned the bot (phase 3): the engine asks for it, never the agent.
|
|
133
|
+
*/
|
|
134
|
+
export type BotWriteAction = 'reply' | 'resolve' | 'unresolve' | 'comment' | 'react';
|
|
135
|
+
export interface BotWriteRequest {
|
|
136
|
+
/** A ULID made for this write, sent again unchanged on every retry, so the service replays rather than posts twice. */
|
|
137
|
+
requestId: string;
|
|
138
|
+
owner: string;
|
|
139
|
+
repo: string;
|
|
140
|
+
number: number;
|
|
141
|
+
action: BotWriteAction;
|
|
142
|
+
threadId?: string;
|
|
143
|
+
body?: string;
|
|
144
|
+
/** `react` only: the comment's node id, from the `request` notice. */
|
|
145
|
+
commentId?: string;
|
|
146
|
+
}
|
|
147
|
+
/** Why the service wrote nothing, so the write may go through gh as the person instead. */
|
|
148
|
+
export type BotWriteFallback =
|
|
149
|
+
/** No Andorra sign-in to send. */
|
|
150
|
+
'signed-out'
|
|
151
|
+
/** The token was refused, and a fresh read of the sign-in did not change that. */
|
|
152
|
+
| 'unauthorized'
|
|
153
|
+
/** `200 {"enabled": false}`: the App is off on the service. */
|
|
154
|
+
| 'disabled'
|
|
155
|
+
/** `403 not_allowed`: the account is outside the App's allowed group. */
|
|
156
|
+
| 'not-allowed'
|
|
157
|
+
/** `403 not_covered`: the bot may not write on this PR. */
|
|
158
|
+
| 'not-covered'
|
|
159
|
+
/** Any other 403 (`account_unavailable`): refused before anything was looked at. */
|
|
160
|
+
| 'forbidden'
|
|
161
|
+
/** `429`, the service's or API Gateway's own. */
|
|
162
|
+
| 'rate-limited'
|
|
163
|
+
/** `503 late`: the service did not start the write in time. */
|
|
164
|
+
| 'late'
|
|
165
|
+
/** `502 github` that GitHub refused (`written: false`, or GitHub's status 403, 404 or 422). */
|
|
166
|
+
| 'github-refused'
|
|
167
|
+
/** Not reachable before anything was sent (refused connection, DNS), or `written: false` with the service failing. */
|
|
168
|
+
| 'unavailable'
|
|
169
|
+
/** An account API without the writes route (API Gateway's own 404). */
|
|
170
|
+
| 'no-route';
|
|
171
|
+
export type BotWriteOutcome = {
|
|
172
|
+
kind: 'written';
|
|
173
|
+
as: string;
|
|
174
|
+
url?: string;
|
|
175
|
+
} | {
|
|
176
|
+
kind: 'not-written';
|
|
177
|
+
reason: BotWriteFallback;
|
|
178
|
+
}
|
|
179
|
+
/** The request itself was wrong (`400`, naming the field) or the thread is not on this PR (`404 not_found`): no fallback. */
|
|
180
|
+
| {
|
|
181
|
+
kind: 'refused';
|
|
182
|
+
reason: 'bad-request';
|
|
183
|
+
field?: string;
|
|
184
|
+
} | {
|
|
185
|
+
kind: 'refused';
|
|
186
|
+
reason: 'not-found';
|
|
187
|
+
}
|
|
188
|
+
/** It may have been written: never repeated through gh. */
|
|
189
|
+
| {
|
|
190
|
+
kind: 'unknown';
|
|
191
|
+
detail: string;
|
|
192
|
+
};
|
|
193
|
+
/** One inline comment of a review, in the service's shape (design/specs/andorra-review-loop.md, "The review write"). */
|
|
194
|
+
export interface ReviewWriteComment {
|
|
195
|
+
path: string;
|
|
196
|
+
line: number;
|
|
197
|
+
side: 'LEFT' | 'RIGHT';
|
|
198
|
+
startLine?: number;
|
|
199
|
+
startSide?: 'LEFT' | 'RIGHT';
|
|
200
|
+
body: string;
|
|
201
|
+
}
|
|
202
|
+
/** `review-check`: the checks a review would get, before any model runs. Its `requestId` is never one a `review` uses. */
|
|
203
|
+
export interface ReviewCheckRequest {
|
|
204
|
+
requestId: string;
|
|
205
|
+
owner: string;
|
|
206
|
+
repo: string;
|
|
207
|
+
number: number;
|
|
208
|
+
}
|
|
209
|
+
/** `review`: one comment-only review as the App's bot. The service writes the header and the marker, and fixes the event. */
|
|
210
|
+
export interface ReviewWriteRequest extends ReviewCheckRequest {
|
|
211
|
+
commitId: string;
|
|
212
|
+
loop: string;
|
|
213
|
+
round: number;
|
|
214
|
+
rounds: number;
|
|
215
|
+
body: string;
|
|
216
|
+
comments: ReviewWriteComment[];
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* What one answer to `review` or `review-check` means (the spec's "Answers, and what the engine does with each").
|
|
220
|
+
* The client asks once; the loop decides what to retry and with which `requestId`.
|
|
221
|
+
*/
|
|
222
|
+
export type ReviewAnswer =
|
|
223
|
+
/** `review-check` passed. */
|
|
224
|
+
{
|
|
225
|
+
kind: 'ok';
|
|
226
|
+
}
|
|
227
|
+
/** Posted: only an answer that names the review's node id counts. */
|
|
228
|
+
| {
|
|
229
|
+
kind: 'posted';
|
|
230
|
+
reviewId: string;
|
|
231
|
+
as: string;
|
|
232
|
+
url?: string;
|
|
233
|
+
comments?: number;
|
|
234
|
+
} | {
|
|
235
|
+
kind: 'stale-head';
|
|
236
|
+
head?: string;
|
|
237
|
+
} | {
|
|
238
|
+
kind: 'closed';
|
|
239
|
+
merged: boolean;
|
|
240
|
+
} | {
|
|
241
|
+
kind: 'loop-taken';
|
|
242
|
+
}
|
|
243
|
+
/** GitHub refused the review and nothing was posted: 422 (a line outside the diff), or 403/404 (locked, gone, withdrawn). */
|
|
244
|
+
| {
|
|
245
|
+
kind: 'github-refused';
|
|
246
|
+
status: number;
|
|
247
|
+
}
|
|
248
|
+
/** The service's own limit (`429 rate_limited`), with its wait. */
|
|
249
|
+
| {
|
|
250
|
+
kind: 'rate-limited';
|
|
251
|
+
retryAfterMs?: number;
|
|
252
|
+
}
|
|
253
|
+
/** Nothing posted: `503 late`, `503 unavailable`, a GitHub 5xx or 401 with `written: false`, API Gateway's own 429, or no connection. */
|
|
254
|
+
| {
|
|
255
|
+
kind: 'unavailable';
|
|
256
|
+
detail: string;
|
|
257
|
+
}
|
|
258
|
+
/** An earlier attempt with this `requestId` is still running. */
|
|
259
|
+
| {
|
|
260
|
+
kind: 'in-progress';
|
|
261
|
+
}
|
|
262
|
+
/** `200 {"enabled": false}`: reviews are off on the service. */
|
|
263
|
+
| {
|
|
264
|
+
kind: 'service-off';
|
|
265
|
+
}
|
|
266
|
+
/** `403 not_covered`, `not_allowed` or any other refusal before GitHub: the bot may not post here. */
|
|
267
|
+
| {
|
|
268
|
+
kind: 'not-covered';
|
|
269
|
+
error: string;
|
|
270
|
+
} | {
|
|
271
|
+
kind: 'plan';
|
|
272
|
+
} | {
|
|
273
|
+
kind: 'signed-out';
|
|
274
|
+
} | {
|
|
275
|
+
kind: 'bad-request';
|
|
276
|
+
field?: string;
|
|
277
|
+
} | {
|
|
278
|
+
kind: 'not-found';
|
|
279
|
+
}
|
|
280
|
+
/** It may have posted. */
|
|
281
|
+
| {
|
|
282
|
+
kind: 'unknown';
|
|
283
|
+
detail: string;
|
|
284
|
+
};
|
|
285
|
+
export interface GitHubAppClient {
|
|
286
|
+
status(signal?: AbortSignal): Promise<GitHubAppStatus>;
|
|
287
|
+
connect(mode: 'install' | 'authorize', signal?: AbortSignal): Promise<{
|
|
288
|
+
enabled: false;
|
|
289
|
+
} | {
|
|
290
|
+
enabled: true;
|
|
291
|
+
url: string;
|
|
292
|
+
}>;
|
|
293
|
+
disconnect(signal?: AbortSignal): Promise<{
|
|
294
|
+
enabled: boolean;
|
|
295
|
+
}>;
|
|
296
|
+
/** The repositories a Cloud machine may clone for this account. */
|
|
297
|
+
repositories(signal?: AbortSignal): Promise<GitHubRepositoriesAnswer>;
|
|
298
|
+
subscribe(engine: string, pullRequests: SubscriptionRequest[], signal?: AbortSignal): Promise<SubscriptionAnswer>;
|
|
299
|
+
events(engine: string, after: string | undefined, signal?: AbortSignal): Promise<EventsAnswer>;
|
|
300
|
+
/**
|
|
301
|
+
* Asks the service to make one write as the App's bot. Never throws for an answer: it says whether the
|
|
302
|
+
* write was made, certainly not made (the caller may fall back to gh), refused, or of unknown fate. Only a
|
|
303
|
+
* cancelled `signal` throws. The answer is read for `ok`, `as`, `url`, `enabled`, `error`, `field`, `status`
|
|
304
|
+
* and `written` alone: no installation token is ever asked for, read or kept.
|
|
305
|
+
*/
|
|
306
|
+
write(request: BotWriteRequest, signal?: AbortSignal): Promise<BotWriteOutcome>;
|
|
307
|
+
/** One `review-check` request. Never throws for an answer; only a cancelled `signal` throws. */
|
|
308
|
+
reviewCheck(request: ReviewCheckRequest, signal?: AbortSignal): Promise<ReviewAnswer>;
|
|
309
|
+
/** One `review` request, asked once with its `requestId`. Never throws for an answer; only a cancelled `signal` throws. */
|
|
310
|
+
review(request: ReviewWriteRequest, signal?: AbortSignal): Promise<ReviewAnswer>;
|
|
311
|
+
}
|
|
312
|
+
export interface GitHubAppClientDependencies {
|
|
313
|
+
accessToken(signal?: AbortSignal): Promise<string | undefined>;
|
|
314
|
+
apiBaseUrl(): string;
|
|
315
|
+
fetch: typeof globalThis.fetch;
|
|
316
|
+
/** Loopback `http:` is allowed only for the test-mode override below; everything else must be `https:`. */
|
|
317
|
+
allowLoopbackHttp?: boolean;
|
|
318
|
+
/** How long a bot write may wait for its answer, retries included (tests shorten it). */
|
|
319
|
+
writeBudgetMs?: number;
|
|
320
|
+
/** The pause between a bot write's attempts (tests skip it). */
|
|
321
|
+
sleep?(ms: number, signal?: AbortSignal): Promise<void>;
|
|
322
|
+
}
|
|
323
|
+
/** A bot write with no answer in this long is of unknown fate (the service's Lambda stops at 20 seconds). */
|
|
324
|
+
export declare const WRITE_BUDGET_MS = 25000;
|
|
325
|
+
/** At most this many requests for one write, all with its one `requestId`; a 401's refreshed token is one more. */
|
|
326
|
+
export declare const WRITE_ATTEMPTS = 3;
|
|
327
|
+
/**
|
|
328
|
+
* The kind of comment a node id names, as the service reads it (`comment_kind` in `github_app.py`): the current
|
|
329
|
+
* form by its prefix (`IC_`, `PRRC_`, `PRR_`), or a legacy id, base64 of `<length>:<Type><number>`. Undefined
|
|
330
|
+
* for any other node, or anything else.
|
|
331
|
+
*/
|
|
332
|
+
export declare function commentKindOf(id: unknown): MentionCommentKind | undefined;
|
|
333
|
+
/** Any comment a `react` may name: a node id of one of the three kinds. */
|
|
334
|
+
export declare const isMentionCommentId: (value: unknown) => value is string;
|
|
335
|
+
export declare const isEngineId: (value: unknown) => value is string;
|
|
336
|
+
export declare const isCursor: (value: unknown) => value is string;
|
|
337
|
+
/**
|
|
338
|
+
* Where the account API is, and which token to send. Production always uses the stamped API and the
|
|
339
|
+
* signed-in account's token. Only with `ANDORRA_TEST_MODE=1`, and only with both `ANDORRA_TEST_ACCOUNT_API`
|
|
340
|
+
* (a staging stack over `https:`, or a fake on a loopback `http:` origin) and `ANDORRA_TEST_ACCOUNT_TOKEN`,
|
|
341
|
+
* do the GitHub App routes go elsewhere, and then always with the test token: the signed-in account's token
|
|
342
|
+
* is never sent anywhere but the production API, and a test token never to it. Either variable alone is
|
|
343
|
+
* ignored.
|
|
344
|
+
*/
|
|
345
|
+
export declare function accountApiTarget(env?: NodeJS.ProcessEnv): {
|
|
346
|
+
baseUrl: string;
|
|
347
|
+
token?: string;
|
|
348
|
+
loopback: boolean;
|
|
349
|
+
};
|
|
350
|
+
export declare function parseNotice(value: unknown): GitHubNotice | undefined;
|
|
351
|
+
/** A notice `parseNotice` read as a `request`, with every field it requires. */
|
|
352
|
+
export declare const isMentionNotice: (notice: GitHubNotice) => notice is MentionNotice;
|
|
353
|
+
/** The most repositories one list answer is read for (the service sends at most this many). */
|
|
354
|
+
export declare const MAX_REPOSITORIES = 1000;
|
|
355
|
+
/** The service's own limit on a bot write's body. */
|
|
356
|
+
export declare const BOT_BODY_BYTES = 16384;
|
|
357
|
+
/** The first field of a bot write the service would refuse (`400 bad_request`), checked as it checks them; undefined when none. */
|
|
358
|
+
export declare function botWriteProblem(request: BotWriteRequest): string | undefined;
|
|
359
|
+
export declare function failedBeforeSending(error: unknown): boolean;
|
|
360
|
+
/** The opening of the review marker that only the service writes; it is refused in every body (R1). */
|
|
361
|
+
export declare const REVIEW_MARKER_OPENING: RegExp;
|
|
362
|
+
/** The first field of a `review-check` or `review` the service would refuse (`400 bad_request`), checked as it checks them. */
|
|
363
|
+
export declare function reviewWriteProblem(request: ReviewCheckRequest | ReviewWriteRequest, action: 'review-check' | 'review'): string | undefined;
|
|
364
|
+
/** What one answer of `POST /v1/github/writes` means for `review` and `review-check`. */
|
|
365
|
+
export declare function reviewVerdict(action: 'review-check' | 'review', status: number, answer: Record<string, unknown> | undefined, retryAfter?: number): ReviewAnswer;
|
|
366
|
+
export declare function createGitHubAppClient(deps: GitHubAppClientDependencies): GitHubAppClient;
|
|
367
|
+
/** The shipped client: the stamped account API and the signed-in account, or the test-mode override (see accountApiTarget). */
|
|
368
|
+
export declare function defaultGitHubAppClient(env?: NodeJS.ProcessEnv): GitHubAppClient;
|