@agent-native/core 0.227.0 → 0.228.0-nightly-20261111004142

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 (190) hide show
  1. package/dist/action.d.ts +6 -2
  2. package/dist/agent/engine/builder-engine.js +6 -1
  3. package/dist/agent/engine/tool-call-journal-seed.d.ts +2 -0
  4. package/dist/agent/engine/tool-call-journal-seed.js +14 -0
  5. package/dist/agent/harness/store.js +14 -0
  6. package/dist/agent/production-agent.js +257 -17
  7. package/dist/agent/reaped-run-thread.js +6 -0
  8. package/dist/agent/run-manager.js +6 -0
  9. package/dist/agent/tool-call-journal.d.ts +4 -0
  10. package/dist/agent/tool-call-journal.js +12 -0
  11. package/dist/agent/types.d.ts +7 -1
  12. package/dist/app-config/agent.d.ts +3 -0
  13. package/dist/app-config/agent.js +7 -0
  14. package/dist/app-config/schema.d.ts +3 -0
  15. package/dist/application-state/handlers.d.ts +3 -3
  16. package/dist/application-state/handlers.js +6 -1
  17. package/dist/application-state/index.d.ts +3 -2
  18. package/dist/application-state/index.js +3 -2
  19. package/dist/application-state/last-used-tab.d.ts +11 -0
  20. package/dist/application-state/last-used-tab.js +43 -0
  21. package/dist/application-state/script-helpers.d.ts +26 -0
  22. package/dist/application-state/script-helpers.js +83 -15
  23. package/dist/application-state/store.d.ts +8 -0
  24. package/dist/application-state/store.js +16 -0
  25. package/dist/cli/agent.js +7 -3
  26. package/dist/cli/code-agent-executor.d.ts +1 -0
  27. package/dist/cli/code-agent-executor.js +37 -2
  28. package/dist/cli/code.js +3 -1
  29. package/dist/client/agent-sidebar-state.d.ts +2 -0
  30. package/dist/client/browser-tab-use.d.ts +9 -0
  31. package/dist/client/browser-tab-use.js +112 -0
  32. package/dist/client/chat/runtime.js +3 -1
  33. package/dist/client/error-capture.js +33 -1
  34. package/dist/client/navigation/index.d.ts +1 -0
  35. package/dist/client/navigation/index.js +1 -0
  36. package/dist/client/resources/mcp-integration-logos.js +16 -0
  37. package/dist/client/review/use-review.d.ts +28 -0
  38. package/dist/client/review/use-review.js +41 -12
  39. package/dist/client/route-state.js +2 -0
  40. package/dist/client/sse-event-processor.d.ts +1 -0
  41. package/dist/client/sse-event-processor.js +7 -1
  42. package/dist/client/use-db-sync.d.ts +8 -1
  43. package/dist/client/use-db-sync.js +6 -5
  44. package/dist/coding-tools/run-code.js +12 -2
  45. package/dist/coding-tools/sandbox/executions-store.d.ts +1 -1
  46. package/dist/coding-tools/sandbox/executions-store.js +9 -3
  47. package/dist/collab/routes.d.ts +1 -1
  48. package/dist/data-programs/execute.js +1 -1
  49. package/dist/db/schema-snapshot.generated.js +17 -3
  50. package/dist/extensions/url-safety.d.ts +1 -3
  51. package/dist/extensions/url-safety.js +23 -23
  52. package/dist/file-upload/actions/upload-image.d.ts +5 -5
  53. package/dist/file-upload/index.d.ts +1 -1
  54. package/dist/file-upload/index.js +1 -1
  55. package/dist/file-upload/s3-client.d.ts +1 -0
  56. package/dist/file-upload/s3-client.js +70 -13
  57. package/dist/file-upload/s3.d.ts +9 -0
  58. package/dist/file-upload/s3.js +14 -1
  59. package/dist/framework-package-versions.json +8 -8
  60. package/dist/jobs/run-history.js +10 -3
  61. package/dist/jobs/scheduler.js +5 -36
  62. package/dist/localization/core-messages/supplemental/ar-SA.js +35 -0
  63. package/dist/localization/core-messages/supplemental/de-DE.js +35 -0
  64. package/dist/localization/core-messages/supplemental/en-US.js +35 -0
  65. package/dist/localization/core-messages/supplemental/es-ES.js +35 -0
  66. package/dist/localization/core-messages/supplemental/fr-FR.js +35 -0
  67. package/dist/localization/core-messages/supplemental/hi-IN.js +35 -0
  68. package/dist/localization/core-messages/supplemental/ja-JP.js +35 -0
  69. package/dist/localization/core-messages/supplemental/ko-KR.js +35 -0
  70. package/dist/localization/core-messages/supplemental/pt-BR.js +35 -0
  71. package/dist/localization/core-messages/supplemental/zh-CN.js +35 -0
  72. package/dist/localization/core-messages/supplemental/zh-TW.js +35 -0
  73. package/dist/localization/default-messages.d.ts +35 -0
  74. package/dist/localization/default-messages.js +35 -0
  75. package/dist/localization/mcp-settings-messages.d.ts +35 -0
  76. package/dist/mcp/actions/list-mcp-client-connections.d.ts +8 -0
  77. package/dist/mcp/actions/list-mcp-client-connections.js +39 -0
  78. package/dist/mcp/browser-tab-target.d.ts +16 -0
  79. package/dist/mcp/browser-tab-target.js +58 -0
  80. package/dist/mcp/build-server.d.ts +1 -0
  81. package/dist/mcp/build-server.js +38 -7
  82. package/dist/mcp/call-attribution.d.ts +4 -1
  83. package/dist/mcp/call-attribution.js +3 -1
  84. package/dist/mcp/client-connections.d.ts +6 -0
  85. package/dist/mcp/client-connections.js +91 -0
  86. package/dist/mcp/connect-route.js +12 -2
  87. package/dist/mcp/connect-store.d.ts +3 -0
  88. package/dist/mcp/connect-store.js +10 -1
  89. package/dist/mcp/direct-action-call.js +1 -0
  90. package/dist/mcp/oauth-store.d.ts +6 -0
  91. package/dist/mcp/oauth-store.js +23 -0
  92. package/dist/mcp/oauth-token.d.ts +1 -0
  93. package/dist/mcp/oauth-token.js +1 -0
  94. package/dist/mcp/server.js +9 -20
  95. package/dist/mcp-client/config.d.ts +2 -0
  96. package/dist/mcp-client/manager.js +23 -0
  97. package/dist/mcp-client/workspace-servers.js +42 -10
  98. package/dist/notifications/routes.d.ts +3 -3
  99. package/dist/org/handlers.d.ts +1 -1
  100. package/dist/org/handlers.js +21 -17
  101. package/dist/provider-api/actions/custom-provider-registration.d.ts +12 -12
  102. package/dist/provider-api/actions/provider-api.d.ts +8 -8
  103. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  104. package/dist/provider-api/index.js +17 -36
  105. package/dist/review/actions/create-review-comment.d.ts +7 -0
  106. package/dist/review/actions/create-review-comment.js +29 -3
  107. package/dist/review/actions/delete-review-comment.js +2 -2
  108. package/dist/review/actions/list-review-comments.d.ts +3 -0
  109. package/dist/review/actions/list-review-comments.js +41 -17
  110. package/dist/review/actions/react-to-review-comment.js +2 -2
  111. package/dist/review/actions/reply-review-comment.d.ts +4 -0
  112. package/dist/review/actions/reply-review-comment.js +15 -6
  113. package/dist/review/actions/update-review-comment-anchor.d.ts +6 -0
  114. package/dist/review/actions/update-review-comment-anchor.js +39 -10
  115. package/dist/review/actions/update-review-comment.d.ts +3 -0
  116. package/dist/review/actions/update-review-comment.js +28 -3
  117. package/dist/review/errors.d.ts +33 -0
  118. package/dist/review/errors.js +51 -0
  119. package/dist/review/index.d.ts +5 -4
  120. package/dist/review/index.js +3 -2
  121. package/dist/review/registry.d.ts +51 -1
  122. package/dist/review/registry.js +117 -0
  123. package/dist/review/store.d.ts +59 -14
  124. package/dist/review/store.js +622 -101
  125. package/dist/review/suggestions/actions.js +65 -10
  126. package/dist/review/suggestions/actor-kind.d.ts +5 -0
  127. package/dist/review/suggestions/actor-kind.js +20 -0
  128. package/dist/review/suggestions/store.js +16 -2
  129. package/dist/review/suggestions/types.d.ts +13 -0
  130. package/dist/review/types.d.ts +89 -0
  131. package/dist/scripts/db/dev-query-proxy.d.ts +2 -0
  132. package/dist/scripts/db/dev-query-proxy.js +4 -1
  133. package/dist/scripts/db/query.js +3 -0
  134. package/dist/scripts/dev/shell.js +4 -0
  135. package/dist/scripts/dev-session.d.ts +31 -0
  136. package/dist/scripts/dev-session.js +58 -0
  137. package/dist/scripts/resources/list.js +53 -4
  138. package/dist/scripts/runner.js +22 -4
  139. package/dist/search/query.d.ts +11 -5
  140. package/dist/search/query.js +52 -15
  141. package/dist/search/tokenize.d.ts +1 -0
  142. package/dist/search/tokenize.js +3 -0
  143. package/dist/secrets/api-keys.d.ts +4 -0
  144. package/dist/secrets/api-keys.js +5 -0
  145. package/dist/secrets/register.d.ts +2 -0
  146. package/dist/secrets/routes.d.ts +2 -2
  147. package/dist/secrets/routes.js +85 -6
  148. package/dist/secrets/storage.d.ts +2 -0
  149. package/dist/secrets/storage.js +34 -9
  150. package/dist/secrets/substitution.d.ts +3 -2
  151. package/dist/secrets/substitution.js +56 -7
  152. package/dist/server/action-discovery.js +5 -0
  153. package/dist/server/action-routes.js +8 -6
  154. package/dist/server/agent-chat/prompt-resources.js +117 -79
  155. package/dist/server/agent-chat/script-entries.js +15 -8
  156. package/dist/server/agent-chat-plugin.js +9 -4
  157. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  158. package/dist/server/agent-engine-ollama-models-route.d.ts +1 -1
  159. package/dist/server/agents-bundle.d.ts +3 -1
  160. package/dist/server/agents-bundle.js +4 -4
  161. package/dist/server/csrf.js +1 -0
  162. package/dist/server/dev-action-bridge.d.ts +2 -0
  163. package/dist/server/dev-action-bridge.js +34 -5
  164. package/dist/server/first-touch-route.d.ts +1 -1
  165. package/dist/server/http-response-telemetry.js +4 -0
  166. package/dist/server/loopback.js +3 -1
  167. package/dist/server/request-context.d.ts +26 -0
  168. package/dist/shared/app-state-routes.d.ts +7 -0
  169. package/dist/shared/app-state-routes.js +7 -0
  170. package/dist/shared/mcp-client-connections.d.ts +41 -0
  171. package/dist/shared/mcp-client-connections.js +18 -0
  172. package/dist/shared/mcp-connect-content.d.ts +18 -0
  173. package/dist/shared/mcp-connect-content.js +200 -172
  174. package/dist/shared/runtime-config.js +5 -1
  175. package/dist/templates/chat/.agents/skills/context-awareness/SKILL.md +13 -0
  176. package/dist/templates/default/.agents/skills/context-awareness/SKILL.md +13 -0
  177. package/dist/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +13 -0
  178. package/dist/tracking/providers.d.ts +7 -0
  179. package/dist/tracking/providers.js +39 -17
  180. package/dist/triggers/condition-evaluator.d.ts +2 -0
  181. package/dist/triggers/condition-evaluator.js +93 -3
  182. package/dist/triggers/dispatcher.js +24 -6
  183. package/docs/AGENTS.md +16 -16
  184. package/docs/content/create-with-an-agent.mdx +10 -4
  185. package/docs/content/durable-resume.mdx +11 -2
  186. package/docs/content/toolkit-comments-review.mdx +54 -1
  187. package/package.json +5 -4
  188. package/src/templates/chat/.agents/skills/context-awareness/SKILL.md +13 -0
  189. package/src/templates/default/.agents/skills/context-awareness/SKILL.md +13 -0
  190. package/src/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +13 -0
