@atrib/summarize 0.3.0 → 0.3.2

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/LICENSE CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  Apache License
2
3
  Version 2.0, January 2004
3
4
  http://www.apache.org/licenses/
@@ -32,9 +33,10 @@
32
33
  not limited to compiled object code, generated documentation,
33
34
  and conversions to other media types.
34
35
 
35
- "Work" shall mean the work of authorship made available under
36
- the License, as indicated by a copyright notice that is included in
37
- or attached to the work (an example is provided in the Appendix below).
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
38
40
 
39
41
  "Derivative Works" shall mean any work, whether in Source or Object
40
42
  form, that is based on (or derived from) the Work and for which the
@@ -44,21 +46,23 @@
44
46
  separable from, or merely link (or bind by name) to the interfaces of,
45
47
  the Work and Derivative Works thereof.
46
48
 
47
- "Contribution" shall mean, as submitted to the Licensor for inclusion
48
- in the Work by the copyright owner or by an individual or Legal Entity
49
- authorized to submit on behalf of the copyright owner. For the purposes
50
- of this definition, "submitted" means any form of electronic, verbal,
51
- or written communication sent to the Licensor or its representatives,
52
- including but not limited to communication on electronic mailing lists,
53
- source code control systems, and issue tracking systems that are managed
54
- by, or on behalf of, the Licensor for the purpose of discussing and
55
- improving the Work, but excluding communication that is conspicuously
56
- marked or otherwise designated in writing by the copyright owner as
57
- "Not a Contribution."
58
-
59
- "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
- whom a Contribution has been received by the Licensor and subsequently
61
- incorporated within the Work.
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
62
66
 
63
67
  2. Grant of Copyright License. Subject to the terms and conditions of
64
68
  this License, each Contributor hereby grants to You a perpetual,
@@ -76,19 +80,20 @@
76
80
  by such Contributor that are necessarily infringed by their
77
81
  Contribution(s) alone or by combination of their Contribution(s)
78
82
  with the Work to which such Contribution(s) was submitted. If You
79
- institute patent litigation against any entity (including a cross-claim
80
- or counterclaim in a lawsuit) alleging that the Work or a Contribution
81
- incorporated within the Work constitutes direct or contributory patent
82
- infringement, then any patent licenses granted to You under this License
83
- for that Work shall terminate as of the date such litigation is filed.
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
84
89
 
85
90
  4. Redistribution. You may reproduce and distribute copies of the
86
91
  Work or Derivative Works thereof in any medium, with or without
87
92
  modifications, and in Source or Object form, provided that You
88
93
  meet the following conditions:
89
94
 
90
- (a) You must give any other recipients of the Work or Derivative Works
91
- a copy of this License; and
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
92
97
 
93
98
  (b) You must cause any modified files to carry prominent notices
94
99
  stating that You changed the files; and
@@ -100,8 +105,10 @@
100
105
  the Derivative Works; and
101
106
 
102
107
  (d) If the Work includes a "NOTICE" text file as part of its
103
- distribution, You must include a readable copy of the attribution
104
- notices contained within such NOTICE file, in at least one
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
105
112
  of the following places: within a NOTICE text file distributed
106
113
  as part of the Derivative Works; within the Source form or
107
114
  documentation, if provided along with the Derivative Works; or,
@@ -114,9 +121,12 @@
114
121
  that such additional attribution notices cannot be construed
115
122
  as modifying the License.
116
123
 
117
- You may add Your own license statement for Your modifications and
118
- may provide additional grant of rights to use, modify, or distribute
119
- those modifications in accordance with this License.
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
120
130
 
121
131
  5. Submission of Contributions. Unless You explicitly state otherwise,
122
132
  any Contribution intentionally submitted for inclusion in the Work
@@ -138,7 +148,7 @@
138
148
  implied, including, without limitation, any warranties or conditions
139
149
  of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
140
150
  PARTICULAR PURPOSE. You are solely responsible for determining the
141
- appropriateness of using or reproducing the Work and assume any
151
+ appropriateness of using or redistributing the Work and assume any
142
152
  risks associated with Your exercise of permissions under this License.
143
153
 
144
154
  8. Limitation of Liability. In no event and under no legal theory,
@@ -146,12 +156,12 @@
146
156
  unless required by applicable law (such as deliberate and grossly
147
157
  negligent acts) or agreed to in writing, shall any Contributor be
148
158
  liable to You for damages, including any direct, indirect, special,
149
- incidental, or exemplary damages of any character arising as a
159
+ incidental, or consequential damages of any character arising as a
150
160
  result of this License or out of the use or inability to use the
