mossbear 0.1.0-alpha.114 → 0.1.0-alpha.115

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 (68) hide show
  1. package/dist/agent-comment-client.d.ts +1 -37
  2. package/dist/agent-comment-client.d.ts.map +1 -1
  3. package/dist/agent-comment-client.js +0 -50
  4. package/dist/agent-comment-client.js.map +1 -1
  5. package/dist/artifacts/artifact-comments-client.d.ts +3 -77
  6. package/dist/artifacts/artifact-comments-client.d.ts.map +1 -1
  7. package/dist/artifacts/artifact-comments-client.js +3 -103
  8. package/dist/artifacts/artifact-comments-client.js.map +1 -1
  9. package/dist/artifacts/sync-acquisition.d.ts +51 -0
  10. package/dist/artifacts/sync-acquisition.d.ts.map +1 -0
  11. package/dist/artifacts/sync-acquisition.js +84 -0
  12. package/dist/artifacts/sync-acquisition.js.map +1 -0
  13. package/dist/artifacts/sync-artifacts.d.ts +49 -91
  14. package/dist/artifacts/sync-artifacts.d.ts.map +1 -1
  15. package/dist/artifacts/sync-artifacts.js +9 -772
  16. package/dist/artifacts/sync-artifacts.js.map +1 -1
  17. package/dist/artifacts/sync-report.d.ts +91 -1
  18. package/dist/artifacts/sync-report.d.ts.map +1 -1
  19. package/dist/artifacts/sync-report.js +661 -0
  20. package/dist/artifacts/sync-report.js.map +1 -1
  21. package/dist/commands/comment.d.ts +1 -1
  22. package/dist/commands/comment.d.ts.map +1 -1
  23. package/dist/commands/comment.js +7 -10
  24. package/dist/commands/comment.js.map +1 -1
  25. package/dist/commands/comments.d.ts.map +1 -1
  26. package/dist/commands/comments.js +1 -4
  27. package/dist/commands/comments.js.map +1 -1
  28. package/dist/commands/mcp.d.ts.map +1 -1
  29. package/dist/commands/mcp.js +2 -4
  30. package/dist/commands/mcp.js.map +1 -1
  31. package/dist/commands/recommend-dismissal.d.ts.map +1 -1
  32. package/dist/commands/recommend-dismissal.js +3 -2
  33. package/dist/commands/recommend-dismissal.js.map +1 -1
  34. package/dist/commands/search.d.ts +1 -1
  35. package/dist/commands/search.d.ts.map +1 -1
  36. package/dist/commands/search.js +3 -5
  37. package/dist/commands/search.js.map +1 -1
  38. package/dist/context/materialize.d.ts.map +1 -1
  39. package/dist/context/materialize.js +3 -1
  40. package/dist/context/materialize.js.map +1 -1
  41. package/dist/http-retry.d.ts.map +1 -1
  42. package/dist/http-retry.js +30 -1
  43. package/dist/http-retry.js.map +1 -1
  44. package/dist/mcp/client.d.ts +113 -1
  45. package/dist/mcp/client.d.ts.map +1 -1
  46. package/dist/mcp/client.js +220 -1
  47. package/dist/mcp/client.js.map +1 -1
  48. package/dist/mcp/operations.d.ts +2 -25
  49. package/dist/mcp/operations.d.ts.map +1 -1
  50. package/dist/mcp/operations.js +24 -62
  51. package/dist/mcp/operations.js.map +1 -1
  52. package/dist/mcp/server.d.ts.map +1 -1
  53. package/dist/mcp/server.js +12 -11
  54. package/dist/mcp/server.js.map +1 -1
  55. package/dist/usage/snapshot-state.d.ts +2 -2
  56. package/package.json +4 -4
  57. package/dist/finding-dismissals-client.d.ts +0 -28
  58. package/dist/finding-dismissals-client.d.ts.map +0 -1
  59. package/dist/finding-dismissals-client.js +0 -25
  60. package/dist/finding-dismissals-client.js.map +0 -1
  61. package/dist/search-client.d.ts +0 -59
  62. package/dist/search-client.d.ts.map +0 -1
  63. package/dist/search-client.js +0 -130
  64. package/dist/search-client.js.map +0 -1
  65. package/dist/session-digest-client.d.ts +0 -36
  66. package/dist/session-digest-client.d.ts.map +0 -1
  67. package/dist/session-digest-client.js +0 -60
  68. package/dist/session-digest-client.js.map +0 -1