@@ -1,9 +1,59 @@
1
+ import type { DbExec } from "../db/client.js";
1
2
  import { type Visibility } from "../sharing/schema.js";
2
- import type { ReviewResourceAccess, ReviewResourceContext, ReviewResourceRole, ReviewableResourceRegistration } from "./types.js";
3
+ import type { ReviewCommentPolicy, ReviewCommentWriteEvent, ReviewResourceAccess, ReviewResourceContext, ReviewResourceRole, ReviewableResourceRegistration } from "./types.js";
3
4
  export declare function registerReviewableResource(registration: ReviewableResourceRegistration): void;
4
5
  export declare function getReviewableResource(type: string): ReviewableResourceRegistration | undefined;
5
6
  export declare function listReviewableResources(): ReviewableResourceRegistration[];
6
7
  export declare function resolveReviewableResourceAccess(resourceType: string, resourceId: string, ctx?: ReviewResourceContext): Promise<ReviewResourceAccess | null>;
7
8
  export declare function assertReviewableResourceAccess(resourceType: string, resourceId: string, ctx: ReviewResourceContext | undefined, minimumRole: ReviewResourceRole): Promise<ReviewResourceAccess>;
9
+ /** The resource's comment policy, with the kit's defaults filled in. */
10
+ export declare function reviewCommentPolicy(resourceType: string): Required<ReviewCommentPolicy>;
11
+ /**
12
+ * The role a suggestion's author needs. A suggestion opens a comment thread,
13
+ * so a resource asking more of commenters asks it of suggesters too; but it
14
+ * proposes a change as well, so it never takes less than a commenter, even
15
+ * where viewers may comment.
16
+ */
17
+ export declare function reviewSuggestionAuthorRole(resourceType: string): ReviewResourceRole;
18
+ /**
19
+ * Whether this access lets its holder comment, reply and react, and edit or
20
+ * delete their own comments. A viewer-level policy opens that to signed-in
21
+ * viewers only: a caller who isn't signed in, such as a visitor to a public
22
+ * resource, still needs the commenter role.
23
+ */
24
+ export declare function canCommentOnReviewableResource(resourceType: string, access: ReviewResourceAccess | null | undefined, signedIn?: boolean): access is ReviewResourceAccess;
25
+ /** Checks the caller holds at least the role the comment policy asks for. */
26
+ export declare function assertReviewCommentAccess(resourceType: string, resourceId: string, ctx: ReviewResourceContext | undefined): Promise<ReviewResourceAccess>;
27
+ /**
28
+ * The kit's own anchor kind, on the thread a suggestion opens: the anchors of
29
+ * its operations, in order. Every resource accepts it, and none may declare it.
30
+ */
31
+ export declare const REVIEW_SUGGESTION_ANCHOR_KIND = "review-suggestion";
32
+ export interface ReviewAnchorInput {
33
+ anchor?: unknown;
34
+ anchorKind?: string | null;
35
+ anchorVersion?: number | null;
36
+ }
37
+ export interface NormalizedReviewAnchor {
38
+ anchor: unknown;
39
+ anchorKind: string | null;
40
+ anchorVersion: number | null;
41
+ }
42
+ /**
43
+ * Checks a comment's anchor against its resource's anchor kinds and returns it
44
+ * as it's stored. A resource that declares no kinds keeps untyped anchors, as
45
+ * before kinds existed; one that declares any needs every anchor to name one.
46
+ */
47
+ export declare function normalizeReviewAnchor(resourceType: string, input: ReviewAnchorInput): NormalizedReviewAnchor;
48
+ /**
49
+ * Refuses a person's comment write that names one of the kit's own anchor
50
+ * kinds, or moves an anchor that keeps one. Only the kit writes those, so a
51
+ * resource's own parser reads every anchor a person sends.
52
+ */
53
+ export declare function assertPersonReviewAnchorKind(anchorKind: string | null | undefined): void;
54
+ /** Whether a resource type has a hook that comment writes must run. */
55
+ export declare function hasReviewCommentWriteHook(resourceType: string): boolean;
56
+ /** Runs the resource's comment write hook on the write's own transaction. */
57
+ export declare function runReviewCommentWriteHook(resourceType: string, event: ReviewCommentWriteEvent, tx: DbExec): Promise<void>;
8
58
  export declare function normalizeReviewVisibility(visibility: Visibility | null | undefined): Visibility;
