@andorra-labs/code 0.1.18 → 0.1.19
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/account-jev-savings.d.ts +4 -0
- package/dist/src/account-jev-savings.js +92 -0
- package/dist/src/acp-agent.js +2 -2
- package/dist/src/agent-execution.js +347 -45
- package/dist/src/agent-mcp.js +7 -1
- package/dist/src/agent-modifiers.js +5 -7
- package/dist/src/analytics.d.ts +19 -1
- package/dist/src/analytics.js +9 -1
- package/dist/src/andorra/entry.js +15 -6
- package/dist/src/andorra/hosted.d.ts +8 -0
- package/dist/src/andorra/hosted.js +22 -3
- package/dist/src/andorra/streams.d.ts +49 -0
- package/dist/src/andorra/streams.js +98 -0
- package/dist/src/antigravity-acp.d.ts +28 -0
- package/dist/src/antigravity-acp.js +150 -0
- package/dist/src/antigravity-terminal.d.ts +2 -0
- package/dist/src/antigravity-terminal.js +214 -0
- package/dist/src/app-server/adaptive-routing-settings.d.ts +37 -0
- package/dist/src/app-server/adaptive-routing-settings.js +69 -0
- package/dist/src/app-server/artifact.d.ts +14 -0
- package/dist/src/app-server/artifact.js +46 -0
- package/dist/src/app-server/legal-protocol.d.ts +33 -0
- package/dist/src/app-server/legal-protocol.js +16 -0
- package/dist/src/app-server/protocol.d.ts +23 -3
- package/dist/src/app-server/protocol.js +3 -1
- package/dist/src/app-server/telemetry-protocol.d.ts +53 -0
- package/dist/src/app-server/telemetry-protocol.js +2 -0
- package/dist/src/app-server/telemetry.d.ts +38 -0
- package/dist/src/app-server/telemetry.js +163 -0
- package/dist/src/app-server/workspace.d.ts +3 -1
- package/dist/src/app-server/workspace.js +39 -8
- package/dist/src/app-server.d.ts +50 -25
- package/dist/src/app-server.js +1008 -400
- package/dist/src/auth/AuthManager.d.ts +11 -2
- package/dist/src/auth/AuthManager.js +56 -13
- package/dist/src/auth/index.d.ts +5 -1
- package/dist/src/auth/index.js +8 -1
- package/dist/src/auth/lifecycle.d.ts +13 -0
- package/dist/src/auth/lifecycle.js +109 -0
- package/dist/src/auth/store.d.ts +1 -0
- package/dist/src/auth/store.js +12 -0
- package/dist/src/auth/types.d.ts +12 -0
- package/dist/src/automation-runner.js +2 -0
- package/dist/src/automation-service.js +7 -2
- package/dist/src/benchmark-scores.d.ts +88 -0
- package/dist/src/benchmark-scores.js +302 -0
- package/dist/src/bridge/command.js +4 -1
- package/dist/src/bridge/control.js +2 -1
- package/dist/src/bridge/engines.d.ts +2 -0
- package/dist/src/bridge/engines.js +9 -0
- package/dist/src/bridge/host-ops.d.ts +2 -2
- package/dist/src/bridge/host-ops.js +4 -2
- package/dist/src/bridge/host.d.ts +2 -0
- package/dist/src/bridge/host.js +63 -12
- package/dist/src/bridge/protocol.d.ts +1 -0
- package/dist/src/bridge/protocol.js +1 -0
- package/dist/src/browser-panel-tool.d.ts +12 -0
- package/dist/src/browser-panel-tool.js +30 -3
- package/dist/src/browser-runner.js +53 -62
- package/dist/src/browser-server.js +10 -4
- package/dist/src/browser-session.d.ts +14 -0
- package/dist/src/browser-session.js +57 -12
- package/dist/src/browser-view.d.ts +40 -1
- package/dist/src/browser-view.js +163 -9
- package/dist/src/browser-window-style.d.ts +27 -0
- package/dist/src/browser-window-style.js +244 -0
- package/dist/src/claude-provider.d.ts +1 -0
- package/dist/src/claude-provider.js +77 -36
- package/dist/src/cli.js +235 -58
- package/dist/src/codex-provider.d.ts +1 -0
- package/dist/src/codex-provider.js +43 -7
- package/dist/src/coding-tools.d.ts +1 -0
- package/dist/src/coding-tools.js +19 -5
- package/dist/src/command-screens.d.ts +1 -1
- package/dist/src/command-screens.js +2 -2
- package/dist/src/commands.d.ts +8 -1
- package/dist/src/commands.js +67 -63
- package/dist/src/completion.js +5 -3
- package/dist/src/config.d.ts +14 -3
- package/dist/src/config.js +54 -16
- package/dist/src/context-budget.d.ts +11 -2
- package/dist/src/context-budget.js +23 -2
- package/dist/src/context-compaction.d.ts +10 -8
- package/dist/src/context-compaction.js +23 -24
- package/dist/src/deadline.js +1 -1
- package/dist/src/decision/DecisionManager.d.ts +5 -0
- package/dist/src/decision/DecisionManager.js +39 -2
- package/dist/src/decision/applyToolMenu.js +6 -2
- package/dist/src/decision/hostedPolicy.js +6 -4
- package/dist/src/decision/optimizationPolicy.d.ts +10 -0
- package/dist/src/decision/optimizationPolicy.js +23 -3
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +2 -1
- package/dist/src/decision/providers/AndorraDecisionProvider.js +17 -7
- package/dist/src/decision/providers/index.js +1 -1
- package/dist/src/decision/toolFamilies.js +1 -1
- package/dist/src/decision/types.d.ts +2 -0
- package/dist/src/efficiency.d.ts +75 -1
- package/dist/src/efficiency.js +114 -3
- package/dist/src/extensions.d.ts +2 -0
- package/dist/src/extensions.js +30 -20
- package/dist/src/github-app/agent-writes.d.ts +1 -1
- package/dist/src/github-app/agent-writes.js +1 -1
- package/dist/src/github-app/event-source.d.ts +0 -5
- package/dist/src/github-app/event-source.js +1 -31
- package/dist/src/github-app/metrics.d.ts +2 -5
- package/dist/src/github-app/metrics.js +2 -14
- package/dist/src/github-app/review-loop.d.ts +5 -5
- package/dist/src/github-app/review-loop.js +1 -1
- package/dist/src/github-app/review-node.d.ts +2 -2
- package/dist/src/github-app/triggers.d.ts +3 -3
- package/dist/src/glob-search.d.ts +1 -0
- package/dist/src/glob-search.js +3 -0
- package/dist/src/google-provider.d.ts +5 -28
- package/dist/src/google-provider.js +6 -141
- package/dist/src/graph-editor-session.d.ts +1 -0
- package/dist/src/graph-editor-session.js +2 -0
- package/dist/src/graph-health.js +3 -1
- package/dist/src/graph-runner.js +19 -13
- package/dist/src/graph-selection.d.ts +3 -1
- package/dist/src/graph-selection.js +2 -2
- package/dist/src/graph-server.d.ts +8 -1
- package/dist/src/graph-server.js +45 -10
- package/dist/src/graph-sync.d.ts +2 -1
- package/dist/src/graph-sync.js +13 -0
- package/dist/src/graph-ui/app.js +19 -8
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graphs.d.ts +17 -1
- package/dist/src/graphs.js +51 -5
- package/dist/src/grok-provider.js +17 -14
- package/dist/src/hardened-runtime.js +7 -4
- package/dist/src/jev-savings.d.ts +4 -0
- package/dist/src/jev-savings.js +13 -0
- package/dist/src/legal/client.d.ts +25 -0
- package/dist/src/legal/client.js +47 -0
- package/dist/src/legal/command.d.ts +13 -0
- package/dist/src/legal/command.js +98 -0
- package/dist/src/legal/documents.d.ts +2 -0
- package/dist/src/legal/documents.js +14 -0
- package/dist/src/legal/gate.d.ts +13 -0
- package/dist/src/legal/gate.js +96 -0
- package/dist/src/legal/manifest.d.ts +21 -0
- package/dist/src/legal/manifest.js +23 -0
- package/dist/src/legal/receipt.d.ts +13 -0
- package/dist/src/legal/receipt.js +137 -0
- package/dist/src/legal/release.d.ts +27 -0
- package/dist/src/legal/release.js +28 -0
- package/dist/src/managed-sign-in.d.ts +0 -1
- package/dist/src/managed-sign-in.js +0 -13
- package/dist/src/membership.d.ts +27 -1
- package/dist/src/membership.js +139 -7
- package/dist/src/model-metadata.js +3 -7
- package/dist/src/model-pool.d.ts +99 -0
- package/dist/src/model-pool.js +136 -0
- package/dist/src/model-relay/local.js +5 -0
- package/dist/src/model-relay/remote.d.ts +2 -0
- package/dist/src/model-relay/remote.js +4 -0
- package/dist/src/model-tiers.d.ts +13 -1
- package/dist/src/model-tiers.js +28 -4
- package/dist/src/opencode-cli-provider.js +59 -56
- package/dist/src/opencode-provider.js +16 -13
- package/dist/src/permissions.d.ts +5 -0
- package/dist/src/permissions.js +7 -0
- package/dist/src/plan-pass.js +2 -1
- package/dist/src/pool-scores.d.ts +45 -0
- package/dist/src/pool-scores.js +40 -0
- package/dist/src/provider-connection.js +3 -17
- package/dist/src/provider-engine.js +42 -12
- package/dist/src/provider-request-error.d.ts +8 -0
- package/dist/src/provider-request-error.js +12 -0
- package/dist/src/provider-settings.d.ts +1 -1
- package/dist/src/provider-settings.js +36 -18
- package/dist/src/provider-turn-deadline.d.ts +39 -0
- package/dist/src/provider-turn-deadline.js +139 -0
- package/dist/src/providers.d.ts +3 -9
- package/dist/src/providers.js +181 -146
- package/dist/src/pull-request-merge.d.ts +1 -8
- package/dist/src/pull-request-merge.js +0 -4
- package/dist/src/pull-requests.d.ts +82 -66
- package/dist/src/pull-requests.js +266 -276
- package/dist/src/qa/runtime/ProcessManager.d.ts +5 -1
- package/dist/src/qa/runtime/ProcessManager.js +9 -3
- package/dist/src/react-runtime.js +147 -56
- package/dist/src/reasoning-probe-cloud.d.ts +10 -0
- package/dist/src/reasoning-probe-cloud.js +209 -0
- package/dist/src/remote/engine-pool.d.ts +3 -0
- package/dist/src/remote/engine-pool.js +85 -18
- package/dist/src/remote/recovery.d.ts +6 -0
- package/dist/src/remote/recovery.js +37 -0
- package/dist/src/run-records.d.ts +13 -3
- package/dist/src/run-records.js +59 -34
- package/dist/src/runtime.d.ts +18 -1
- package/dist/src/runtime.js +25 -7
- package/dist/src/session-summary.d.ts +8 -0
- package/dist/src/session-summary.js +34 -0
- package/dist/src/sessions.d.ts +8 -0
- package/dist/src/sessions.js +12 -3
- package/dist/src/shell.js +6 -0
- package/dist/src/side-panel.js +36 -2
- package/dist/src/sign-in-detection.d.ts +1 -1
- package/dist/src/sign-in-detection.js +4 -10
- package/dist/src/sign-in-offer.js +1 -1
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +2 -2
- package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
- package/dist/src/skills/bundled/provenance.json +2 -2
- package/dist/src/subagent-run.js +50 -50
- package/dist/src/subscription-usage.d.ts +50 -0
- package/dist/src/subscription-usage.js +92 -0
- package/dist/src/task-checkout.d.ts +20 -4
- package/dist/src/task-checkout.js +78 -8
- package/dist/src/telemetry/access.d.ts +18 -0
- package/dist/src/telemetry/access.js +43 -0
- package/dist/src/telemetry/aggregate.d.ts +18 -2
- package/dist/src/telemetry/aggregate.js +22 -9
- package/dist/src/telemetry/capture-core.d.ts +33 -14
- package/dist/src/telemetry/capture-core.js +124 -25
- package/dist/src/telemetry/capture.d.ts +3 -2
- package/dist/src/telemetry/capture.js +21 -1
- package/dist/src/telemetry/decision-capture.js +4 -0
- package/dist/src/telemetry/emitter.d.ts +6 -7
- package/dist/src/telemetry/emitter.js +124 -29
- package/dist/src/telemetry/gate.d.ts +41 -2
- package/dist/src/telemetry/gate.js +89 -4
- package/dist/src/telemetry/home.d.ts +1 -0
- package/dist/src/telemetry/home.js +20 -0
- package/dist/src/telemetry/identity.d.ts +6 -3
- package/dist/src/telemetry/identity.js +19 -6
- package/dist/src/telemetry/lifecycle.d.ts +8 -0
- package/dist/src/telemetry/lifecycle.js +76 -0
- package/dist/src/telemetry/outbox.d.ts +13 -8
- package/dist/src/telemetry/outbox.js +68 -12
- package/dist/src/telemetry/permission-command.d.ts +38 -0
- package/dist/src/telemetry/permission-command.js +208 -0
- package/dist/src/telemetry/permission.d.ts +168 -0
- package/dist/src/telemetry/permission.js +662 -0
- package/dist/src/telemetry/record-installation.d.ts +1 -0
- package/dist/src/telemetry/record-installation.js +9 -0
- package/dist/src/telemetry/region-data.d.ts +12 -0
- package/dist/src/telemetry/region-data.js +1314 -0
- package/dist/src/telemetry/region.d.ts +34 -0
- package/dist/src/telemetry/region.js +87 -0
- package/dist/src/telemetry/run-privacy.d.ts +11 -0
- package/dist/src/telemetry/run-privacy.js +165 -0
- package/dist/src/telemetry/schema.d.ts +27 -6
- package/dist/src/telemetry/schema.js +109 -14
- package/dist/src/telemetry/state.d.ts +11 -7
- package/dist/src/telemetry/state.js +39 -6
- package/dist/src/telemetry/surface.d.ts +20 -3
- package/dist/src/telemetry/surface.js +71 -15
- package/dist/src/telemetry/uploader.d.ts +6 -11
- package/dist/src/telemetry/uploader.js +72 -46
- package/dist/src/telemetry/uploads.d.ts +5 -1
- package/dist/src/telemetry/uploads.js +25 -6
- package/dist/src/telemetry/version.d.ts +5 -0
- package/dist/src/telemetry/version.js +34 -0
- package/dist/src/telemetry/workspace.d.ts +4 -1
- package/dist/src/telemetry/workspace.js +18 -3
- package/dist/src/terminal-ui.d.ts +3 -0
- package/dist/src/terminal-ui.js +48 -6
- package/dist/src/thinking-level-detect.d.ts +3 -1
- package/dist/src/thinking-level-detect.js +8 -3
- package/dist/src/thinking-levels.d.ts +1 -1
- package/dist/src/thinking-levels.js +11 -4
- package/dist/src/timers.d.ts +2 -0
- package/dist/src/todos.d.ts +2 -1
- package/dist/src/todos.js +24 -4
- package/dist/src/tool-argument-coercion.d.ts +7 -0
- package/dist/src/tool-argument-coercion.js +49 -0
- package/dist/src/tool-catalog.d.ts +2 -2
- package/dist/src/tools.js +67 -22
- package/dist/src/transcript.js +2 -1
- package/dist/src/types.d.ts +14 -1
- package/dist/src/update.js +4 -0
- package/dist/src/usage-analytics.d.ts +7 -0
- package/dist/src/usage-analytics.js +85 -13
- package/dist/telemetry-consent-v1 +1 -0
- package/package.json +97 -96
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ReviewCommentWrites, type GhRunner, type ReviewLoopSettings, type ReviewLoopState, type SessionPullRequest } from '../pull-requests.js';
|
|
2
2
|
import type { GitHubAppClient, GitHubCoverage } from './client.js';
|
|
3
3
|
import { type ReviewLoopEnd } from './review-post.js';
|
|
4
4
|
import { prepareReviewWorkspace, runReviewer } from './reviewer.js';
|
|
@@ -56,8 +56,8 @@ export interface ReviewLoopDependencies {
|
|
|
56
56
|
provider: string;
|
|
57
57
|
model: string;
|
|
58
58
|
} | undefined>;
|
|
59
|
-
/** Who the fixer's replies post as, for the wake's account clause (the
|
|
60
|
-
writes(sessionId: string): Promise<
|
|
59
|
+
/** Who the fixer's replies post as, for the wake's account clause (the PR writing tool?s rule). */
|
|
60
|
+
writes(sessionId: string): Promise<ReviewCommentWrites>;
|
|
61
61
|
/**
|
|
62
62
|
* Hands the fixer its wake: into a run of the session waiting in await_review in this process (`heldBy` is that
|
|
63
63
|
* run), or as a wake the timers deliver as the next turn.
|
|
@@ -128,7 +128,7 @@ export declare function reviewFixPrompt(pullRequest: SessionPullRequest, input:
|
|
|
128
128
|
reviewUrl: string;
|
|
129
129
|
inline: number;
|
|
130
130
|
summary: number;
|
|
131
|
-
writes:
|
|
131
|
+
writes: ReviewCommentWrites;
|
|
132
132
|
form?: 'chat' | 'graph';
|
|
133
133
|
}): string;
|
|
134
134
|
/**
|
|
@@ -218,7 +218,7 @@ export declare class ReviewLoopController {
|
|
|
218
218
|
* removed, and the transcript row. Also for a loop whose record went (a dismissed PR, a deleted session).
|
|
219
219
|
*/
|
|
220
220
|
ended(sessionId: string, before: ReviewLoopState, reason: ReviewLoopEnd, detail?: string): void;
|
|
221
|
-
/** At delivery: whether the fixer's wake is still wanted. The PR is read on GitHub
|
|
221
|
+
/** At delivery: whether the fixer's wake is still wanted. The PR is read on GitHub. */
|
|
222
222
|
confirmWake(sessionId: string, wakeId: string): Promise<boolean>;
|
|
223
223
|
/** The fixer's wake started (or continued) a run: that run's end, or its wait in await_review, ends the round. */
|
|
224
224
|
wakeDelivered(sessionId: string, wakeId: string, runId: string): Promise<void>;
|
|
@@ -663,7 +663,7 @@ export class ReviewLoopController {
|
|
|
663
663
|
void removePostRecord(this.deps.home, sessionId);
|
|
664
664
|
this.deps.emitLoop({ sessionId, kind: 'ended', round: before.round, rounds: before.rounds, reason, ...(detail === undefined ? {} : { detail }) });
|
|
665
665
|
}
|
|
666
|
-
/** At delivery: whether the fixer's wake is still wanted. The PR is read on GitHub
|
|
666
|
+
/** At delivery: whether the fixer's wake is still wanted. The PR is read on GitHub. */
|
|
667
667
|
async confirmWake(sessionId, wakeId) {
|
|
668
668
|
const wanted = (pullRequest) => pullRequest !== undefined && chatReviewLoopActive(pullRequest)
|
|
669
669
|
&& pullRequest.review.phase === 'fixing' && pullRequest.review.pendingReview?.wakeId === wakeId && pullRequest.review.pendingReview.runId === undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReviewNodeSettings } from '../graphs.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ReviewCommentWrites, type SessionPullRequest } from '../pull-requests.js';
|
|
3
3
|
import type { GitHubCoverage } from './client.js';
|
|
4
4
|
import { type ReviewLoopController } from './review-loop.js';
|
|
5
5
|
/**
|
|
@@ -66,7 +66,7 @@ export interface ReviewNodeDependencies {
|
|
|
66
66
|
readNow(): Promise<void>;
|
|
67
67
|
/** The PR's head on GitHub now, or undefined when it cannot be read. */
|
|
68
68
|
head(pullRequest: SessionPullRequest): Promise<string | undefined>;
|
|
69
|
-
writes(): Promise<
|
|
69
|
+
writes(): Promise<ReviewCommentWrites>;
|
|
70
70
|
/** The ids of the person's messages to the task not yet delivered: one that comes while a draft waits ends the wait. */
|
|
71
71
|
steers?(): string[];
|
|
72
72
|
bot?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ReviewCommentWrites, type GhRunner, type SessionPullRequest } from '../pull-requests.js';
|
|
2
2
|
import type { GitHubAppClient, MentionNotice } from './client.js';
|
|
3
3
|
/**
|
|
4
4
|
* "@andorra-code" comment triggers (`design/specs/github-app.md`, "Phase 3"). The receiver writes a `request`
|
|
@@ -36,7 +36,7 @@ export declare const RETRY_DELAYS_MS: readonly number[];
|
|
|
36
36
|
* to stop if the comment is not theirs alone, and who the agent's answer posts as. The comment's text never
|
|
37
37
|
* enters it.
|
|
38
38
|
*/
|
|
39
|
-
export declare function mentionPrompt(notice: Pick<MentionNotice, 'actor' | 'commentUrl' | 'commentKind' | 'commentId'>, pullRequest: Pick<SessionPullRequest, 'url' | 'ghUser'>, writes:
|
|
39
|
+
export declare function mentionPrompt(notice: Pick<MentionNotice, 'actor' | 'commentUrl' | 'commentKind' | 'commentId'>, pullRequest: Pick<SessionPullRequest, 'url' | 'ghUser'>, writes: ReviewCommentWrites): string;
|
|
40
40
|
/** A definite no: the mention wakes nothing, and (unless `remember` is false) is remembered as handled. */
|
|
41
41
|
export declare class MentionRefused extends Error {
|
|
42
42
|
readonly reason: 'not-signed-in' | 'no-access' | 'not-author' | 'edited' | 'gone';
|
|
@@ -61,7 +61,7 @@ export interface MentionTriggerOptions {
|
|
|
61
61
|
/** `github.app.triggers` is not false here. */
|
|
62
62
|
enabled(): Promise<boolean>;
|
|
63
63
|
/** Who the agent's answer posts as on this session's PR (the pull_request tool's own rule), and the bot's login. */
|
|
64
|
-
writes(sessionId: string): Promise<
|
|
64
|
+
writes(sessionId: string): Promise<ReviewCommentWrites>;
|
|
65
65
|
/** Wakes the session with the prompt, as Fix with Agent does, and answers the wake's id. */
|
|
66
66
|
wake(sessionId: string, prompt: string, pullRequest: SessionPullRequest): string;
|
|
67
67
|
log?(level: 'info' | 'warn', detail: string): void;
|
|
@@ -15,6 +15,7 @@ export interface GlobSearchInput {
|
|
|
15
15
|
walk(directory: string, budget: {
|
|
16
16
|
entries: number;
|
|
17
17
|
limit: number;
|
|
18
|
+
unreadable?: number;
|
|
18
19
|
}): AsyncIterable<string>;
|
|
19
20
|
/** Drops listed paths the agent may not see; paths are relative to cwd. */
|
|
20
21
|
keep?(relative: string[], cwd: string): string[];
|
package/dist/src/glob-search.js
CHANGED
|
@@ -114,6 +114,9 @@ async function listWithWalk(cwd, accept, input) {
|
|
|
114
114
|
throw error;
|
|
115
115
|
listing.incomplete = `stopped at the ${GLOB_WALK_ENTRY_LIMIT.toLocaleString('en-US')}-entry directory scan limit`;
|
|
116
116
|
}
|
|
117
|
+
if (budget.unreadable && !listing.incomplete) {
|
|
118
|
+
listing.incomplete = `${budget.unreadable.toLocaleString('en-US')} folder${budget.unreadable === 1 ? '' : 's'} could not be opened (permission denied) and ${budget.unreadable === 1 ? 'was' : 'were'} skipped`;
|
|
119
|
+
}
|
|
117
120
|
return listing;
|
|
118
121
|
}
|
|
119
122
|
/**
|
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { ModelAdapter
|
|
1
|
+
import type { CliExecutableSpec } from './cli-executable.js';
|
|
2
|
+
import type { ModelAdapter } from './types.js';
|
|
3
3
|
export declare const GOOGLE_BASE_URL = "https://antigravity.google";
|
|
4
|
+
export declare const GOOGLE_LEGACY_MESSAGE = "Google subscriptions now use a dedicated Antigravity ACP session. Open Antigravity in Desktop or run andorra antigravity. For Gemini in an Andorra graph, add Google with an AI Studio API key.";
|
|
4
5
|
export declare const GOOGLE_EXECUTABLE: CliExecutableSpec;
|
|
5
6
|
export declare function googleEnvironment(source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
captureStderr?: boolean;
|
|
9
|
-
acceptedExitCodes?: number[];
|
|
10
|
-
}
|
|
11
|
-
export type GoogleRun = (args: string[], signal: AbortSignal, options?: GoogleRunOptions) => Promise<{
|
|
12
|
-
stdout: string;
|
|
13
|
-
stderr: string;
|
|
14
|
-
}>;
|
|
15
|
-
export interface GoogleDependencies {
|
|
16
|
-
run?: GoogleRun;
|
|
17
|
-
}
|
|
18
|
-
export declare const runGoogleProcess: GoogleRun;
|
|
19
|
-
export declare function parseGoogleModels(output: string): {
|
|
20
|
-
signedIn: boolean;
|
|
21
|
-
models: string[];
|
|
22
|
-
};
|
|
23
|
-
export declare function readGoogleCatalog(signal: AbortSignal, dependencies?: GoogleDependencies): Promise<{
|
|
24
|
-
signedIn: boolean;
|
|
25
|
-
models: string[];
|
|
26
|
-
}>;
|
|
27
|
-
export declare function parseGoogleResponse(output: string, tools?: readonly Pick<ToolSchema, 'name'>[]): ModelResponse;
|
|
28
|
-
export declare function parseGoogleText(output: string): ModelResponse;
|
|
29
|
-
export declare function createGoogleAdapter(_config: {
|
|
30
|
-
model: string;
|
|
31
|
-
}, dependencies?: GoogleDependencies): ModelAdapter;
|
|
7
|
+
/** Keep saved provider IDs loadable so graphs can report how to migrate. */
|
|
8
|
+
export declare function createGoogleAdapter(): ModelAdapter;
|
|
@@ -1,153 +1,18 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
|
-
import { resolveCliExecutable } from './cli-executable.js';
|
|
3
|
-
import { runBoundedCli } from './cli-process.js';
|
|
4
|
-
import { allowanceInstruction, boundTextStep, parseStructuredStep, STRUCTURED_STEP_PROMPT, STRUCTURED_STEP_SCHEMA, structuredStepPrompt, TEXT_STEP_PROMPT } from './structured-step.js';
|
|
5
2
|
export const GOOGLE_BASE_URL = 'https://antigravity.google';
|
|
3
|
+
export const GOOGLE_LEGACY_MESSAGE = 'Google subscriptions now use a dedicated Antigravity ACP session. Open Antigravity in Desktop or run andorra antigravity. For Gemini in an Andorra graph, add Google with an AI Studio API key.';
|
|
6
4
|
export const GOOGLE_EXECUTABLE = {
|
|
7
5
|
names: ['agy'], overrideEnv: 'ANDORRA_AGY_PATH', homeDirectories: [join('AppData', 'Local', 'agy', 'bin'), join('.local', 'bin')],
|
|
8
|
-
installMessage: 'Install the Antigravity CLI (agy) from antigravity.google,
|
|
6
|
+
installMessage: 'Install the official Antigravity CLI (agy) from antigravity.google, then run agy acp --login.',
|
|
9
7
|
};
|
|
10
|
-
const SIGN_IN_MESSAGE = 'Sign in with Google in the Antigravity CLI (agy) on this machine, then retry the Google provider.';
|
|
11
|
-
const REQUEST_TIMEOUT_MS = 10 * 60_000;
|
|
12
|
-
const CATALOG_TIMEOUT_MS = 30_000;
|
|
13
|
-
// Strict permissions make the CLI ask before every one of its own tools, and a headless run cannot
|
|
14
|
-
// answer, so each is denied: the CLI serves as a model and Andorra runs the tools.
|
|
15
|
-
const STEP_SETTINGS = JSON.stringify({ toolPermission: 'strict', disableSlashCommands: true, allowNonWorkspaceAccess: false });
|
|
16
8
|
export function googleEnvironment(source = process.env) {
|
|
17
9
|
const env = Object.fromEntries(Object.entries(source).filter(([key]) => !/^(?:GEMINI_API_KEY$|GOOGLE_API_KEY$|GOOGLE_GENAI_|NODE_OPTIONS$)/i.test(key)));
|
|
18
10
|
return { ...env, NO_COLOR: '1' };
|
|
19
11
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return runBoundedCli(executable, () => args, signal, { env: googleEnvironment(), label: 'Antigravity CLI', ...options });
|
|
23
|
-
};
|
|
24
|
-
/** The CLI also lists models from other vendors; only Google's own are offered here. */
|
|
25
|
-
const GOOGLE_MODEL = /^gemini-[\w.-]{1,200}$/;
|
|
26
|
-
export function parseGoogleModels(output) {
|
|
27
|
-
const plain = output.replace(/\u001b\[[0-9;]*m/g, '');
|
|
28
|
-
if (/\b(?:please sign in|authentication required|not (?:authenticated|signed in|logged in))\b/i.test(plain))
|
|
29
|
-
return { signedIn: false, models: [] };
|
|
30
|
-
const models = [];
|
|
31
|
-
let listed = 0;
|
|
32
|
-
for (const line of plain.split(/\r?\n/)) {
|
|
33
|
-
const id = line.match(/^([\w.-]+)\t/)?.[1];
|
|
34
|
-
if (!id)
|
|
35
|
-
continue;
|
|
36
|
-
listed += 1;
|
|
37
|
-
if (GOOGLE_MODEL.test(id) && !models.includes(id) && models.length < 1000)
|
|
38
|
-
models.push(id);
|
|
39
|
-
}
|
|
40
|
-
return { signedIn: listed > 0, models };
|
|
41
|
-
}
|
|
42
|
-
export async function readGoogleCatalog(signal, dependencies = {}) {
|
|
43
|
-
const run = dependencies.run ?? runGoogleProcess;
|
|
44
|
-
const bounded = AbortSignal.any([signal, AbortSignal.timeout(CATALOG_TIMEOUT_MS)]);
|
|
45
|
-
const { stdout, stderr } = await run(['models'], bounded, { captureStderr: true, acceptedExitCodes: [0, 1] });
|
|
46
|
-
return parseGoogleModels(`${stdout}\n${stderr}`);
|
|
47
|
-
}
|
|
48
|
-
function frames(text) {
|
|
49
|
-
return text.split(/\r?\n/).filter(line => line.trim().startsWith('{')).map(line => {
|
|
50
|
-
try {
|
|
51
|
-
return JSON.parse(line);
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
throw new Error('Antigravity CLI returned malformed JSON');
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
function googleUsage(usage) {
|
|
59
|
-
if (!usage || typeof usage !== 'object')
|
|
60
|
-
return undefined;
|
|
61
|
-
const token = (name) => Number.isSafeInteger(usage[name]) && usage[name] >= 0 ? usage[name] : undefined;
|
|
62
|
-
const input = token('input_tokens');
|
|
63
|
-
const output = token('output_tokens');
|
|
64
|
-
const read = token('cache_read_tokens');
|
|
65
|
-
if (!input && !output && !read)
|
|
66
|
-
return { requests: 1 };
|
|
67
|
-
return { requests: 1,
|
|
68
|
-
...(input === undefined ? {} : { inputTokens: input + (read ?? 0) }),
|
|
69
|
-
...(output === undefined ? {} : { outputTokens: output }),
|
|
70
|
-
...(read === undefined ? {} : { cacheRead: read }) };
|
|
71
|
-
}
|
|
72
|
-
function failure(message) {
|
|
73
|
-
if (typeof message === 'string' && /\bauthenticat|\bsign in\b|\blog in\b/i.test(message))
|
|
74
|
-
return new Error(SIGN_IN_MESSAGE);
|
|
75
|
-
return new Error('Google inference failed. Check the Antigravity CLI sign-in, model access, and plan limits.');
|
|
76
|
-
}
|
|
77
|
-
function singleResult(output, attempted) {
|
|
78
|
-
const events = frames(output);
|
|
79
|
-
for (const event of events) {
|
|
80
|
-
const step = event?.event === 'step_update' ? event.step_update : undefined;
|
|
81
|
-
if (step && (step.step_type === 'tool' || step.tool_name !== undefined || step.tool_info !== undefined || step.subagent_info !== undefined))
|
|
82
|
-
throw new Error(attempted);
|
|
83
|
-
}
|
|
84
|
-
const results = events.filter(event => event?.event === 'result').map(event => event.result);
|
|
85
|
-
if (results.length !== 1 || !results[0] || typeof results[0] !== 'object')
|
|
86
|
-
throw new Error('Google did not return exactly one model result');
|
|
87
|
-
const result = results[0];
|
|
88
|
-
if (result.status !== 'SUCCESS')
|
|
89
|
-
throw failure(result.error);
|
|
90
|
-
if (Array.isArray(result.denied_actions) && result.denied_actions.length)
|
|
91
|
-
throw new Error(attempted);
|
|
92
|
-
return result;
|
|
93
|
-
}
|
|
94
|
-
export function parseGoogleResponse(output, tools = []) {
|
|
95
|
-
const result = singleResult(output, 'Google attempted a native tool');
|
|
96
|
-
let structured = result.structured_output;
|
|
97
|
-
if (structured === undefined && typeof result.response === 'string') {
|
|
98
|
-
try {
|
|
99
|
-
structured = JSON.parse(result.response);
|
|
100
|
-
}
|
|
101
|
-
catch { }
|
|
102
|
-
}
|
|
103
|
-
if (structured === undefined)
|
|
104
|
-
throw new Error('Google did not return a complete Andorra model step');
|
|
105
|
-
const response = parseStructuredStep(structured, tools, 'Google');
|
|
106
|
-
const usage = googleUsage(result.usage);
|
|
107
|
-
if (usage)
|
|
108
|
-
response.usage = usage;
|
|
109
|
-
return response;
|
|
110
|
-
}
|
|
111
|
-
export function parseGoogleText(output) {
|
|
112
|
-
const result = singleResult(output, 'Google attempted a tool during text generation');
|
|
113
|
-
const usage = googleUsage(result.usage);
|
|
114
|
-
return { text: typeof result.response === 'string' ? result.response.replace(/\r?\n$/, '') : '', toolCalls: [], ...(usage ? { usage } : {}) };
|
|
115
|
-
}
|
|
116
|
-
export function createGoogleAdapter(_config, dependencies = {}) {
|
|
117
|
-
const run = dependencies.run ?? runGoogleProcess;
|
|
12
|
+
/** Keep saved provider IDs loadable so graphs can report how to migrate. */
|
|
13
|
+
export function createGoogleAdapter() {
|
|
118
14
|
return {
|
|
119
|
-
async listModels(
|
|
120
|
-
|
|
121
|
-
if (!catalog.signedIn)
|
|
122
|
-
throw new Error(SIGN_IN_MESSAGE);
|
|
123
|
-
return catalog.models;
|
|
124
|
-
},
|
|
125
|
-
async generate(request) {
|
|
126
|
-
request.signal.throwIfAborted();
|
|
127
|
-
if (!GOOGLE_MODEL.test(request.model))
|
|
128
|
-
throw new Error('The Google provider runs Gemini models only. Choose a Gemini model.');
|
|
129
|
-
const auxiliary = request.maxTokens !== undefined;
|
|
130
|
-
if (auxiliary && (!Number.isSafeInteger(request.maxTokens) || request.maxTokens < 1))
|
|
131
|
-
throw new Error('Invalid auxiliary output allowance.');
|
|
132
|
-
if (auxiliary && request.tools.length)
|
|
133
|
-
throw new Error('Google cannot apply an auxiliary output allowance to tool-bearing requests.');
|
|
134
|
-
const signal = AbortSignal.any([request.signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS)]);
|
|
135
|
-
const imageCount = request.messages.reduce((total, message) => total + (message.images?.length ?? 0), 0);
|
|
136
|
-
// The CLI has no system-prompt override, so the model-component instructions travel in the prompt.
|
|
137
|
-
const prompt = JSON.stringify({
|
|
138
|
-
instructions: auxiliary ? `${TEXT_STEP_PROMPT} ${allowanceInstruction(request.maxTokens)}` : STRUCTURED_STEP_PROMPT,
|
|
139
|
-
...JSON.parse(structuredStepPrompt(request)),
|
|
140
|
-
...(imageCount ? { omittedImages: `This provider cannot forward images; ${imageCount} image${imageCount === 1 ? ' was' : 's were'} omitted from the conversation.` } : {})
|
|
141
|
-
});
|
|
142
|
-
request.onRequest?.();
|
|
143
|
-
const { stdout } = await run(['--input-format', 'stream-json', '--output-format', 'stream-json', '--model', request.model,
|
|
144
|
-
'--settings', STEP_SETTINGS, '--disable-slash-commands',
|
|
145
|
-
...(auxiliary ? [] : ['--json-schema', JSON.stringify(STRUCTURED_STEP_SCHEMA)])], signal, { input: `${JSON.stringify({ event: 'user', message: { content: prompt } })}\n`, acceptedExitCodes: [0, 1] });
|
|
146
|
-
signal.throwIfAborted();
|
|
147
|
-
if (!auxiliary)
|
|
148
|
-
return parseGoogleResponse(stdout, request.tools);
|
|
149
|
-
const text = parseGoogleText(stdout);
|
|
150
|
-
return boundTextStep(text, request.maxTokens, text.usage?.outputTokens);
|
|
151
|
-
},
|
|
15
|
+
async listModels() { throw new Error(GOOGLE_LEGACY_MESSAGE); },
|
|
16
|
+
async generate() { throw new Error(GOOGLE_LEGACY_MESSAGE); },
|
|
152
17
|
};
|
|
153
18
|
}
|
|
@@ -6,6 +6,7 @@ export interface GraphEditorSessionDependencies {
|
|
|
6
6
|
startServer?: () => Promise<EditorServer>;
|
|
7
7
|
openBrowser?: (url: string, signal: AbortSignal) => Promise<void>;
|
|
8
8
|
checkMembership?: (signal?: AbortSignal) => Promise<void>;
|
|
9
|
+
checkLegal?: () => Promise<void>;
|
|
9
10
|
}
|
|
10
11
|
export declare function createGraphEditorSession(deps?: GraphEditorSessionDependencies): {
|
|
11
12
|
open(signal?: AbortSignal, mode?: "new" | "edit"): Promise<void>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
3
|
import { requireGraphMembership } from './membership.js';
|
|
4
|
+
import { requireLegalAcceptance } from './legal/gate.js';
|
|
4
5
|
const startGraphServer = async () => (await import('./graph-server.js')).startGraphServer();
|
|
5
6
|
function openBrowser(url, signal) {
|
|
6
7
|
const command = process.platform === 'win32' ? 'rundll32.exe' : process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
@@ -24,6 +25,7 @@ export function createGraphEditorSession(deps = {}) {
|
|
|
24
25
|
const operation = pending.then(async () => {
|
|
25
26
|
const active = signal ? AbortSignal.any([signal, lifetime.signal]) : lifetime.signal;
|
|
26
27
|
active.throwIfAborted();
|
|
28
|
+
await (deps.checkLegal ?? requireLegalAcceptance)();
|
|
27
29
|
let created = false;
|
|
28
30
|
try {
|
|
29
31
|
if (server)
|
package/dist/src/graph-health.js
CHANGED
|
@@ -73,7 +73,9 @@ function graphModels(graph, config, session = {}, only) {
|
|
|
73
73
|
if (seen.has(key(parent)))
|
|
74
74
|
continue;
|
|
75
75
|
seen.add(key(parent));
|
|
76
|
-
|
|
76
|
+
// A node that allows spawning without a role has one more child to probe: the general subagent.
|
|
77
|
+
const general = (policy.freeform ?? 'off') === 'off' ? [] : [{ id: 'general', name: 'General subagent' }];
|
|
78
|
+
for (const role of [...(policy.roles ?? []), ...general]) {
|
|
77
79
|
const provider = policy.modelPolicy === 'specific' ? policy.provider ?? parent.provider
|
|
78
80
|
: policy.modelPolicy === 'per-role' ? role.provider ?? parent.provider : parent.provider;
|
|
79
81
|
const model = policy.modelPolicy === 'specific' ? policy.model
|
package/dist/src/graph-runner.js
CHANGED
|
@@ -19,12 +19,13 @@ import { memorySearchTool } from './memory/tools/memorySearchTool.js';
|
|
|
19
19
|
import { resolveEfficiency } from './efficiency.js';
|
|
20
20
|
import { collectWorkspaceFacts } from './workspace-facts.js';
|
|
21
21
|
import { MemoryManager } from './memory/MemoryManager.js';
|
|
22
|
-
import { loadConfig, resolveMemoryConfig } from './config.js';
|
|
22
|
+
import { configDirectory, loadConfig, loadFunctionalConfig, resolveMemoryConfig } from './config.js';
|
|
23
23
|
import { advertiseAvailableTools } from './tool-availability.js';
|
|
24
24
|
import { elapsedMs, monotonicNow } from './duration.js';
|
|
25
25
|
import { dashboardAdapter } from './dashboard.js';
|
|
26
26
|
import { toolBoundaryOpen } from './run-progress.js';
|
|
27
|
-
import { createRunTelemetry, mergeRunTelemetry, recordAttempt, recordErrorOnce, recordTestCommand, recordToolFailure, recordToolUse } from './telemetry/capture.js';
|
|
27
|
+
import { resolveTelemetryCapture, bindRunTelemetry, createRunTelemetry, mergeRunTelemetry, recordAttempt, recordErrorOnce, recordTestCommand, recordToolFailure, recordToolUse } from './telemetry/capture.js';
|
|
28
|
+
import { withTelemetryAdmission } from './telemetry/permission.js';
|
|
28
29
|
import { ProviderRequestError, runFailureCode } from './providers.js';
|
|
29
30
|
import { isTestCommandLine } from './telemetry/classify.js';
|
|
30
31
|
import { reviewNodeUnavailable } from './github-app/review-node.js';
|
|
@@ -81,11 +82,16 @@ async function isolatedRunOptions(options) {
|
|
|
81
82
|
export async function runGraph(graph, options) {
|
|
82
83
|
if (isolatedGraph(graph.id))
|
|
83
84
|
options = await isolatedRunOptions(options);
|
|
85
|
+
options = { ...options, telemetry: resolveTelemetryCapture(options.telemetry) };
|
|
84
86
|
if (options.goalCompletionVerification && !graphCanCheckGoal(graph))
|
|
85
87
|
throw new Error(GOAL_NEEDS_AGENT);
|
|
86
88
|
const removedMemorySettings = [];
|
|
87
89
|
if (!options.memory || !options.decisionManager) {
|
|
88
|
-
const
|
|
90
|
+
const home = options.telemetry ? options.telemetry.home : configDirectory();
|
|
91
|
+
const admitted = await withTelemetryAdmission({ home, signals: options.telemetry ? options.telemetry.signals : undefined }, async (admission) => ({
|
|
92
|
+
config: await (admission.lease.mode === 'out' ? loadConfig : loadFunctionalConfig)(home),
|
|
93
|
+
}), options.telemetry ? options.telemetry.lease : undefined);
|
|
94
|
+
const config = admitted?.config ?? await loadFunctionalConfig(home);
|
|
89
95
|
const memoryConfig = options.memory ? undefined : resolveMemoryConfig(config, process.env, notice => { removedMemorySettings.push(notice); });
|
|
90
96
|
options = { ...options, decisionManager: options.decisionManager ?? new DecisionManager({ config: config.decisions, onEvent: options.onEvent }), memory: options.memory ?? await MemoryManager.create({
|
|
91
97
|
config: memoryConfig, workspace: options.context.workspace, onEvent: options.onEvent, getPermissions: () => permissionMode(options.context),
|
|
@@ -193,8 +199,9 @@ export async function runGraph(graph, options) {
|
|
|
193
199
|
const result = {
|
|
194
200
|
id: options.runId ?? randomUUID(), graph: pinned, provider: options.provider, model: options.model,
|
|
195
201
|
status: 'exhausted', usage: { inputTokens: 0, outputTokens: 0, requests: 0 }, toolCalls: 0, nodeResults: {},
|
|
196
|
-
limits: { ...limits },
|
|
202
|
+
limits: { ...limits },
|
|
197
203
|
};
|
|
204
|
+
bindRunTelemetry(result, createRunTelemetry(options.telemetry));
|
|
198
205
|
const todoStore = options.todoStore ?? new TodoStore();
|
|
199
206
|
const widgetStore = options.widgetStore ?? new WidgetStore(pinned.widgets);
|
|
200
207
|
let seededPlan;
|
|
@@ -430,12 +437,11 @@ export async function runGraph(graph, options) {
|
|
|
430
437
|
target.inputTokens += delta.inputTokens;
|
|
431
438
|
target.outputTokens += delta.outputTokens;
|
|
432
439
|
target.requests += delta.requests;
|
|
433
|
-
|
|
434
|
-
if (
|
|
435
|
-
target.cacheRead =
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
target.cacheWrite = write;
|
|
440
|
+
// A figure the provider reported is kept even when it is zero: a measured zero is not an unreported one.
|
|
441
|
+
if (delta.cacheRead !== undefined || target.cacheRead !== undefined)
|
|
442
|
+
target.cacheRead = (target.cacheRead ?? 0) + (delta.cacheRead ?? 0);
|
|
443
|
+
if (delta.cacheWrite !== undefined || target.cacheWrite !== undefined)
|
|
444
|
+
target.cacheWrite = (target.cacheWrite ?? 0) + (delta.cacheWrite ?? 0);
|
|
439
445
|
if (delta.decodeMs !== undefined)
|
|
440
446
|
target.decodeMs = (target.decodeMs ?? 0) + delta.decodeMs;
|
|
441
447
|
};
|
|
@@ -553,8 +559,8 @@ export async function runGraph(graph, options) {
|
|
|
553
559
|
...(activation.routedModel ? { modelPinned: true } : {}),
|
|
554
560
|
adapter: instrument(options.provider, { model: options.model, adapter: options.adapter }).adapter,
|
|
555
561
|
...(options.resolveModel ? { resolveModel: async (provider, model, signal, reasoningEffort) => instrument(provider, await options.resolveModel(provider, model, signal, reasoningEffort)) } : {}),
|
|
556
|
-
...(options.getLiveModel ? { getLiveModel: async (
|
|
557
|
-
const live = await options.getLiveModel(
|
|
562
|
+
...(options.getLiveModel ? { getLiveModel: async (...args) => {
|
|
563
|
+
const live = await options.getLiveModel(...args);
|
|
558
564
|
return live ? { ...instrument(live.provider, live), provider: live.provider } : undefined;
|
|
559
565
|
} } : {}),
|
|
560
566
|
task: invocationTask,
|
|
@@ -1162,7 +1168,7 @@ export async function runGraph(graph, options) {
|
|
|
1162
1168
|
endOn(result, {});
|
|
1163
1169
|
else
|
|
1164
1170
|
endOn(result, {
|
|
1165
|
-
failureCode: recordErrorOnce(result.telemetry
|
|
1171
|
+
failureCode: recordErrorOnce(result.telemetry, error, runFailureCode(error)),
|
|
1166
1172
|
...(error instanceof ProviderRequestError ? { providerRequestFailed: true, ...(error.contextOverflow ? { providerOverflow: true } : {}) } : {}),
|
|
1167
1173
|
});
|
|
1168
1174
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Config } from './config.js';
|
|
2
|
-
export declare function currentGraphSubject(
|
|
2
|
+
export declare function currentGraphSubject(options?: {
|
|
3
|
+
readOnly?: boolean;
|
|
4
|
+
}): Promise<string | undefined>;
|
|
3
5
|
export declare function identityStillHolds(declared: {
|
|
4
6
|
subject?: string;
|
|
5
7
|
signedOut?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getAuthStatus } from './auth/index.js';
|
|
2
2
|
import { currentGraphSelection } from './membership.js';
|
|
3
|
-
export async function currentGraphSubject() {
|
|
4
|
-
const status = await getAuthStatus().catch(() => ({ signedIn: false, subject: undefined }));
|
|
3
|
+
export async function currentGraphSubject(options) {
|
|
4
|
+
const status = await getAuthStatus(undefined, options).catch(() => ({ signedIn: false, subject: undefined }));
|
|
5
5
|
return status.signedIn && status.subject && /^[A-Za-z0-9-]{1,128}$/.test(status.subject) ? status.subject : undefined;
|
|
6
6
|
}
|
|
7
7
|
export function identityStillHolds(declared, current) {
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
+
import type { LegalDependencies } from './legal/client.js';
|
|
1
2
|
import { type Config } from './config.js';
|
|
2
3
|
import { type Membership } from './membership.js';
|
|
3
4
|
import { GraphSync } from './graph-sync.js';
|
|
4
5
|
import { GraphManagerChat, type ManagerGraphRevision } from './graph-manager-chat.js';
|
|
5
6
|
export declare function readManagerGraphRevision(id: string, graphDirectory: string): Promise<ManagerGraphRevision | undefined>;
|
|
6
7
|
export type GraphManagerChatSession = Pick<GraphManagerChat, 'subscribe' | 'send' | 'approve' | 'answer' | 'cancel' | 'reset' | 'close'>;
|
|
7
|
-
export declare function createGraphSessionCheck(subject: string | undefined, status?: (signal?: AbortSignal
|
|
8
|
+
export declare function createGraphSessionCheck(subject: string | undefined, status?: (signal?: AbortSignal, options?: {
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
}) => Promise<import("./auth/types.js").AuthStatus>, membership?: () => Promise<Membership>): () => Promise<void>;
|
|
8
11
|
export declare const EDITOR_MEMBERSHIP_TTL_MS = 30000;
|
|
9
12
|
export declare function sharedRead<T>(read: () => Promise<T>, ttlMs: number, now?: () => number): () => Promise<T>;
|
|
10
13
|
export declare function requireGraphProviders(directory?: string): Promise<Config>;
|
|
14
|
+
/** Only the authenticated desktop RPC may select an additional, exact loopback origin. */
|
|
15
|
+
export declare function graphEditorParentOrigins(value: unknown): string[];
|
|
11
16
|
export declare function startGraphServer(directory?: string, checkMembership?: () => Promise<unknown>, options?: {
|
|
17
|
+
parentOrigin?: string;
|
|
18
|
+
legal?: LegalDependencies;
|
|
12
19
|
membership?: () => Promise<Membership>;
|
|
13
20
|
sync?: GraphSync;
|
|
14
21
|
managerChat?: (directory: string, graphId: string) => GraphManagerChatSession;
|
package/dist/src/graph-server.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createServer } from 'node:http';
|
|
2
|
+
import { requireLegalAcceptance, LegalAcceptanceRequired } from './legal/gate.js';
|
|
2
3
|
import { randomBytes, timingSafeEqual } from 'node:crypto';
|
|
3
4
|
import { readFile } from 'node:fs/promises';
|
|
4
5
|
import { join } from 'node:path';
|
|
@@ -103,7 +104,32 @@ async function editorConfig(directory) {
|
|
|
103
104
|
throw new Error('Invalid provider configuration. Run `andorra` and open /providers to repair it.');
|
|
104
105
|
}
|
|
105
106
|
}
|
|
107
|
+
const DEFAULT_EDITOR_PARENTS = ['tauri://localhost', 'http://tauri.localhost', 'http://127.0.0.1:7347'];
|
|
108
|
+
/** Only the authenticated desktop RPC may select an additional, exact loopback origin. */
|
|
109
|
+
export function graphEditorParentOrigins(value) {
|
|
110
|
+
if (value === undefined)
|
|
111
|
+
return [...DEFAULT_EDITOR_PARENTS];
|
|
112
|
+
if (typeof value !== 'string')
|
|
113
|
+
throw new Error('Invalid Graph Editor parent origin.');
|
|
114
|
+
if (DEFAULT_EDITOR_PARENTS.includes(value))
|
|
115
|
+
return [...DEFAULT_EDITOR_PARENTS];
|
|
116
|
+
let url;
|
|
117
|
+
try {
|
|
118
|
+
url = new URL(value);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
throw new Error('Invalid Graph Editor parent origin.');
|
|
122
|
+
}
|
|
123
|
+
if (url.protocol !== 'http:' || url.hostname !== '127.0.0.1' || !url.port
|
|
124
|
+
|| Number(url.port) < 1 || Number(url.port) > 65535 || url.origin !== value) {
|
|
125
|
+
throw new Error('Invalid Graph Editor parent origin.');
|
|
126
|
+
}
|
|
127
|
+
return [...DEFAULT_EDITOR_PARENTS, value];
|
|
128
|
+
}
|
|
106
129
|
export async function startGraphServer(directory = configDirectory(), checkMembership = readGraphMembership, options = {}) {
|
|
130
|
+
const parentOrigins = graphEditorParentOrigins(options.parentOrigin);
|
|
131
|
+
const checkLegal = () => requireLegalAcceptance(directory, options.legal);
|
|
132
|
+
await checkLegal(); // Before account storage, autosync, config/model work or opening the editor.
|
|
107
133
|
await editorConfig(directory);
|
|
108
134
|
const startup = await checkMembership();
|
|
109
135
|
const account = checkMembership === readGraphMembership ? await getAuthStatus() : { signedIn: false, subject: undefined };
|
|
@@ -201,7 +227,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
201
227
|
res.setHeader('Cache-Control', 'no-store');
|
|
202
228
|
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
203
229
|
res.setHeader('Referrer-Policy', 'no-referrer');
|
|
204
|
-
res.setHeader('Content-Security-Policy',
|
|
230
|
+
res.setHeader('Content-Security-Policy', `default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; frame-ancestors ${parentOrigins.join(' ')}; base-uri 'none'; form-action 'none'`);
|
|
205
231
|
try {
|
|
206
232
|
if (req.headers.host !== new URL(origin).host || (req.headers.origin && req.headers.origin !== origin)) {
|
|
207
233
|
reply(res, 403, { error: 'Untrusted origin' });
|
|
@@ -219,6 +245,12 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
219
245
|
reply(res, 401, { error: 'Reopen the editor using andorra graph.' });
|
|
220
246
|
return;
|
|
221
247
|
}
|
|
248
|
+
// Local metadata/status and cancellation stay usable after an in-TUI account change.
|
|
249
|
+
// Manager operations that create a child engine or resume work are checked first.
|
|
250
|
+
const harmless = req.method === 'GET' && ['/api/activity', '/api/activity/stream', '/api/sync'].includes(path)
|
|
251
|
+
|| req.method === 'POST' && ['/api/manager/cancel', '/api/manager/reset'].includes(path);
|
|
252
|
+
if (!harmless)
|
|
253
|
+
await checkLegal();
|
|
222
254
|
if (req.method === 'GET' && path === '/api/activity') {
|
|
223
255
|
reply(res, 200, await liveEditorState());
|
|
224
256
|
return;
|
|
@@ -299,7 +331,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
299
331
|
catch { } };
|
|
300
332
|
const timer = setInterval(() => {
|
|
301
333
|
void (async () => { if (sync?.accessDenied)
|
|
302
|
-
throw new PaidMembershipRequiredError(); await checkSession(); })()
|
|
334
|
+
throw new PaidMembershipRequiredError(); await checkSession(); await checkLegal(); })()
|
|
303
335
|
.then(() => { if (open && !res.destroyed)
|
|
304
336
|
res.write(': ping\n\n'); }, end);
|
|
305
337
|
}, MANAGER_PING_MS);
|
|
@@ -328,12 +360,11 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
328
360
|
const parsed = JSON.parse(body.toString('utf8'));
|
|
329
361
|
const value = parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
|
|
330
362
|
const graphId = action === 'message' ? value.graph?.id : value.graphId;
|
|
331
|
-
if (action === 'cancel') {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
accepted(managerChat(graphId).reset());
|
|
363
|
+
if (action === 'cancel' || action === 'reset') {
|
|
364
|
+
if (typeof graphId !== 'string' || !MANAGER_GRAPH_ID.test(graphId))
|
|
365
|
+
throw new Error('Graph Manager needs the id of the open graph.');
|
|
366
|
+
const chat = managers.get(graphId); // Cancellation must not start a new child engine.
|
|
367
|
+
accepted(chat ? action === 'cancel' ? chat.cancel() : chat.reset() : Promise.resolve());
|
|
337
368
|
return;
|
|
338
369
|
}
|
|
339
370
|
if (action === 'approve') {
|
|
@@ -601,15 +632,19 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
601
632
|
}
|
|
602
633
|
const [file, mime] = assets[path];
|
|
603
634
|
const content = await readFile(new URL(`./graph-ui/${file}`, import.meta.url));
|
|
635
|
+
// Serve the same allowlist used by CSP; never derive trust from an HTTP request.
|
|
636
|
+
const body = file === 'embed.js'
|
|
637
|
+
? content.toString('utf8').replace("const parentOrigins = new Set(['tauri://localhost', 'http://tauri.localhost', 'http://127.0.0.1:7347']);", `const parentOrigins = new Set(${JSON.stringify(parentOrigins)});`)
|
|
638
|
+
: content;
|
|
604
639
|
res.writeHead(200, { 'Content-Type': mime });
|
|
605
|
-
res.end(
|
|
640
|
+
res.end(body);
|
|
606
641
|
}
|
|
607
642
|
catch (error) {
|
|
608
643
|
if (error instanceof FreeTierLimitError) {
|
|
609
644
|
reply(res, 422, { error: error.message, code: error.code });
|
|
610
645
|
return;
|
|
611
646
|
}
|
|
612
|
-
reply(res, error instanceof PaidMembershipRequiredError ? 403 : 400, { error: error instanceof Error ? error.message : 'Request failed' });
|
|
647
|
+
reply(res, error instanceof LegalAcceptanceRequired ? 428 : error instanceof PaidMembershipRequiredError ? 403 : 400, { error: error instanceof Error ? error.message : 'Request failed', ...(error instanceof LegalAcceptanceRequired ? { code: error.code } : {}) });
|
|
613
648
|
}
|
|
614
649
|
});
|
|
615
650
|
server.requestTimeout = 15_000;
|
package/dist/src/graph-sync.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Graph } from './graphs.js';
|
|
2
2
|
export interface GraphSyncStatus {
|
|
3
|
-
state: 'pending' | 'syncing' | 'synced' | 'offline';
|
|
3
|
+
state: 'pending' | 'syncing' | 'synced' | 'offline' | 'acceptance-required';
|
|
4
4
|
detail: string;
|
|
5
5
|
}
|
|
6
6
|
export interface GraphSyncDependencies {
|
|
@@ -9,6 +9,7 @@ export interface GraphSyncDependencies {
|
|
|
9
9
|
baseUrl: string;
|
|
10
10
|
fetch: typeof fetch;
|
|
11
11
|
now?: () => number;
|
|
12
|
+
authorize?: () => Promise<void>;
|
|
12
13
|
}
|
|
13
14
|
export declare class GraphSync {
|
|
14
15
|
readonly directory: string;
|