@@ -1,40 +1,4 @@
1
- /**
2
- * The CLI's write of an agent comment: `POST /api/v1/context/comments`.
3
- *
4
- * **One client, two callers** — the MCP `comment` tool and the
5
- * `mossbear comment` verb — for the reason `search-client.ts` gives: two fetch
6
- * calls are two places for the headers, the status handling and the response
7
- * schema to drift. The response goes through the protocol's own parser, so a
8
- * drifting server contract fails here rather than being reported to an agent as
9
- * a comment that was left.
10
- *
11
- * Who the agent is is the caller's to say (`agent`), and the callers read it
12
- * from the harness (`resolveAgentSession`); this module neither reads an
13
- * environment nor makes an id up.
14
- */
15
- import type { AgentCommentRequest, AgentCommentResponse } from '@mossbear/protocol';
16
- export type CreateAgentCommentOptions = {
17
- dashboardUrl: string;
18
- token: string;
19
- target: AgentCommentRequest['target'];
20
- body: string;
21
- /** The exact text of whole lines of the artifact this comment is about. */
22
- passage?: string | undefined;
23
- agent: {
24
- sessionId: string;
25
- harness: AgentCommentRequest['agent']['harness'];
26
- model?: string | undefined;
27
- };
28
- /** This repo's committed `project.id`, so a reply by id prefix finds its repo's findings. */
29
- projectId?: string | null;
30
- /** The bundles this repo's comment read is scoped to, so a reply's id prefix is matched among them. */
31
- bundleIds?: readonly string[] | undefined;
32
- /** Defaults to the running CLI's own version. */
33
- cliVersion?: string;
34
- /** Override fetch for tests. Defaults to globalThis.fetch. */
35
- fetchImpl?: typeof fetch;
36
- };
37
- export declare function createAgentComment(options: CreateAgentCommentOptions): Promise<AgentCommentResponse>;
1
+ import type { AgentCommentResponse } from '@mossbear/protocol';
38
2
  /**
39
3
  * What to tell the caller a create did, in one sentence. The two outcomes read
40
4
  * differently on purpose: an agent that was handed back its earlier comment must
@@ -1 +1 @@
1
- {"version":3,"file":"agent-comment-client.d.ts","sourceRoot":"","sources":["../src/agent-comment-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAQH,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAEnF,MAAM,MAAM,yBAAyB,GAAG;IACtC,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,KAAK,EAAE;QACL,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAA;QAChD,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAC3B,CAAA;IACD,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,uGAAuG;IACvG,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;IACzC,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACzB,CAAA;AAED,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,oBAAoB,CAAC,CAkC/B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAIzE"}
1
+ {"version":3,"file":"agent-comment-client.d.ts","sourceRoot":"","sources":["../src/agent-comment-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE9D;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAIzE"}
@@ -1,53 +1,3 @@
1
- /**
2
- * The CLI's write of an agent comment: `POST /api/v1/context/comments`.
3
- *
4
- * **One client, two callers** — the MCP `comment` tool and the
5
- * `mossbear comment` verb — for the reason `search-client.ts` gives: two fetch
6
- * calls are two places for the headers, the status handling and the response
7
- * schema to drift. The response goes through the protocol's own parser, so a
8
- * drifting server contract fails here rather than being reported to an agent as
9
- * a comment that was left.
10
- *
11
- * Who the agent is is the caller's to say (`agent`), and the callers read it
12
- * from the harness (`resolveAgentSession`); this module neither reads an
13
- * environment nor makes an id up.
14
- */
15
- import { parseAgentCommentResponse } from '@mossbear/protocol';
16
- import { dashboardHttpError } from './dashboard-error.js';
17
- import { trimTrailingSlashes } from './url.js';
18
- import { CLI_VERSION } from './version.js';
19
- export async function createAgentComment(options) {
20
- const request = {
21
- target: options.target,
22
- body: options.body,
23
- ...(options.passage !== undefined ? { passage: options.passage } : {}),
24
- agent: {
25
- sessionId: options.agent.sessionId,
26
- harness: options.agent.harness,
27
- ...(options.agent.model ? { model: options.agent.model } : {}),
28
- cliVersion: options.cliVersion ?? CLI_VERSION,
29
- },
30
- ...(options.projectId ? { projectId: options.projectId } : {}),
31
- ...(options.bundleIds && options.bundleIds.length > 0
32
- ? { bundleIds: [...options.bundleIds] }
33
- : {}),
34
- };
35
- const response = await (options.fetchImpl ?? fetch)(`${trimTrailingSlashes(options.dashboardUrl)}/api/v1/context/comments`, {
36
- method: 'POST',
37
- headers: {
38
- Authorization: `Bearer ${options.token}`,
39
- 'Content-Type': 'application/json',
40
- },
41
- body: JSON.stringify(request),
42
- });
43
- if (!response.ok) {
44
- const text = await response.text().catch(() => '');
45
- // The server's own sentence when it sent one ("This agent session has left
46
- // 50 comments here"), the status form when a gateway answered instead.
47
- throw dashboardHttpError('Comment', response.status, text);
48
- }
49
- return parseAgentCommentResponse(await response.json());
50
- }
51
1
  /**
52
2
  * What to tell the caller a create did, in one sentence. The two outcomes read
53
3
  * differently on purpose: an agent that was handed back its earlier comment must
@@ -1 +1 @@
1
- {"version":3,"file":"agent-comment-client.js","sourceRoot":"","sources":["../src/agent-comment-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AA0B1C,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAkC;IAElC,MAAM,OAAO,GAAwB;QACnC,MAAM,EAAE,OAAO,CAAC,MAAM;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AAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;QAClD,2EAA2E;QAC3E,uEAAuE;QACvE,MAAM,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC5D,CAAC;IACD,OAAO,yBAAyB,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAA4B;IAC/D,OAAO,MAAM,CAAC,OAAO;QACnB,CAAC,CAAC,sBAAsB,MAAM,CAAC,OAAO,CAAC,EAAE,IAAI;QAC7C,CAAC,CAAC,sCAAsC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,KAAK,MAAM,CAAC,OAAO,CAAC,EAAE,qDAAqD,CAAA;AACzL,CAAC"}
1
+ {"version":3,"file":"agent-comment-client.js","sourceRoot":"","sources":["../src/agent-comment-client.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAA4B;IAC/D,OAAO,MAAM,CAAC,OAAO;QACnB,CAAC,CAAC,sBAAsB,MAAM,CAAC,OAAO,CAAC,EAAE,IAAI;QAC7C,CAAC,CAAC,sCAAsC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,KAAK,MAAM,CAAC,OAAO,CAAC,EAAE,qDAAqD,CAAA;AACzL,CAAC"}
@@ -1,26 +1,5 @@
1
- /**
2
- * The CLI's read of the comment channel: `GET /api/v1/context/comments` and
3
- * `POST /api/v1/context/comments/announcements`.
4
- *
5
- * **One client, three callers.** The `comments` verb, the MCP `pull` tool's comment read and
6
- * the session-start hook are three ways into the same two requests, and the
7
- * headers, the status handling and the response validation would otherwise be
8
- * three places to drift. The same reasoning as the guide-history client beside
9
- * it, and it takes its credentials directly for the same reason: this is a
10
- * read of what a person left, not a context-layer mutation, so it is not a
11
- * method on the context client.
12
- *
13
- * **Two requests because they are two acts.** Fetching bodies is a delivery
14
- * and the server counts it as one. Announcing prints a number and no bodies,
15
- * so it delivers nothing and is capped instead — per reader, per repo, on the
16
- * server, because a count kept in the checkout resets with the clone and a
17
- * count kept on the comment is shared by every reader.
18
- *
19
- * Responses go through the protocol's own parsers, so a drifting server
20
- * contract fails here rather than putting an unvalidated payload in front of
21
- * an agent.
22
- */
23
- import { type AnnounceItemCommentsResponse, type CommentEvidenceResponse, type HarnessId, type ItemCommentsResponse, type ResolveItemCommentResponse } from '@mossbear/protocol';
1
+ /** Counted announcements; comment bodies, evidence and other writes live on ContextClient. */
2
+ import { type AnnounceItemCommentsResponse } from '@mossbear/protocol';
24
3
  export type ArtifactCommentsRequestOptions = {
25
4
  dashboardUrl: string;
26
5
  token: string;
@@ -55,59 +34,6 @@ export type AnnounceArtifactCommentsOptions = ArtifactCommentsRequestOptions & {
55
34
  */
56
35
  projectId: string;
57
36
  };
58
- /**
59
- * Every open comment waiting for this reader in this repo.
60
- *
61
- * A deliberate read, so nothing about it is capped — and the server counts it
62
- * as a delivery, which is what lets a comment's author tell an ignored request
63
- * from an undelivered one.
64
- */
65
- export declare function fetchArtifactComments(options: ArtifactCommentsRequestOptions): Promise<ItemCommentsResponse>;
66
- /**
67
- * The evidence behind one Mossbear comment this reader was handed: its claim,
68
- * prediction and cited sessions.
69
- *
70
- * Takes the same bundles the comment read does, because the server finds the
71
- * comment through that read: evidence exists here only for a comment
72
- * `fetchArtifactComments` would return. A read, and not a delivery.
73
- */
74
- export declare function fetchCommentEvidence(options: Pick<ArtifactCommentsRequestOptions, 'dashboardUrl' | 'token' | 'fetchImpl'> & {
75
- id: string;
76
- bundleIds: readonly string[];
77
- /**
78
- * This repo's committed `project.id`, when it has one. An edit drafted
79
- * from one repo's sessions is withheld from a read that declares no repo,
80
- * so without it that edit's evidence could never be read.
81
- */
82
- projectId?: string | null;
83
- /** Defaults to the running CLI's own version. */
84
- cliVersion?: string;
85
- }): Promise<CommentEvidenceResponse>;
86
- /** Resolve one listed comment and leave the agent's account of its change. */
87
- export declare function resolveArtifactComment(options: Pick<ArtifactCommentsRequestOptions, 'dashboardUrl' | 'token' | 'fetchImpl'> & {
88
- id: string;
89
- note: string;
90
- bundleIds: readonly string[];
91
- /**
92
- * The artifact the comment is on. With it, the comment is found among that
93
- * artifact's open comments, as its comments read listed them, and
94
- * `bundleIds` is not consulted.
95
- */
96
- artifactId?: string;
97
- /** This repo's committed `project.id`, so its own repo-scoped comments resolve. */
98
- projectId?: string | null;
99
- /** Defaults to the running CLI's own version, so a listed draft resolves. */
100
- cliVersion?: string;
101
- /**
102
- * The agent session resolving it, so its note is named after that session.
103
- * Left out when the harness did not say which session this is.
104
- */
105
- agent?: {
106
- sessionId: string;
107
- harness: HarnessId;
108
- model?: string;
109
- };
110
- }): Promise<ResolveItemCommentResponse>;
111
37
  /**
112
38
  * Ask how many comments are waiting, and be counted as having said so.
113
39
  *
@@ -115,7 +41,7 @@ export declare function resolveArtifactComment(options: Pick<ArtifactCommentsReq
115
41
  * is how many were still under the per-repo cap, and it is what decides
116
42
  * whether to say anything at all. Zero means this reader has already been told
117
43
  * about every one of them as often as the cap allows — the comments are still
118
- * there, and `fetchArtifactComments` is where they still are.
44
+ * there, and `ContextClient.fetchArtifactComments` is where they still are.
119
45
  */
120
46
  export declare function announceArtifactComments(options: AnnounceArtifactCommentsOptions): Promise<AnnounceItemCommentsResponse>;
121
47
  //# sourceMappingURL=artifact-comments-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"artifact-comments-client.d.ts","sourceRoot":"","sources":["../../src/artifacts/artifact-comments-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAKL,KAAK,4BAA4B,EACjC,KAAK,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AAE,SAAS,MAAM,EAAE,CAAA;IAC5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,SAAS,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAClE,GACA,OAAO,CAAC,0BAA0B,CAAC,CAsBrC;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,4BAA4B,CAAC,CA2BvC"}
1
+ {"version":3,"file":"artifact-comments-client.d.ts","sourceRoot":"","sources":["../../src/artifacts/artifact-comments-client.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,oBAAoB,CAAA;AAO3B,MAAM,MAAM,8BAA8B,GAAG;IAC3C,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb;;;;;;;OAOG;IACH,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,+BAA+B,GAAG,8BAA8B,GAAG;IAC7E;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,4BAA4B,CAAC,CA2BvC"}
@@ -1,109 +1,9 @@
1
- /**
2
- * The CLI's read of the comment channel: `GET /api/v1/context/comments` and
3
- * `POST /api/v1/context/comments/announcements`.
4
- *
5
- * **One client, three callers.** The `comments` verb, the MCP `pull` tool's comment read and
6
- * the session-start hook are three ways into the same two requests, and the
7
- * headers, the status handling and the response validation would otherwise be
8
- * three places to drift. The same reasoning as the guide-history client beside
9
- * it, and it takes its credentials directly for the same reason: this is a
10
- * read of what a person left, not a context-layer mutation, so it is not a
11
- * method on the context client.
12
- *
13
- * **Two requests because they are two acts.** Fetching bodies is a delivery
14
- * and the server counts it as one. Announcing prints a number and no bodies,
15
- * so it delivers nothing and is capped instead — per reader, per repo, on the
16
- * server, because a count kept in the checkout resets with the clone and a
17
- * count kept on the comment is shared by every reader.
18
- *
19
- * Responses go through the protocol's own parsers, so a drifting server
20
- * contract fails here rather than putting an unvalidated payload in front of
21
- * an agent.
22
- */
23
- import { parseAnnounceItemCommentsResponse, parseCommentEvidenceResponse, parseItemCommentsResponse, parseResolveItemCommentResponse, } from '@mossbear/protocol';
1
+ /** Counted announcements; comment bodies, evidence and other writes live on ContextClient. */
2
+ import { parseAnnounceItemCommentsResponse, } from '@mossbear/protocol';
24
3
  import { dashboardHttpError } from '../dashboard-error.js';
25
4
  import { fetchWithRetry } from '../http-retry.js';
26
5
  import { trimTrailingSlashes } from '../url.js';
27
6
  import { CLI_VERSION } from '../version.js';
28
- /**
29
- * Every open comment waiting for this reader in this repo.
30
- *
31
- * A deliberate read, so nothing about it is capped — and the server counts it
32
- * as a delivery, which is what lets a comment's author tell an ignored request
33
- * from an undelivered one.
34
- */
35
- export async function fetchArtifactComments(options) {
36
- // Answered without a round trip rather than as an empty request: a repo that
37
- // subscribes to nothing has no comments about its context, and that is a state
38
- // rather than something the server has to be asked about.
39
- if (options.bundleIds.length === 0)
40
- return { comments: [] };
41
- const params = new URLSearchParams({ bundles: options.bundleIds.join(',') });
42
- if (options.since)
43
- params.set('since', options.since);
44
- if (options.projectId)
45
- params.set('project', options.projectId);
46
- // The server lists Mossbear's findings only to a release that can tell one
47
- // from a person's request, so it must know which release is asking.
48
- params.set('cli', options.cliVersion ?? CLI_VERSION);
49
- const url = `${commentsBase(options.dashboardUrl)}?${params.toString()}`;
50
- const fetchImpl = options.fetchImpl ?? fetch;
51
- const response = await fetchImpl(url, {
52
- headers: { Authorization: `Bearer ${options.token}` },
53
- });
54
- if (!response.ok)
55
- throw await refusal(response);
56
- return parseItemCommentsResponse(await response.json());
57
- }
58
- /**
59
- * The evidence behind one Mossbear comment this reader was handed: its claim,
60
- * prediction and cited sessions.
61
- *
62
- * Takes the same bundles the comment read does, because the server finds the
63
- * comment through that read: evidence exists here only for a comment
64
- * `fetchArtifactComments` would return. A read, and not a delivery.
65
- */
66
- export async function fetchCommentEvidence(options) {
67
- const params = new URLSearchParams({
68
- id: options.id,
69
- bundles: options.bundleIds.join(','),
70
- });
71
- if (options.projectId)
72
- params.set('project', options.projectId);
73
- // The server withholds a citation kind a CLI too old to parse it would reject
74
- // the whole response for, so it must know which release is asking.
75
- params.set('cli', options.cliVersion ?? CLI_VERSION);
76
- const fetchImpl = options.fetchImpl ?? fetch;
77
- const response = await fetchImpl(`${commentsBase(options.dashboardUrl)}/evidence?${params.toString()}`, { headers: { Authorization: `Bearer ${options.token}` } });
78
- if (!response.ok)
79
- throw await refusal(response);
80
- return parseCommentEvidenceResponse(await response.json());
81
- }
82
- /** Resolve one listed comment and leave the agent's account of its change. */
83
- export async function resolveArtifactComment(options) {
84
- const fetchImpl = options.fetchImpl ?? fetch;
85
- const response = await fetchImpl(`${commentsBase(options.dashboardUrl)}/resolve`, {
86
- method: 'POST',
87
- headers: {
88
- Authorization: `Bearer ${options.token}`,
89
- 'Content-Type': 'application/json',
90
- },
91
- body: JSON.stringify({
92
- id: options.id,
93
- note: options.note,
94
- bundleIds: [...options.bundleIds],
95
- ...(options.artifactId ? { artifactId: options.artifactId } : {}),
96
- ...(options.projectId ? { projectId: options.projectId } : {}),
97
- cliVersion: options.cliVersion ?? CLI_VERSION,
98
- ...(options.agent
99
- ? { agent: { ...options.agent, cliVersion: options.cliVersion ?? CLI_VERSION } }
100
- : {}),
101
- }),
102
- });
103
- if (!response.ok)
104
- throw await refusal(response);
105
- return parseResolveItemCommentResponse(await response.json());
106
- }
107
7
  /**
108
8
  * Ask how many comments are waiting, and be counted as having said so.
109
9
  *
@@ -111,7 +11,7 @@ export async function resolveArtifactComment(options) {
111
11
  * is how many were still under the per-repo cap, and it is what decides
112
12
  * whether to say anything at all. Zero means this reader has already been told
113
13
  * about every one of them as often as the cap allows — the comments are still
114
- * there, and `fetchArtifactComments` is where they still are.
14
+ * there, and `ContextClient.fetchArtifactComments` is where they still are.
115
15
  */
116
16
  export async function announceArtifactComments(options) {
117
17
  if (options.bundleIds.length === 0)
@@ -1 +1 @@
1
- {"version":3,"file":"artifact-comments-client.js","sourceRoot":"","sources":["../../src/artifacts/artifact-comments-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,iCAAiC,EACjC,4BAA4B,EAC5B,yBAAyB,EACzB,+BAA+B,GAOhC,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAsC3C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAuC;IAEvC,6EAA6E;IAC7E,+EAA+E;IAC/E,0DAA0D;IAC1D,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;IAE3D,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,OAAO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AA;IAC5C,2EAA2E;IAC3E,0EAA0E;IAC1E,MAAM,QAAQ,GAAG,MAAM,cAAc,CACnC,SAAS,EACT,GAAG,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,EACrD;QACE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,OAAO,CAAC,KAAK,EAAE;YACxC,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;YACjC,oEAAoE;YACpE,wBAAwB;YACxB,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,WAAW;SAC9C,CAAC;KACH,EACD,EAAE,WAAW,EAAE,CAAC,EAAE,CACnB,CAAA;IACD,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC/C,OAAO,iCAAiC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;AACjE,CAAC;AAED,SAAS,YAAY,CAAC,YAAoB;IACxC,OAAO,GAAG,mBAAmB,CAAC,YAAY,CAAC,0BAA0B,CAAA;AACvE,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,OAAO,CAAC,QAAkB;IACvC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;IAClD,OAAO,kBAAkB,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAC9D,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { ContextClient } from '../mcp/client.js';
2
+ import type { SubscribedBundle, SubscriptionTarget } from './sync-artifacts.js';
3
+ import type { ContextItem } from '@mossbear/protocol';
4
+ /** A failed or unavailable inventory is never evidence that a bundle is empty. */
5
+ export type AcquiredBundle = {
6
+ /** Addressed by id; `bundle` below is the slug the directory is named for. */
7
+ bundleId: string;
8
+ bundle: string;
9
+ dir: string;
10
+ /** The bundle's home repo, or null when nothing claims it. */
11
+ home: string | null;
12
+ /** Guide ids this subscriber switched off; empty when none. */
13
+ muted: ReadonlySet<string>;
14
+ /** Ids switched off for the account target only; empty when none. */
15
+ accountMuted: ReadonlySet<string>;
16
+ /** Reached by publication rather than membership: nothing is pushed back. */
17
+ readOnly: boolean;
18
+ /** Published: its skills are copied into every skills folder a wired harness reads. */
19
+ published: boolean;
20
+ /**
21
+ * The delivery targets this bundle's subscriptions asked for — never empty:
22
+ * a bundle with no recorded target still has one untargeted delivery, which
23
+ * routes on each item's own root.
24
+ */
25
+ targets: readonly SubscriptionTarget[];
26
+ } & AcquiredInventory;
27
+ /** Completeness describes the raw read, before tombstones are filtered. */
28
+ type AcquiredInventory = {
29
+ inventory: 'complete' | 'truncated';
30
+ items: readonly ContextItem[];
31
+ untrustedNote: string | null;
32
+ error: undefined;
33
+ } | {
34
+ inventory: 'failed' | 'unavailable';
35
+ items: readonly [];
36
+ untrustedNote: null;
37
+ error: string;
38
+ };
39
+ /**
40
+ * Pull all subscriptions in order. Discard partial pages on failure, establish
41
+ * completeness before filtering tombstones, and retain newest-first delivery.
42
+ * No local files, mappings or cache evidence are changed here.
43
+ */
44
+ export declare function acquireSubscribedArtifacts(input: {
45
+ client: ContextClient;
46
+ bundles: readonly SubscribedBundle[];
47
+ root: string;
48
+ comments: 'deliver' | 'none';
49
+ }): Promise<AcquiredBundle[]>;
50
+ export {};
51
+ //# sourceMappingURL=sync-acquisition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-acquisition.d.ts","sourceRoot":"","sources":["../../src/artifacts/sync-acquisition.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAA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 @@
1
+ /** Sequential remote acquisition and subscription normalization, before any planning. */
2
+ import { defaultPullDir } from '../context/pull.js';
3
+ import { ContextHttpError } from '../dashboard-error.js';
4
+ import { errText } from '../err-text.js';
5
+ import { readBundlePages } from './published-artifacts.js';
6
+ /**
7
+ * Pull all subscriptions in order. Discard partial pages on failure, establish
8
+ * completeness before filtering tombstones, and retain newest-first delivery.
9
+ * No local files, mappings or cache evidence are changed here.
10
+ */
11
+ export async function acquireSubscribedArtifacts(input) {
12
+ const { client, bundles, root, comments } = input;
13
+ const pulled = [];
14
+ for (const subscribed of bundles) {
15
+ let outcome;
16
+ try {
17
+ // **Paged to the end**, so a bundle whose tombstones push it past one
18
+ // read is still delivered whole and still retires what left it. Against
19
+ // a server that cannot page this is the one read it always was.
20
+ //
21
+ // Two limits a multi-request read has that one read did not. Each page
22
+ // counts its comments as delivered when it is served, so a read that
23
+ // fails on a later page has counted comments nobody is shown. And the
24
+ // pages are not one snapshot: a row created mid-read behind the cursor is
25
+ // missed while the read still counts as complete. That can retire an
26
+ // unedited file whose item was just re-keyed — only ever a file this sync
27
+ // wrote and nobody has changed since, delivered again on the next pass.
28
+ const read = await readBundlePages(client, {
29
+ bundleId: subscribed.id,
30
+ ...(comments === 'none' ? { comments: 'none' } : {}),
31
+ });
32
+ // **Newest first, whichever way it was read.** Pages arrive in id order,
33
+ // and this phase was written against the unpaged read's order: two new
34
+ // pathless items with one name settle which takes `<name>.md` by which is
35
+ // planned first, and the per-doc outcomes are reported in this order.
36
+ // Sorting keeps both as they were for distinct timestamps; ties, which
37
+ // the unpaged read left in the server's own order, stay in id order. An
38
+ // old server's page is already newest first and keeps its order exactly.
39
+ const response = read.pages
40
+ .flatMap((page) => page.artifacts)
41
+ .sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
42
+ // The ceiling counts tombstones too. Filtering first could turn a short
43
+ // inventory into apparent authority to retire still-live local files.
44
+ outcome = {
45
+ inventory: read.atCeiling ? 'truncated' : 'complete',
46
+ items: response.filter((item) => item.removed !== true),
47
+ untrustedNote: read.pages.find((page) => page.untrusted)?.untrusted?.note ?? null,
48
+ error: undefined,
49
+ };
50
+ }
51
+ catch (err) {
52
+ const unavailable = err instanceof ContextHttpError && err.status === 404;
53
+ // Discard every partial page. Unavailability is not a complete empty read;
54
+ // both failure outcomes retain files and withhold retirement authority.
55
+ outcome = {
56
+ inventory: unavailable ? 'unavailable' : 'failed',
57
+ items: [],
58
+ untrustedNote: null,
59
+ error: unavailable
60
+ ? `bundle no longer exists on the server — remove "${subscribed.slug}" from "bundles" in .mossbear/config.json to stop syncing it (local files are left in place)`
61
+ : errText(err),
62
+ };
63
+ }
64
+ pulled.push({
65
+ bundleId: subscribed.id,
66
+ bundle: subscribed.dirName,
67
+ dir: defaultPullDir(subscribed.dirName, root),
68
+ // Absent or empty reads as one untargeted delivery rather than none: a
69
+ // caller that does not know the scopes (`mossbear pull`, the interactive
70
+ // picker) still delivers, and it delivers the way it always has.
71
+ targets: subscribed.targets && subscribed.targets.length > 0
72
+ ? subscribed.targets
73
+ : [{ scope: 'repo', deliver: null }],
74
+ home: subscribed.home ?? null,
75
+ muted: new Set(subscribed.muted ?? []),
76
+ accountMuted: new Set(subscribed.accountMuted ?? []),
77
+ readOnly: subscribed.readOnly === true,
78
+ published: subscribed.published === true || subscribed.readOnly === true,
79
+ ...outcome,
80
+ });
81
+ }
82
+ return pulled;
83
+ }
84
+ //# sourceMappingURL=sync-acquisition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-acquisition.js","sourceRoot":"","sources":["../../src/artifacts/sync-acquisition.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AA6C1D;;;;GA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