9
59
  export declare function __resetReviewableResourcesForTests(): void;
@@ -1,11 +1,20 @@
1
1
  import { ForbiddenError, resolveAccess, } from "../sharing/access.js";
2
2
  import { getShareableResource } from "../sharing/registry.js";
3
3
  import { roleSatisfies } from "../sharing/schema.js";
4
+ import { ReviewAnchorError } from "./errors.js";
4
5
  const registrations = new Map();
5
6
  export function registerReviewableResource(registration) {
6
7
  if (!registration.type.trim()) {
7
8
  throw new Error("registerReviewableResource requires a non-empty resource type");
8
9
  }
10
+ for (const [name, kind] of Object.entries(registration.anchorKinds ?? {})) {
11
+ if (!name.trim() || !Number.isInteger(kind.version) || kind.version < 1) {
12
+ throw new Error(`Anchor kind "${name}" on ${registration.type} needs a name and a whole version from 1`);
13
+ }
14
+ if (ownAnchorKind(KIT_ANCHOR_KINDS, name)) {
15
+ throw new Error(`Anchor kind "${name}" belongs to the review kit`);
16
+ }
17
+ }
9
18
  registrations.set(registration.type, registration);
10
19
  }
11
20
  export function getReviewableResource(type) {
@@ -50,6 +59,114 @@ export async function assertReviewableResourceAccess(resourceType, resourceId, c
50
59
  }
51
60
  return access;
52
61
  }
