@quantiya/codevibe-core 1.0.18 → 2.0.0

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.
Files changed (36) hide show
  1. package/dist/appsync/appsync-client.d.ts +16 -84
  2. package/dist/appsync/queries.d.ts +2 -8
  3. package/dist/audit-keys/__tests__/audit-keys-parity.test.d.ts +1 -0
  4. package/dist/audit-keys/index.d.ts +41 -0
  5. package/dist/auth/auth-telemetry.d.ts +0 -9
  6. package/dist/index.d.ts +4 -0
  7. package/dist/index.js +72 -45
  8. package/dist/orchestration/detect-agents.d.ts +56 -0
  9. package/dist/orchestration/index.d.ts +2 -0
  10. package/dist/orchestration/orchestration-cli.d.ts +9 -0
  11. package/dist/reviewer/__tests__/integration.test.d.ts +1 -0
  12. package/dist/reviewer/__tests__/mocks.test.d.ts +1 -0
  13. package/dist/reviewer/__tests__/output-parser.test.d.ts +1 -0
  14. package/dist/reviewer/__tests__/registry.test.d.ts +1 -0
  15. package/dist/reviewer/__tests__/subprocess.test.d.ts +1 -0
  16. package/dist/reviewer/index.d.ts +15 -0
  17. package/dist/reviewer/mocks.d.ts +80 -0
  18. package/dist/reviewer/output-parser.d.ts +95 -0
  19. package/dist/reviewer/provider.d.ts +153 -0
  20. package/dist/reviewer/providers/__tests__/claude-live-smoke.test.d.ts +1 -0
  21. package/dist/reviewer/providers/__tests__/claude.test.d.ts +1 -0
  22. package/dist/reviewer/providers/__tests__/codex-live-smoke.test.d.ts +1 -0
  23. package/dist/reviewer/providers/__tests__/codex.test.d.ts +1 -0
  24. package/dist/reviewer/providers/__tests__/gemini-live-smoke.test.d.ts +1 -0
  25. package/dist/reviewer/providers/__tests__/gemini.test.d.ts +1 -0
  26. package/dist/reviewer/providers/claude.d.ts +59 -0
  27. package/dist/reviewer/providers/codex.d.ts +67 -0
  28. package/dist/reviewer/providers/common.d.ts +25 -0
  29. package/dist/reviewer/providers/gemini.d.ts +108 -0
  30. package/dist/reviewer/registry.d.ts +87 -0
  31. package/dist/reviewer/subprocess.d.ts +117 -0
  32. package/dist/reviewer/types.d.ts +101 -0
  33. package/dist/types/index.d.ts +1 -0
  34. package/dist/types/reviewer.d.ts +67 -0
  35. package/dist/types/session.d.ts +16 -0
  36. package/package.json +6 -3
@@ -1,4 +1,4 @@
1
- import { CreateEventInput, CreateSessionInput, UpdateSessionInput, UpdateEventStatusInput, Event, Session, EventSource, DeviceKey, GrantSessionKeyInput } from '../types';
1
+ import { CreateEventInput, CreateSessionInput, UpdateSessionInput, UpdateEventStatusInput, Event, Session, EventSource, DeviceKey, GrantSessionKeyInput, UpdateReviewerPolicyInput, UserReviewerPolicySnapshot } from '../types';
2
2
  /**
3
3
  * Download URL response
4
4
  */
