@clawtrail/context-graph-openclaw 0.1.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 (62) hide show
  1. package/README.md +252 -0
  2. package/dist/OpenClawAdapter.d.ts +75 -0
  3. package/dist/OpenClawAdapter.d.ts.map +1 -0
  4. package/dist/OpenClawAdapter.js +157 -0
  5. package/dist/OpenClawAdapter.js.map +1 -0
  6. package/dist/detectors/BuildDetector.d.ts +17 -0
  7. package/dist/detectors/BuildDetector.d.ts.map +1 -0
  8. package/dist/detectors/BuildDetector.js +98 -0
  9. package/dist/detectors/BuildDetector.js.map +1 -0
  10. package/dist/detectors/TestDetector.d.ts +19 -0
  11. package/dist/detectors/TestDetector.d.ts.map +1 -0
  12. package/dist/detectors/TestDetector.js +133 -0
  13. package/dist/detectors/TestDetector.js.map +1 -0
  14. package/dist/hooks/lifecycle.d.ts +29 -0
  15. package/dist/hooks/lifecycle.d.ts.map +1 -0
  16. package/dist/hooks/lifecycle.js +26 -0
  17. package/dist/hooks/lifecycle.js.map +1 -0
  18. package/dist/hooks/toolCall.d.ts +18 -0
  19. package/dist/hooks/toolCall.d.ts.map +1 -0
  20. package/dist/hooks/toolCall.js +34 -0
  21. package/dist/hooks/toolCall.js.map +1 -0
  22. package/dist/index.d.ts +30 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +29 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/mappers/MapperRegistry.d.ts +29 -0
  27. package/dist/mappers/MapperRegistry.d.ts.map +1 -0
  28. package/dist/mappers/MapperRegistry.js +29 -0
  29. package/dist/mappers/MapperRegistry.js.map +1 -0
  30. package/dist/mappers/fallback.d.ts +11 -0
  31. package/dist/mappers/fallback.d.ts.map +1 -0
  32. package/dist/mappers/fallback.js +25 -0
  33. package/dist/mappers/fallback.js.map +1 -0
  34. package/dist/mappers/fs.d.ts +7 -0
  35. package/dist/mappers/fs.d.ts.map +1 -0
  36. package/dist/mappers/fs.js +51 -0
  37. package/dist/mappers/fs.js.map +1 -0
  38. package/dist/mappers/git.d.ts +10 -0
  39. package/dist/mappers/git.d.ts.map +1 -0
  40. package/dist/mappers/git.js +79 -0
  41. package/dist/mappers/git.js.map +1 -0
  42. package/dist/mappers/shell.d.ts +16 -0
  43. package/dist/mappers/shell.d.ts.map +1 -0
  44. package/dist/mappers/shell.js +75 -0
  45. package/dist/mappers/shell.js.map +1 -0
  46. package/dist/rules/openclaw-rules.d.ts +15 -0
  47. package/dist/rules/openclaw-rules.d.ts.map +1 -0
  48. package/dist/rules/openclaw-rules.js +175 -0
  49. package/dist/rules/openclaw-rules.js.map +1 -0
  50. package/dist/tools/status.d.ts +14 -0
  51. package/dist/tools/status.d.ts.map +1 -0
  52. package/dist/tools/status.js +21 -0
  53. package/dist/tools/status.js.map +1 -0
  54. package/dist/tools/summarize.d.ts +17 -0
  55. package/dist/tools/summarize.d.ts.map +1 -0
  56. package/dist/tools/summarize.js +30 -0
  57. package/dist/tools/summarize.js.map +1 -0
  58. package/dist/util/hash.d.ts +23 -0
  59. package/dist/util/hash.d.ts.map +1 -0
  60. package/dist/util/hash.js +83 -0
  61. package/dist/util/hash.js.map +1 -0
  62. package/package.json +48 -0
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Shell mapper — maps bash/shell tool calls to SHELL_COMMAND events,
3
+ * promoting to TEST_RUN or BUILD_RUN when detected.
4
+ */
5
+ import type { EventMapper, MappedEvent } from './MapperRegistry.js';
6
+ import { TestDetector } from '../detectors/TestDetector.js';
7
+ import { BuildDetector } from '../detectors/BuildDetector.js';
8
+ export declare class ShellMapper implements EventMapper {
9
+ toolNames: string[];
10
+ private testDetector;
11
+ private buildDetector;
12
+ constructor(testDetector?: TestDetector, buildDetector?: BuildDetector);
13
+ mapStart(toolName: string, params: Record<string, unknown>): MappedEvent;
14
+ mapEnd(toolName: string, params: Record<string, unknown>, result: Record<string, unknown> | null, error?: Error): MappedEvent;
15
+ }
16
+ //# sourceMappingURL=shell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/mappers/shell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAI9D,qBAAa,WAAY,YAAW,WAAW;IAC7C,SAAS,WAAqB;IAE9B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,aAAa,CAAgB;gBAEzB,YAAY,CAAC,EAAE,YAAY,EAAE,aAAa,CAAC,EAAE,aAAa;IAKtE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW;IAWxE,MAAM,CACJ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACtC,KAAK,CAAC,EAAE,KAAK,GACZ,WAAW;CAsDf"}
@@ -0,0 +1,75 @@
1
+ import { TestDetector } from '../detectors/TestDetector.js';
2
+ import { BuildDetector } from '../detectors/BuildDetector.js';
3
+ import { hashCommand, extractBaseCommand } from '../util/hash.js';
4
+ import { sha256 } from '../util/hash.js';
5
+ export class ShellMapper {
6
+ toolNames = ['bash', 'shell'];
7
+ testDetector;
8
+ buildDetector;
9
+ constructor(testDetector, buildDetector) {
10
+ this.testDetector = testDetector ?? new TestDetector();
11
+ this.buildDetector = buildDetector ?? new BuildDetector();
12
+ }
13
+ mapStart(toolName, params) {
14
+ const cmd = (params.command || params.cmd || '');
15
+ return {
16
+ type: 'SHELL_COMMAND',
17
+ data: {
18
+ cmd_hash: hashCommand(cmd),
19
+ cmd_display: extractBaseCommand(cmd),
20
+ },
21
+ };
22
+ }
23
+ mapEnd(toolName, params, result, error) {
24
+ const cmd = (params.command || params.cmd || '');
25
+ const exitCode = (result?.exitCode ?? result?.exit_code ?? (error ? 1 : 0));
26
+ const stdout = (result?.stdout || '');
27
+ const stderr = (result?.stderr || '');
28
+ // Try to promote to TEST_RUN
29
+ const testResult = this.testDetector.detect(cmd, stdout, stderr, exitCode);
30
+ if (testResult) {
31
+ return {
32
+ type: 'TEST_RUN',
33
+ data: {
34
+ framework: testResult.framework,
35
+ passed: testResult.passed,
36
+ failed: testResult.failed,
37
+ skipped: testResult.skipped,
38
+ duration_ms: testResult.durationMs,
39
+ report_hash: sha256(stdout),
40
+ cmd_hash: hashCommand(cmd),
41
+ cmd_display: extractBaseCommand(cmd),
42
+ exit_code: exitCode,
43
+ },
44
+ };
45
+ }
46
+ // Try to promote to BUILD_RUN
47
+ const buildResult = this.buildDetector.detect(cmd, stdout, stderr, exitCode);
48
+ if (buildResult) {
49
+ return {
50
+ type: 'BUILD_RUN',
51
+ data: {
52
+ tool: buildResult.tool,
53
+ exit_code: exitCode,
54
+ errors_count: buildResult.errorsCount,
55
+ warnings_count: buildResult.warningsCount,
56
+ cmd_hash: hashCommand(cmd),
57
+ cmd_display: extractBaseCommand(cmd),
58
+ },
59
+ };
60
+ }
61
+ // Default: generic shell command
62
+ return {
63
+ type: 'SHELL_COMMAND',
64
+ data: {
65
+ cmd_hash: hashCommand(cmd),
66
+ cmd_display: extractBaseCommand(cmd),
67
+ cwd_hash: params.cwd ? sha256(params.cwd) : undefined,
68
+ exit_code: exitCode,
69
+ stdout_hash: sha256(stdout),
70
+ stderr_hash: sha256(stderr),
71
+ },
72
+ };
73
+ }
74
+ }
75
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/mappers/shell.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8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AAC,GAAG,CAAC;gBACpC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAa,CAAC,CAAC,CAAC,CAAC,SAAS;gBAC/D,SAAS,EAAE,QAAQ;gBACnB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC;gBAC3B,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC;aAC5B;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * OpenClaw-specific reasoning rules.
3
+ * Registered with the context-graph engine on adapter initialization.
4
+ */
5
+ import type { ReasoningRule } from '@clawtrail/context-graph';
6
+ export declare const CanFixBuild: ReasoningRule;
7
+ export declare const CanFixTests: ReasoningRule;
8
+ export declare const CanRunTests: ReasoningRule;
9
+ export declare const CanRecoverFromError: ReasoningRule;
10
+ export declare const CanWriteCode: ReasoningRule;
11
+ export declare const CanUseFramework: ReasoningRule;
12
+ export declare const CanUseTool: ReasoningRule;
13
+ /** All OpenClaw rules for easy registration */
14
+ export declare const openclawRules: ReasoningRule[];
15
+ //# sourceMappingURL=openclaw-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw-rules.d.ts","sourceRoot":"","sources":["../../src/rules/openclaw-rules.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,aAAa,EAAuC,MAAM,0BAA0B,CAAC;AAGnG,eAAO,MAAM,WAAW,EAAE,aA4BzB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,aA8BzB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,aAoBzB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,aAsBjC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,aAwB1B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,aAsB7B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,aAuBxB,CAAC;AAEF,+CAA+C;AAC/C,eAAO,MAAM,aAAa,EAAE,aAAa,EAQxC,CAAC"}
@@ -0,0 +1,175 @@
1
+ import { extensionToLanguage } from '../util/hash.js';
2
+ export const CanFixBuild = {
3
+ id: 'cg:CanFixBuild',
4
+ name: 'Can Fix Build',
5
+ description: 'Agent recovered a failing build within the same session',
6
+ evaluate(ctx) {
7
+ const buildRuns = ctx.events.filter((e) => e.type === 'BUILD_RUN');
8
+ const failed = buildRuns.filter((e) => e.status === 'FAILED' || e.data.exit_code !== 0);
9
+ const succeeded = buildRuns.filter((e) => e.status === 'SUCCEEDED' && e.data.exit_code === 0);
10
+ for (const fail of failed) {
11
+ const recovery = succeeded.find((s) => s.ts > fail.ts);
12
+ if (recovery) {
13
+ return [
14
+ {
15
+ claimType: 'cg:CanFixBuild',
16
+ confidence: 0.9,
17
+ scope: (fail.data.tool || recovery.data.tool),
18
+ evidenceHashes: [fail.event_hash, recovery.event_hash],
19
+ },
20
+ ];
21
+ }
22
+ }
23
+ return [];
24
+ },
25
+ };
26
+ export const CanFixTests = {
27
+ id: 'cg:CanFixTests',
28
+ name: 'Can Fix Tests',
29
+ description: 'Agent recovered failing tests within the same session',
30
+ evaluate(ctx) {
31
+ const testRuns = ctx.events.filter((e) => e.type === 'TEST_RUN');
32
+ const failed = testRuns.filter((e) => e.status === 'FAILED' ||
33
+ (e.data.failed > 0));
34
+ const succeeded = testRuns.filter((e) => e.status === 'SUCCEEDED' && e.data.failed === 0);
35
+ for (const fail of failed) {
36
+ const recovery = succeeded.find((s) => s.ts > fail.ts);
37
+ if (recovery) {
38
+ return [
39
+ {
40
+ claimType: 'cg:CanFixTests',
41
+ confidence: 0.9,
42
+ scope: (fail.data.framework || recovery.data.framework),
43
+ evidenceHashes: [fail.event_hash, recovery.event_hash],
44
+ },
45
+ ];
46
+ }
47
+ }
48
+ return [];
49
+ },
50
+ };
51
+ export const CanRunTests = {
52
+ id: 'cg:CanRunTests',
53
+ name: 'Can Run Tests',
54
+ description: 'Agent successfully ran tests multiple times',
55
+ evaluate(ctx) {
56
+ const successful = ctx.events.filter((e) => e.type === 'TEST_RUN' && e.status === 'SUCCEEDED');
57
+ if (successful.length < 3)
58
+ return [];
59
+ const frameworks = [...new Set(successful.map((e) => e.data.framework))];
60
+ return frameworks.map((fw) => ({
61
+ claimType: 'cg:CanRunTests',
62
+ confidence: 0.8,
63
+ scope: fw,
64
+ evidenceHashes: successful
65
+ .filter((e) => e.data.framework === fw)
66
+ .map((e) => e.event_hash),
67
+ }));
68
+ },
69
+ };
70
+ export const CanRecoverFromError = {
71
+ id: 'cg:CanRecoverFromError',
72
+ name: 'Can Recover From Error',
73
+ description: 'Agent recovered from an error by succeeding on the same artifact',
74
+ evaluate(ctx) {
75
+ const errors = ctx.events.filter((e) => e.type === 'ERROR');
76
+ for (const err of errors) {
77
+ const laterSuccess = ctx.events.find((e) => e.ts > err.ts && e.status === 'SUCCEEDED');
78
+ if (laterSuccess) {
79
+ return [
80
+ {
81
+ claimType: 'cg:CanRecoverFromError',
82
+ confidence: 0.85,
83
+ evidenceHashes: [err.event_hash, laterSuccess.event_hash],
84
+ },
85
+ ];
86
+ }
87
+ }
88
+ return [];
89
+ },
90
+ };
91
+ export const CanWriteCode = {
92
+ id: 'cg:CanWrite',
93
+ name: 'Can Write Code',
94
+ description: 'Agent wrote files in specific languages',
95
+ evaluate(ctx) {
96
+ const writes = ctx.events.filter((e) => e.type === 'FILE_WRITE' && e.status === 'SUCCEEDED');
97
+ const extCounts = new Map();
98
+ for (const w of writes) {
99
+ const ext = w.data.path_extension;
100
+ if (!ext)
101
+ continue;
102
+ if (!extCounts.has(ext))
103
+ extCounts.set(ext, []);
104
+ extCounts.get(ext).push(w.event_hash);
105
+ }
106
+ return [...extCounts.entries()].map(([ext, hashes]) => ({
107
+ claimType: 'cg:CanWrite',
108
+ confidence: 0.3,
109
+ scope: extensionToLanguage(ext),
110
+ evidenceHashes: hashes,
111
+ }));
112
+ },
113
+ };
114
+ export const CanUseFramework = {
115
+ id: 'cg:CanUseFramework',
116
+ name: 'Can Use Framework',
117
+ description: 'Agent used specific test/build frameworks',
118
+ evaluate(ctx) {
119
+ const frameworks = new Map();
120
+ for (const e of ctx.events) {
121
+ let fw;
122
+ if (e.type === 'TEST_RUN')
123
+ fw = e.data.framework;
124
+ if (e.type === 'BUILD_RUN')
125
+ fw = e.data.tool;
126
+ if (fw) {
127
+ if (!frameworks.has(fw))
128
+ frameworks.set(fw, []);
129
+ frameworks.get(fw).push(e.event_hash);
130
+ }
131
+ }
132
+ return [...frameworks.entries()].map(([fw, hashes]) => ({
133
+ claimType: 'cg:CanUseFramework',
134
+ confidence: 0.5,
135
+ scope: fw,
136
+ evidenceHashes: hashes,
137
+ }));
138
+ },
139
+ };
140
+ export const CanUseTool = {
141
+ id: 'cg:CanUseTool',
142
+ name: 'Can Use Tool',
143
+ description: 'Agent used specific shell tools',
144
+ evaluate(ctx) {
145
+ const tools = new Map();
146
+ for (const e of ctx.events) {
147
+ if (e.type === 'SHELL_COMMAND' || e.type === 'TOOL_CALL') {
148
+ const toolName = (e.data.cmd_display || e.data.tool);
149
+ if (toolName) {
150
+ const baseTool = toolName.split(' ')[0];
151
+ if (!tools.has(baseTool))
152
+ tools.set(baseTool, []);
153
+ tools.get(baseTool).push(e.event_hash);
154
+ }
155
+ }
156
+ }
157
+ return [...tools.entries()].map(([tool, hashes]) => ({
158
+ claimType: 'cg:CanUseTool',
159
+ confidence: 0.4,
160
+ scope: tool,
161
+ evidenceHashes: hashes,
162
+ }));
163
+ },
164
+ };
165
+ /** All OpenClaw rules for easy registration */
166
+ export const openclawRules = [
167
+ CanFixBuild,
168
+ CanFixTests,
169
+ CanRunTests,
170
+ CanRecoverFromError,
171
+ CanWriteCode,
172
+ CanUseFramework,
173
+ CanUseTool,
174
+ ];
175
+ //# sourceMappingURL=openclaw-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw-rules.js","sourceRoot":"","sources":["../../src/rules/openclaw-rules.ts"],"names":[],"mappings":"AAKA,OAAO,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agent-facing status tool — returns current session info.
3
+ */
4
+ import type { ContextGraph } from '@clawtrail/context-graph';
5
+ export interface StatusResult {
6
+ session_id?: string;
7
+ state?: string;
8
+ event_count?: number;
9
+ started_at?: string;
10
+ head_hash?: string | null;
11
+ status: string;
12
+ }
13
+ export declare function getStatus(cg: ContextGraph, sessionId: string | undefined): Promise<StatusResult>;
14
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/tools/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,SAAS,CAC7B,EAAE,EAAE,YAAY,EAChB,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,OAAO,CAAC,YAAY,CAAC,CAmBvB"}
@@ -0,0 +1,21 @@
1
+ export async function getStatus(cg, sessionId) {
2
+ if (!sessionId) {
3
+ return { status: 'no_active_session' };
4
+ }
5
+ try {
6
+ const session = await cg.getSession(sessionId);
7
+ const meta = session.getMeta();
8
+ return {
9
+ session_id: meta.session_id,
10
+ state: meta.state,
11
+ event_count: meta.event_count,
12
+ started_at: meta.started_at,
13
+ head_hash: meta.head_hash,
14
+ status: 'ok',
15
+ };
16
+ }
17
+ catch {
18
+ return { status: 'session_not_found' };
19
+ }
20
+ }
21
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/tools/status.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,EAAgB,EAChB,SAA6B;IAE7B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;IACzC,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAC/B,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI;SACb,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;IACzC,CAAC;AACH,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Agent-facing summarize tool — generates metrics and claims for the current session.
3
+ */
4
+ import type { ContextGraph } from '@clawtrail/context-graph';
5
+ export interface SummarizeResult {
6
+ session_id?: string;
7
+ metrics?: Record<string, unknown>;
8
+ claims?: Array<{
9
+ type: string;
10
+ confidence: number;
11
+ scope?: string;
12
+ }>;
13
+ error?: string;
14
+ status: string;
15
+ }
16
+ export declare function summarizeSession(cg: ContextGraph, sessionId: string | undefined): Promise<SummarizeResult>;
17
+ //# sourceMappingURL=summarize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarize.d.ts","sourceRoot":"","sources":["../../src/tools/summarize.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAyB,MAAM,0BAA0B,CAAC;AAEpF,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,YAAY,EAChB,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,OAAO,CAAC,eAAe,CAAC,CA6B1B"}
@@ -0,0 +1,30 @@
1
+ export async function summarizeSession(cg, sessionId) {
2
+ if (!sessionId) {
3
+ return { error: 'no_active_session', status: 'error' };
4
+ }
5
+ try {
6
+ // End session if still active
7
+ const session = await cg.getSession(sessionId);
8
+ if (session.getMeta().state === 'ACTIVE') {
9
+ await session.end({ status: 'COMPLETED' });
10
+ }
11
+ const summary = await cg.summarize(sessionId);
12
+ return {
13
+ session_id: sessionId,
14
+ metrics: summary.metrics,
15
+ claims: summary.claims.map((c) => ({
16
+ type: c.claimType,
17
+ confidence: c.confidence,
18
+ scope: c.scope,
19
+ })),
20
+ status: 'ok',
21
+ };
22
+ }
23
+ catch (err) {
24
+ return {
25
+ error: err instanceof Error ? err.message : String(err),
26
+ status: 'error',
27
+ };
28
+ }
29
+ }
30
+ //# sourceMappingURL=summarize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarize.js","sourceRoot":"","sources":["../../src/tools/summarize.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,EAAgB,EAChB,SAA6B;IAE7B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACzD,CAAC;IAED,IAAI,CAAC;QACH,8BAA8B;QAC9B,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAC/C,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACzC,MAAM,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC9C,OAAO;YACL,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,OAAO,CAAC,OAA6C;YAC9D,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAQ,EAAE,EAAE,CAAC,CAAC;gBACxC,IAAI,EAAE,CAAC,CAAC,SAAS;gBACjB,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,KAAK,EAAE,CAAC,CAAC,KAAK;aACf,CAAC,CAAC;YACH,MAAM,EAAE,IAAI;SACb,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;YACvD,MAAM,EAAE,OAAO;SAChB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Hashing helpers for the OpenClaw adapter.
3
+ * Delegates to @clawtrail/context-graph's Hasher.
4
+ */
5
+ import { sha256, hashContent } from '@clawtrail/context-graph';
6
+ export { sha256, hashContent };
7
+ /** Hash tool arguments (always hash, never store raw) */
8
+ export declare function hashArgs(args: unknown): string;
9
+ /** Hash command string */
10
+ export declare function hashCommand(cmd: string): string;
11
+ /** Hash file content or diff */
12
+ export declare function hashFileContent(content: string | Buffer): string;
13
+ /**
14
+ * Extract the base command name from a full command string.
15
+ * "npm test --coverage" → "npm test"
16
+ * "npx vitest run" → "npx vitest"
17
+ */
18
+ export declare function extractBaseCommand(cmd: string): string;
19
+ /** Get MIME type from file extension */
20
+ export declare function mimeFromExtension(ext: string): string;
21
+ /** Map file extension to language name */
22
+ export declare function extensionToLanguage(ext: string): string;
23
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/util/hash.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAE/B,yDAAyD;AACzD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAE9C;AAED,0BAA0B;AAC1B,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,gCAAgC;AAChC,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAYtD;AAED,wCAAwC;AACxC,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAoBrD;AAED,0CAA0C;AAC1C,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAsBvD"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Hashing helpers for the OpenClaw adapter.
3
+ * Delegates to @clawtrail/context-graph's Hasher.
4
+ */
5
+ import { sha256, hashContent } from '@clawtrail/context-graph';
6
+ export { sha256, hashContent };
7
+ /** Hash tool arguments (always hash, never store raw) */
8
+ export function hashArgs(args) {
9
+ return hashContent(args);
10
+ }
11
+ /** Hash command string */
12
+ export function hashCommand(cmd) {
13
+ return sha256(cmd);
14
+ }
15
+ /** Hash file content or diff */
16
+ export function hashFileContent(content) {
17
+ return sha256(typeof content === 'string' ? content : content.toString('utf-8'));
18
+ }
19
+ /**
20
+ * Extract the base command name from a full command string.
21
+ * "npm test --coverage" → "npm test"
22
+ * "npx vitest run" → "npx vitest"
23
+ */
24
+ export function extractBaseCommand(cmd) {
25
+ const parts = cmd.trim().split(/\s+/);
26
+ // For npx/pnpx/yarn, include the tool name
27
+ if (parts[0] === 'npx' || parts[0] === 'pnpx' || parts[0] === 'yarn') {
28
+ return parts.slice(0, 2).join(' ');
29
+ }
30
+ // For common multi-word commands: npm test, cargo build, go test, etc.
31
+ const twoWordCommands = ['npm', 'cargo', 'go', 'python', 'node', 'docker', 'git'];
32
+ if (twoWordCommands.includes(parts[0]) && parts.length > 1) {
33
+ return parts.slice(0, 2).join(' ');
34
+ }
35
+ return parts[0];
36
+ }
37
+ /** Get MIME type from file extension */
38
+ export function mimeFromExtension(ext) {
39
+ const mimeMap = {
40
+ '.ts': 'text/typescript',
41
+ '.tsx': 'text/typescript',
42
+ '.js': 'text/javascript',
43
+ '.jsx': 'text/javascript',
44
+ '.json': 'application/json',
45
+ '.md': 'text/markdown',
46
+ '.py': 'text/x-python',
47
+ '.rs': 'text/x-rust',
48
+ '.go': 'text/x-go',
49
+ '.sol': 'text/x-solidity',
50
+ '.yaml': 'text/yaml',
51
+ '.yml': 'text/yaml',
52
+ '.toml': 'text/toml',
53
+ '.html': 'text/html',
54
+ '.css': 'text/css',
55
+ '.sh': 'text/x-shellscript',
56
+ };
57
+ return mimeMap[ext.toLowerCase()] || 'application/octet-stream';
58
+ }
59
+ /** Map file extension to language name */
60
+ export function extensionToLanguage(ext) {
61
+ const langMap = {
62
+ '.ts': 'typescript',
63
+ '.tsx': 'typescript',
64
+ '.js': 'javascript',
65
+ '.jsx': 'javascript',
66
+ '.py': 'python',
67
+ '.rs': 'rust',
68
+ '.go': 'go',
69
+ '.sol': 'solidity',
70
+ '.java': 'java',
71
+ '.rb': 'ruby',
72
+ '.c': 'c',
73
+ '.cpp': 'cpp',
74
+ '.h': 'c',
75
+ '.cs': 'csharp',
76
+ '.swift': 'swift',
77
+ '.kt': 'kotlin',
78
+ '.sh': 'shell',
79
+ '.bash': 'shell',
80
+ };
81
+ return langMap[ext.toLowerCase()] || ext.replace('.', '');
82
+ }
83
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/util/hash.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAE/B,yDAAyD;AACzD,MAAM,UAAU,QAAQ,CAAC,IAAa;IACpC,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,0BAA0B;AAC1B,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC;AAED,gCAAgC;AAChC,MAAM,UAAU,eAAe,CAAC,OAAwB;IACtD,OAAO,MAAM,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AACnF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtC,2CAA2C;IAC3C,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;QACrE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IACD,uEAAuE;IACvE,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,O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ACf,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,GAAG;QACT,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,QAAQ;QACf,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,OAAO;KACjB,CAAC;IACF,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC5D,CAAC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@clawtrail/context-graph-openclaw",
3
+ "version": "0.1.0",
4
+ "description": "OpenClaw adapter for @clawtrail/context-graph — captures agent execution traces as PROV-O events",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "dev": "tsc --watch",
17
+ "test": "vitest run",
18
+ "test:watch": "vitest",
19
+ "lint": "oxlint src/",
20
+ "clean": "rm -rf dist"
21
+ },
22
+ "keywords": [
23
+ "openclaw",
24
+ "context-graph",
25
+ "provenance",
26
+ "agent",
27
+ "origintrail"
28
+ ],
29
+ "license": "MIT",
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "engines": {
34
+ "node": ">=20"
35
+ },
36
+ "peerDependencies": {
37
+ "@clawtrail/context-graph": "^0.1.0"
38
+ },
39
+ "dependencies": {
40
+ "@clawtrail/context-graph": "^0.1.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^22.0.0",
44
+ "oxlint": "^0.16.0",
45
+ "typescript": "^5.7.0",
46
+ "vitest": "^3.0.0"
47
+ }
48
+ }