151
161
  Work (including but not limited to damages for loss of goodwill,
152
- work stoppage, computer failure or malfunction, or all other
153
- commercial damages or losses), even if such Contributor has been
154
- advised of the possibility of such damages.
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
155
165
 
156
166
  9. Accepting Warranty or Additional Liability. While redistributing
157
167
  the Work or Derivative Works thereof, You may choose to offer,
@@ -172,8 +182,24 @@
172
182
  boilerplate notice, with the fields enclosed by brackets "[]"
173
183
  replaced with your own identifying information. (Don't include
174
184
  the brackets!) The text should be enclosed in the appropriate
175
- comment syntax for the file format in question. Also, an optional
176
- "Statement of Purpose" appears after the copyright notice.
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
177
203
 
178
204
  Copyright 2025-2026 Atrib contributors
179
205
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @atrib/summarize
2
2
 
3
- MCP server exposing the `summarize` tool synthesizes a narrative across N records using an OpenAI-compatible LLM.
3
+ MCP server exposing the `summarize` tool, synthesizes a narrative across N records using an OpenAI-compatible LLM.
4
4
 
5
5
  Closes the consumer-side cognitive-loop primitive companion to `atrib-trace`: trace returns the causal chain (structural); summarize returns the synthesized meaning across the chain (semantic). Both read the same local mirror including the optional `_local` sidecar.
6
6
 
@@ -39,13 +39,13 @@ OpenAI-compatible HTTP. Defaults to NVIDIA NIM with `qwen/qwen3.5-397b-a17b`. Ov
39
39
  | `ATRIB_SUMMARIZE_TEMPERATURE` | `0.3` |
40
40
  | `ATRIB_SUMMARIZE_TIMEOUT_MS` | `120000` |
41
41
 