62
+ /** The resource's comment policy, with the kit's defaults filled in. */
63
+ export function reviewCommentPolicy(resourceType) {
64
+ const policy = getReviewableResource(resourceType)?.comments;
65
+ return {
66
+ minimumRole: policy?.minimumRole ?? "commenter",
67
+ unmentionedRoute: policy?.unmentionedRoute ?? "agent",
68
+ };
69
+ }
70
+ /**
71
+ * The role a suggestion's author needs. A suggestion opens a comment thread,
72
+ * so a resource asking more of commenters asks it of suggesters too; but it
73
+ * proposes a change as well, so it never takes less than a commenter, even
74
+ * where viewers may comment.
75
+ */
76
+ export function reviewSuggestionAuthorRole(resourceType) {
77
+ const { minimumRole } = reviewCommentPolicy(resourceType);
78
+ return roleSatisfies(minimumRole, "commenter") ? minimumRole : "commenter";
79
+ }
80
+ /**
81
+ * Whether this access lets its holder comment, reply and react, and edit or
82
+ * delete their own comments. A viewer-level policy opens that to signed-in
83
+ * viewers only: a caller who isn't signed in, such as a visitor to a public
84
+ * resource, still needs the commenter role.
85
+ */
86
+ export function canCommentOnReviewableResource(resourceType, access, signedIn = true) {
87
+ return Boolean(access &&
88
+ roleSatisfies(access.role, reviewCommentPolicy(resourceType).minimumRole) &&
89
+ (signedIn || roleSatisfies(access.role, "commenter")));
90
+ }
91
+ /** Checks the caller holds at least the role the comment policy asks for. */
92
+ export async function assertReviewCommentAccess(resourceType, resourceId, ctx) {
93
+ const access = await resolveReviewableResourceAccess(resourceType, resourceId, ctx);
94
+ if (!canCommentOnReviewableResource(resourceType, access, Boolean(ctx?.userEmail))) {
95
+ throw new ForbiddenError(`Not allowed to comment on ${resourceType}:${resourceId}`);
96
+ }
97
+ return access;
98
+ }
99
+ /**
100
+ * The kit's own anchor kind, on the thread a suggestion opens: the anchors of
101
+ * its operations, in order. Every resource accepts it, and none may declare it.
102
+ */
103
+ export const REVIEW_SUGGESTION_ANCHOR_KIND = "review-suggestion";
104
+ const KIT_ANCHOR_KINDS = {
105
+ [REVIEW_SUGGESTION_ANCHOR_KIND]: { version: 1, parse: (anchor) => anchor },
106
+ };
107
+ function ownAnchorKind(kinds, name) {
108
+ const kind = kinds?.[name];
109
+ return kind && Object.prototype.hasOwnProperty.call(kinds, name)
110
+ ? kind
111
+ : null;
112
+ }
113
+ /**
114
+ * Checks a comment's anchor against its resource's anchor kinds and returns it
115
+ * as it's stored. A resource that declares no kinds keeps untyped anchors, as
116
+ * before kinds existed; one that declares any needs every anchor to name one.
117
+ */
118
+ export function normalizeReviewAnchor(resourceType, input) {
119
+ const anchor = input.anchor ?? null;
120
+ const kinds = getReviewableResource(resourceType)?.anchorKinds;
121
+ const kindName = input.anchorKind ?? null;
122
+ if (kindName === null) {
123
+ if (input.anchorVersion != null) {
124
+ throw new ReviewAnchorError("An anchor version needs an anchor kind.");
125
+ }
126
+ if (anchor !== null && kinds && Object.keys(kinds).length > 0) {
127
+ throw new ReviewAnchorError(`Anchored ${resourceType} comments need an anchor kind: ${Object.keys(kinds).join(", ")}.`);
128
+ }
129
+ return { anchor, anchorKind: null, anchorVersion: null };
130
+ }
131
+ const kind = ownAnchorKind(KIT_ANCHOR_KINDS, kindName) ?? ownAnchorKind(kinds, kindName);
132
+ if (!kind) {
133
+ throw new ReviewAnchorError(`${resourceType} comments have no anchor kind "${kindName}".`);
134
+ }
135
+ const version = input.anchorVersion ?? kind.version;
136
+ if (!Number.isInteger(version) || version < 1 || version > kind.version) {
137
+ throw new ReviewAnchorError(`Anchor kind "${kindName}" has no version ${version}; the latest is ${kind.version}.`);
138
+ }
139
+ let parsed;
140
+ try {
141
+ parsed = kind.parse(anchor, version);
142
+ }
143
+ catch (error) {
144
+ throw new ReviewAnchorError(`Not a valid "${kindName}" anchor: ${error instanceof Error ? error.message : String(error)}`);
145
+ }
146
+ return {
147
+ anchor: parsed === undefined ? null : parsed,
148
+ anchorKind: kindName,
149
+ anchorVersion: version,
150
+ };
151
+ }
152
+ /**
153
+ * Refuses a person's comment write that names one of the kit's own anchor
154
+ * kinds, or moves an anchor that keeps one. Only the kit writes those, so a
155
+ * resource's own parser reads every anchor a person sends.
156
+ */
157
+ export function assertPersonReviewAnchorKind(anchorKind) {
158
+ if (anchorKind != null && ownAnchorKind(KIT_ANCHOR_KINDS, anchorKind)) {
159
+ throw new ReviewAnchorError(`Only the review kit writes "${anchorKind}" anchors.`);
160
+ }
161
+ }
162
+ /** Whether a resource type has a hook that comment writes must run. */
163
+ export function hasReviewCommentWriteHook(resourceType) {
164
+ return Boolean(getReviewableResource(resourceType)?.onCommentWrite);
165
+ }
166
+ /** Runs the resource's comment write hook on the write's own transaction. */
167
+ export async function runReviewCommentWriteHook(resourceType, event, tx) {
168
+ await getReviewableResource(resourceType)?.onCommentWrite?.(event, tx);
169
+ }
53
170
  export function normalizeReviewVisibility(visibility) {
54
171
  return visibility === "org" || visibility === "public"
55
172
  ? visibility
@@ -1,6 +1,6 @@
1
1
  import { type DbExec } from "../db/client.js";
2
2
  import type { Visibility } from "../sharing/schema.js";
3
- import type { ReviewActorKind, ReviewComment, ReviewCommentKind, ReviewCommentReaction, ReviewThreadPreference, ReviewMention, ReviewResolutionTarget, ReviewScope, ReviewStatus, ReviewStatusEntry } from "./types.js";
3
+ import type { ReviewActorKind, ReviewComment, ReviewCommentKind, ReviewCommentLink, ReviewCommentReaction, ReviewThreadPreference, ReviewMention, ReviewResolutionTarget, ReviewScope, ReviewStatus, ReviewStatusEntry } from "./types.js";
4
4
  type ReviewThreadStatus = "open" | "resolved";
5
5
  export interface InsertReviewCommentInput {
6
6
  id?: string;
@@ -9,8 +9,11 @@ export interface InsertReviewCommentInput {
9
9
  threadId?: string | null;
10
10
  parentCommentId?: string | null;
11
11
  targetId?: string | null;
12
+ surfaceId?: string | null;
12
13
  kind?: ReviewCommentKind;
13
14
  anchor?: unknown;
15
+ anchorKind?: string | null;
16
+ anchorVersion?: number | null;
14
17
  body: string;
15
18
  authorEmail?: string | null;
16
19
  authorName?: string | null;
@@ -30,21 +33,47 @@ export interface InsertReviewCommentResult {
30
33
  export interface UpdateReviewCommentInput {
31
34
  body?: string;
32
35
  anchor?: unknown;
36
+ /** With `anchor`: a new kind for it. Left out, the comment's kind stays. */
37
+ anchorKind?: string | null;
38
+ anchorVersion?: number | null;
33
39
  mentions?: ReviewMention[];
34
40
  }
41
+ export interface ReviewCommentWriteOptions {
42
+ /**
43
+ * The revision the caller read. When the comment has moved past it, nothing
44
+ * is written and a `ReviewCommentRevisionConflictError` is thrown.
45
+ */
46
+ expectedRevision?: number | undefined;
47
+ /** Who made the change, for the resource's write hook. */
48
+ actorEmail?: string | null | undefined;
49
+ }
35
50
  export interface QueryReviewCommentsInput {
36
51
  resourceType: string;
37
52
  resourceId: string;
38
53
  scope: ReviewScope;
39
- bypassScope?: boolean;
40
- includeResolved?: boolean;
41
- includeDeleted?: boolean;
42
- targetId?: string | null;
43
- newestFirst?: boolean;
54
+ bypassScope?: boolean | undefined;
55
+ includeResolved?: boolean | undefined;
56
+ includeDeleted?: boolean | undefined;
57
+ targetId?: string | null | undefined;
58
+ /** One surface's comments, or with `null` those on no surface. */
59
+ surfaceId?: string | null | undefined;
60
+ newestFirst?: boolean | undefined;
44
61
  rootOnly?: boolean;
45
62
  resolutionTargets?: readonly (ReviewResolutionTarget | null)[];
46
63
  unconsumedOnly?: boolean;
47
- limit?: number;
64
+ /** Oldest first only: start after this comment. */
65
+ after?: ReviewCommentPosition | undefined;
66
+ limit?: number | undefined;
67
+ }
68
+ /** Where a comment sits in oldest-first order. */
69
+ export interface ReviewCommentPosition {
70
+ createdAt: string;
71
+ id: string;
72
+ }
73
+ export interface ReviewCommentPage {
74
+ comments: ReviewComment[];
75
+ /** Pass back as `cursor` for the next page; null on the last one. */
76
+ nextCursor: string | null;
48
77
  }
49
78
  export interface GetReviewThreadSummaryInput {
50
79
  resourceType: string;
@@ -52,6 +81,8 @@ export interface GetReviewThreadSummaryInput {
52
81
  scope: ReviewScope;
53
82
  bypassScope?: boolean;
54
83
  targetId?: string | null;
84
+ /** One surface's threads, or `null` for those on no surface. */
85
+ surfaceId?: string | null | undefined;
55
86
  }
56
87
  export interface ReviewThreadSummary {
57
88
  openCount: number;
@@ -152,6 +183,14 @@ export declare function insertReviewReplyIdempotently(input: InsertReviewComment
152
183
  }): Promise<InsertReviewCommentResult>;
153
184
  export declare function insertReviewCommentWithClient(input: InsertReviewCommentInput, client: DbExec): Promise<ReviewComment>;
154
185
  export declare function queryReviewComments(input: QueryReviewCommentsInput): Promise<ReviewComment[]>;
186
+ /**
187
+ * One page of a resource's comments, oldest first, and the cursor for the
188
+ * next. Unlike a plain list, which stops at its limit, every comment is
189
+ * reachable page by page.
190
+ */
191
+ export declare function queryReviewCommentPage(input: Omit<QueryReviewCommentsInput, "after"> & {
192
+ cursor?: string | null | undefined;
193
+ }): Promise<ReviewCommentPage>;
155
194
  export declare function getReviewThreadSummary(input: GetReviewThreadSummaryInput): Promise<ReviewThreadSummary>;
156
195
  export declare function getReviewCommentById(id: string, scope: ReviewScope, options?: {
157
196
  bypassScope?: boolean;
@@ -162,12 +201,6 @@ export declare function getReviewThreadRoot(threadId: string, resource: {
162
201
  }, scope: ReviewScope, options?: {
163
202
  bypassScope?: boolean;
164
203
  }): Promise<ReviewComment | null>;
165
- export declare function updateReviewCommentAnchor(input: {
166
- commentId: string;
167
- resourceType: string;
168
- resourceId: string;
169
- anchor: unknown;
170
- }): Promise<number>;
171
204
  export declare function resolveReviewThread(threadId: string, resolvedBy?: string | null, resource?: {
172
205
  resourceType: string;
173
206
  resourceId: string;
@@ -218,7 +251,7 @@ export declare function listReviewThreadParticipantEmails(input: {
218
251
  export declare function updateReviewComment(id: string, input: UpdateReviewCommentInput, resource?: {
219
252
  resourceType: string;
220
253
  resourceId: string;
221
- }): Promise<ReviewComment | null>;
254
+ }, options?: ReviewCommentWriteOptions): Promise<ReviewComment | null>;
222
255
  export declare function consumeReviewFeedback(ids: string[], consumedAt?: string, resource?: {
223
256
  resourceType: string;
224
257
  resourceId: string;
@@ -227,6 +260,18 @@ export declare function upsertReviewStatus(input: UpsertReviewStatusInput): Prom
227
260
  export declare function getReviewStatus(resourceType: string, resourceId: string, scope: ReviewScope, options?: {
228
261
  bypassScope?: boolean;
229
262
  }): Promise<ReviewStatusEntry | null>;
263
+ /**
264
+ * Links a comment to the same comment or thread in another system, such as a
265
+ * Notion comment or discussion, so an import can skip what it already copied.
266
+ * Linking the same outside ID to the same comment again changes nothing;
267
+ * linking it to another comment is refused. Links outlive a deleted comment,
268
+ * so a later import doesn't bring it back.
269
+ */
270
+ export declare function linkReviewComment(input: Omit<ReviewCommentLink, "createdAt" | "resourceType" | "resourceId">, client?: DbExec): Promise<ReviewCommentLink>;
271
+ /** The comment an outside ID is linked to, if any. */
272
+ export declare function findReviewCommentLink(input: Pick<ReviewCommentLink, "provider" | "externalKind" | "externalId">, client?: DbExec): Promise<ReviewCommentLink | null>;
273
+ /** Every outside link on these comments, optionally from one system. */
274
+ export declare function listReviewCommentLinks(commentIds: readonly string[], provider?: string): Promise<ReviewCommentLink[]>;
230
275
  export declare function __resetReviewInitForTests(): void;
231
276
  export declare function reviewCommentIdForClientOperation(clientOperationId: string): string;
232
277
  export {};