@@ -15,9 +15,6 @@ export declare class AppSyncClient {
15
15
  private currentEmail;
16
16
  private tokens;
17
17
  private activeSubscriptions;
18
- private pendingRefresh;
19
- private lastRefreshFailureAt;
20
- private static readonly REFRESH_BACKOFF_MS;
21
18
  private deviceKeyWatcher;
22
19
  private environment;
23
20
  constructor();
@@ -37,47 +34,6 @@ export declare class AppSyncClient {
37
34
  * Refresh expired tokens
38
35
  */
39
36
  private refreshTokens;
40
- /**
41
- * Do the work of refreshing tokens. Tries the caller-supplied tokens
42
- * first; on failure, re-reads from storage and retries once with a
43
- * potentially-fresher refresh token. This is the self-healing path
44
- * that lets `codevibe login` (which writes new tokens to the
45
- * keychain) recover running daemons without requiring a restart:
46
- * the in-memory copy the daemon cached at boot may be invalid, but
47
- * whatever the user just wrote from the login flow is still valid.
48
- *
49
- * Splitting the two attempts into a pure-network helper keeps the
50
- * orchestration readable without duplicating the fetch + body-shape
51
- * plumbing.
52
- */
53
- private performRefresh;
54
- /**
55
- * POST to Cognito's /oauth2/token with a refresh_token grant.
56
- * Returns the parsed body on 200, or null on any failure (network
57
- * error, non-2xx response, JSON parse failure). Caller decides how
58
- * to proceed — this helper is side-effect-free beyond logging.
59
- */
60
- private callCognitoRefresh;
61
- /**
62
- * Apply a successful refresh response: update in-memory cache first,
63
- * clear the backoff sentinel, then persist to storage. Success here
64
- * is defined as "the process has usable fresh tokens in memory" —
65
- * storage persistence is degraded-success, not a failure mode.
66
- *
67
- * Ordering matters. The API call to Cognito already succeeded, which
68
- * means we hold valid access/id tokens right now. If we delayed the
69
- * in-memory update until after persistence and the keychain write
70
- * threw (keychain locked, disk full, file-backend permission error),
71
- * we'd be stuck with stale-and-known-dead tokens in memory while
72
- * holding valid fresh tokens in local scope that vanish at the end
73
- * of this function. That would re-break both guarantees this hotfix
74
- * makes: no-restart recovery becomes "restart required to escape
75
- * the keychain-lock window," and backoff stays unarmed so the
76
- * caller hot-loops against a working Cognito endpoint — R1's MEDIUM
77
- * on round 1 of this review. Persistence-failure is loud-logged
78
- * so operators can see degraded durability without losing availability.
79
- */
80
- private applyRefreshedTokens;
81
37
  /**
82
38
  * Check if authenticated
83
39
  */
@@ -114,45 +70,6 @@ export declare class AppSyncClient {
114
70
  * List events for a session
115
71
  */
116
72
  listEvents(sessionId: string, source?: EventSource, limit?: number): Promise<Event[]>;
117
- /**
118
- * List the authenticated user's sessions. Paginates automatically
119
- * via nextToken so callers always get the complete set.
120
- */
121
- listSessions(limit?: number): Promise<Array<{
122
- sessionId: string;
123
- agentType: string;
124
- status: string;
125
- lastHeartbeatAt: string | null;
126
- }>>;
127
- /**
128
- * Mark stale ACTIVE sessions of a given agentType INACTIVE so they
129
- * stop appearing in the mobile app's session list. Called at daemon
130
- * startup to clean up after daemons that died without running their
131
- * graceful shutdown (crash, auth-loop death, force-kill, power loss).
132
- *
133
- * Staleness rule: lastHeartbeatAt is older than `staleThresholdMs`
134
- * (default 15 min — a conservative ~7.5× the 2-min heartbeat
135
- * interval, giving legitimately-active daemons on other machines
136
- * ample margin before we consider their session abandoned).
137
- *
138
- * Safety:
139
- * - Only sessions with status === 'ACTIVE' are candidates.
140
- * - Sessions explicitly listed in `excludeSessionIds` are skipped
141
- * (caller can pass the session the daemon is about to attach to
142
- * if the ID is known before the sweep).
143
- * - Absent `lastHeartbeatAt` (never-heartbeated sessions — should
144
- * only happen for rows created within the last few seconds)
145
- * treats the session as fresh and skips.
146
- * - updateSession failures are logged as warnings and don't abort
147
- * the sweep — best-effort cleanup.
148
- *
149
- * Returns the number of sessions actually marked INACTIVE.
150
- */
151
- sweepOrphanSessions(opts: {
152
- agentType: string;
153
- staleThresholdMs?: number;
154
- excludeSessionIds?: string[];
155
- }): Promise<number>;
156
73
  /**
157
74
  * List user device keys
158
75
  */
@@ -177,6 +94,21 @@ export declare class AppSyncClient {
177
94
  * Get attachment download URL
178
95
  */
179
96
  getAttachmentDownloadUrl(s3Key: string): Promise<DownloadUrlResponse>;
97
+ /**
98
+ * Plugin startup pushes the user's locally-detected agents
99
+ * (`CLAUDE` / `GEMINI` / `CODEX`). Idempotent — safe to call every
100
+ * launch. Backend stores in `User.availableAgents`; used later to
101
+ * derive tier-default reviewer seat assignments.
102
+ */
103
+ updateAvailableAgents(agents: Array<'CLAUDE' | 'GEMINI' | 'CODEX'>): Promise<UserReviewerPolicySnapshot>;
104
+ /**
105
+ * Persist the user's orchestration opt-in default and/or custom
106
+ * reviewer panel. Backend validates seat-count against tier, seat_id
107
+ * uniqueness + range, and role uniqueness. Throws on validation
108
+ * failure — error message is user-facing (surfaced to the
109
+ * configure-reviewers wizard).
110
+ */
111
+ updateReviewerPolicy(input: UpdateReviewerPolicyInput): Promise<UserReviewerPolicySnapshot>;
180
112
  /**
181
113
  * Subscribe to events for a session
182
114
  */
@@ -2,14 +2,6 @@ export declare const queries: {
2
2
  getSession: string;
3
3
  listEvents: string;
4
4
  listUserDeviceKeys: string;
5
- /**
6
- * Minimal session listing used by the orphan-sweep path. Only the
7
- * fields needed to decide whether a session row is stale — sessionId
8
- * for the INACTIVE mutation, agentType for the per-plugin filter,
9
- * status to skip non-ACTIVE rows, and lastHeartbeatAt for the age
10
- * check.
11
- */
12
- listSessions: string;
13
5
  };
14
6
  export declare const mutations: {
15
7
  createSession: string;
@@ -19,6 +11,8 @@ export declare const mutations: {
19
11
  registerDeviceKey: string;
20
12
  grantSessionKey: string;
21
13
  getAttachmentDownloadUrl: string;
14
+ updateAvailableAgents: string;
15
+ updateReviewerPolicy: string;
22
16
  };
23
17
  export declare const subscriptions: {
24
18
  onEventCreated: string;
@@ -0,0 +1,41 @@
1
+ export type Uuid = string;
2
+ /**
3
+ * `TaskCreated` — one per task lifecycle. Identity: `(task_id, kind)`.
4
+ */
5
+ export declare function dedupKeyForTaskCreated(taskId: Uuid): string;
6
+ /**
7
+ * `TaskTerminated` — one per task lifecycle. Identity: `(task_id, kind)`.
8
+ */
9
+ export declare function dedupKeyForTaskTerminated(taskId: Uuid): string;
10
+ /**
11
+ * `ProgressEvent` — keyed on `(task_id, kind, caller_event_id)`.
12
+ *
13
+ * `callerEventId` is REQUIRED (no `Option<&str>` fallback per the
14
+ * 2f.2 §5.2 lock). Callers without a stable id must invent one
15
+ * (e.g., a UUID at emit time); silently deriving from payload
16
+ * bytes would re-introduce the dedup-drift bug the lock prevents.
17
+ */
18
+ export declare function dedupKeyForProgressEvent(taskId: Uuid, callerEventId: string): string;
19
+ /**
20
+ * `ToolUse` — keyed on `(task_id, kind, caller_event_id)`. Same
21
+ * REQUIRED-not-optional rule as `dedupKeyForProgressEvent`.
22
+ */
23
+ export declare function dedupKeyForToolUse(taskId: Uuid, callerEventId: string): string;
24
+ /**
25
+ * `DestructiveActionEscalated` — keyed on `(gate_id, kind, action_id)`.
26
+ *
27
+ * Multiple destructive actions can be escalated within one gate
28
+ * (e.g., a turn that proposes both `rm -rf` and `git push --force`).
29
+ * `actionId` is the engine's internal id for the specific
30
+ * destructive call (NOT the gate, NOT the round).
31
+ */
32
+ export declare function dedupKeyForDestructiveActionEscalated(gateId: Uuid, actionId: string): string;
33
+ /**
34
+ * `FlagBadApproval` — keyed on `(flagged_entry_id, kind)`.
35
+ *
36
+ * A user flagging the same prior approval twice should dedupe to
37
+ * one flag. The Rust formula identifies the flag by the audit
38
+ * entry being flagged (not by a synthesized "bad-approval id"
39
+ * passed alongside).
40
+ */
41
+ export declare function dedupKeyForFlagBadApproval(flaggedEntryId: Uuid): string;
@@ -40,19 +40,10 @@ export declare function fireAuthCompletedBeacon(userId: string): Promise<void>;
40
40
  * `reason` is constrained to the `AuthFailureReason` union — this
41
41
  * is the ONLY input path; passing a raw error message is a compile
42
42
  * error.
43
- *
44
- * Optional `errorFragment` is a diagnostic dimension reserved for
45
- * `reason: 'unknown'`. The outer `auth-cli` catch passes the first
46
- * portion of `error.message` here so the next analytics pass can
47
- * see what's hiding in `unknown` and we can ship a typed reason in
48
- * a follow-up. Sanitized inside (newlines/tabs/quotes/backslashes
49
- * stripped, non-ASCII dropped, capped at 100 chars to match GA4's
50
- * default per-param limit).
51
43
  */
52
44
  export declare function fireAuthFailedBeacon(reason: AuthFailureReason, extra?: {
53
45
  httpStatus?: number;
54
46
  stage?: AuthStage;
55
- errorFragment?: string;
56
47
  }): Promise<void>;
57
48
  /**
58
49
  * Attach the reason + beaconed marker to an Error. Non-enumerable so
package/dist/index.d.ts CHANGED
@@ -13,4 +13,8 @@ export { parseInteractivePrompt, normalizeSnapshot, } from './prompt-parser';
13
13
  export type { ParsedInteractivePrompt, PromptKind, InteractivePromptOption, } from './prompt-parser';
14
14
  export { resumeOrCreateSession, prepareSessionEncryption, rekeySessionForNewDevices, startDeviceKeyWatcher, registerDeviceEncryptionKey, } from './session';
15
15
  export type { ResumeOrCreateSessionInput, ResumeOrCreateSessionResult } from './session';
16
+ export { detectInstalledAgents, pushDetectedAgents, applyPerSessionOrchestrationOverride, runOrchestrationCli, } from './orchestration';
17
+ export type { DetectableAgent } from './orchestration';
18
+ export * as Reviewer from './reviewer';
19
+ export * as AuditKeys from './audit-keys';
16
20
  export * from './types';