42
- Without an API key, the tool returns a warnings-only response per the [§5.8](../../atrib-spec.md#58-degradation-contract) graceful-degradation contract.
42
+ Without an API key, the tool returns a warnings-only response per the [§5.8](https://github.com/creatornader/atrib/blob/main/atrib-spec.md#58-degradation-contract) graceful-degradation contract.
43
43
 
44
44
  ## Reads
45
45
 
46
46
  Same as `@atrib/trace`: every `*.jsonl` mirror under `~/.atrib/records/` (override via `ATRIB_RECORDS_DIR`). Tolerates both legacy bare-record and current envelope shapes.
47
47
 
48
- When a record lacks a `_local` sidecar (legacy entry), the prompt includes a marker telling the LLM the input is impoverished only event_type + cryptographic metadata is available so the synthesis can be honest about gaps. The output reports `records_with_sidecar` and `records_without_sidecar` counts so callers know how rich the input was.
48
+ When a record lacks a `_local` sidecar (legacy entry), the prompt includes a marker telling the LLM the input is impoverished, only event_type + cryptographic metadata is available, so the synthesis can be honest about gaps. The output reports `records_with_sidecar` and `records_without_sidecar` counts so callers know how rich the input was.
49
49
 
50
50
  ## Behaviors
51
51
 
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
18
18
  import { z } from 'zod';
19
+ import { resolveEnvContextId } from '@atrib/mcp';
19
20
  import { loadAllRecords } from './storage.js';
20
21
  import { callLlm, resolveLlmConfig } from './llm.js';
21
22
  import { buildSystemPrompt, buildUserMessage } from './prompt.js';
@@ -31,7 +32,7 @@ const SummarizeInput = z.object({
31
32
  'general "summarize what the agent did and why" focus.'),
32
33
  max_records: z.number().int().min(1).max(200).optional().describe('Cap on records fed to the LLM, default 50. Records beyond the cap (after ' +
33
34
  'sorting by timestamp ascending) are skipped and counted in records_skipped. ' +
34
- 'Increase carefully large prompts run slower + cost more + risk model ' +
35
+ 'Increase carefully, large prompts run slower + cost more + risk model ' +
35
36
  'context limits.'),
36
37
  model: z.string().min(1).max(200).optional().describe('Override the configured model for this call. Format depends on provider ' +
37
38
  '(NVIDIA NIM uses e.g. "qwen/qwen3.5-397b-a17b"). Defaults to env ' +
@@ -59,14 +60,11 @@ export async function createAtribSummarizeServer() {
59
60
  async function handleSummarize(input) {
60
61
  const warnings = [];
61
62
  const maxRecords = input.max_records ?? 50;
62
- // ATRIB_CONTEXT_ID env-var default: when the caller omitted context_id
63
- // AND did not supply record_hashes, fall back to the env var if it
64
- // carries a valid 32-hex value. Lets Inspect-style harnesses scope
65
- // summarize to a per-arm context_id via the MCP env block (per D072's
66
- // per-arm isolation contract). Explicit input.context_id always wins.
67
- const envContextId = process.env['ATRIB_CONTEXT_ID'];
68
- const effectiveContextId = input.context_id ??
69
- (envContextId && HEX_32_PATTERN.test(envContextId) ? envContextId : undefined);
63
+ // Env-var context_id default: when the caller omitted context_id AND did
64
+ // not supply record_hashes, fall back to @atrib/mcp's resolveEnvContextId
65
+ // (D078 + D083 precedence: ATRIB_CONTEXT_ID, then a registered harness
66
+ // env var like CLAUDE_CODE_SESSION_ID). Explicit input.context_id wins.
67
+ const effectiveContextId = input.context_id ?? resolveEnvContextId();
70
68
  const effective = {
71
69
  ...input,
72
70
  ...(effectiveContextId ? { context_id: effectiveContextId } : {}),
@@ -166,6 +164,6 @@ function emptyOutput(warnings) {
166
164
  warnings,
167
165
  };
168
166
  }
169
- // Test-only export lets unit tests exercise the assembly logic without
167
+ // Test-only export, lets unit tests exercise the assembly logic without
170
168
  // going through the McpServer transport.
171
169
  export const __test_only__ = { handleSummarize, selectRecords };
package/dist/prompt.js CHANGED
@@ -13,7 +13,7 @@ Your job: produce a coherent narrative across the records that surfaces:
13
13
  - Honest gaps (when records are impoverished, say so; do not invent semantics)
14
14
 
15
15
  Cite specific records by short hash (first 12 chars of record_hash) when making claims.
16
- Be concise. The reader is the same agent that signed these records assume they want to be reminded, not lectured.`;
16
+ Be concise. The reader is the same agent that signed these records, assume they want to be reminded, not lectured.`;
17
17
  export function buildSystemPrompt() {
18
18
  return SYSTEM_PROMPT;
19
19
  }
@@ -89,7 +89,7 @@ function renderRecord(r) {
89
89
  out.push(`result (truncated): ${JSON.stringify(sc.result).slice(0, 300)}`);
90
90
  }
91
91
  else {
92
- out.push('(no semantic sidecar available record predates local-mirror sidecar pattern; only cryptographic metadata is present)');
92
+ out.push('(no semantic sidecar available, record predates local-mirror sidecar pattern; only cryptographic metadata is present)');
93
93
  }
94
94
  return out.join('\n');
95
95
  }
package/dist/storage.d.ts CHANGED
@@ -15,7 +15,7 @@ export interface IndexedRecord {
15
15
  local?: SidecarPayload;
16
16
  }
17
17
  /**
18
- * Combined sidecar shape superset of every producer's local payload
18
+ * Combined sidecar shape, superset of every producer's local payload
19
19
  * (mcp-wrap writes toolName/args/result; atrib-emit writes content).
20
20
  */
21
21
  export interface SidecarPayload extends OnRecordSidecar {
package/dist/storage.js CHANGED
@@ -60,7 +60,7 @@ export function loadAllRecords(dir = RECORDS_DIR) {
60
60
  source: fname,
61
61
  };
62
62
  // Lift the `_local` sidecar onto the indexed record when present.
63
- // Legacy bare-record entries have no sidecar; that's OK consumers
63
+ // Legacy bare-record entries have no sidecar; that's OK, consumers
64
64
  // tolerate its absence.
65
65
  if (isEnvelope) {
66
66
  const sidecar = parsed._local;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atrib/summarize",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "MCP server for atrib. Synthesizes a narrative across N records via an OpenAI-compatible LLM so agents read context, not raw record bytes.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -11,13 +11,13 @@
11
11
  "dependencies": {
12
12
  "@modelcontextprotocol/sdk": "^1.29.0",
13
13
  "zod": "^3.25.76",
14
- "@atrib/mcp": "0.6.2"
14
+ "@atrib/mcp": "0.8.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@types/node": "^22.19.17",
18
- "tsx": "^4.21.0",
19
- "typescript": "^5.9.3",
20
- "vitest": "^3.2.4"
17
+ "@types/node": "^25.8.0",
18
+ "tsx": "^4.22.1",
19
+ "typescript": "^6.0.3",
20
+ "vitest": "^4.1.6"
21
21
  },
22
22
  "files": [
23
23
  "dist"
@@ -25,6 +25,11 @@
25
25
  "publishConfig": {
26
26
  "access": "public"
27
27
  },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/creatornader/atrib.git",
31
+ "directory": "services/atrib-summarize"
32
+ },
28
33
  "scripts": {
29
34
  "build": "rm -rf dist && tsc",
30
35
  "start": "node dist/main.js",