arc-1 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 (160) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +222 -0
  3. package/bin/arc1.js +12 -0
  4. package/dist/adt/btp.d.ts +122 -0
  5. package/dist/adt/btp.d.ts.map +1 -0
  6. package/dist/adt/btp.js +392 -0
  7. package/dist/adt/btp.js.map +1 -0
  8. package/dist/adt/client.d.ts +89 -0
  9. package/dist/adt/client.d.ts.map +1 -0
  10. package/dist/adt/client.js +208 -0
  11. package/dist/adt/client.js.map +1 -0
  12. package/dist/adt/codeintel.d.ts +38 -0
  13. package/dist/adt/codeintel.d.ts.map +1 -0
  14. package/dist/adt/codeintel.js +61 -0
  15. package/dist/adt/codeintel.js.map +1 -0
  16. package/dist/adt/config.d.ts +65 -0
  17. package/dist/adt/config.d.ts.map +1 -0
  18. package/dist/adt/config.js +35 -0
  19. package/dist/adt/config.js.map +1 -0
  20. package/dist/adt/cookies.d.ts +27 -0
  21. package/dist/adt/cookies.d.ts.map +1 -0
  22. package/dist/adt/cookies.js +67 -0
  23. package/dist/adt/cookies.js.map +1 -0
  24. package/dist/adt/crud.d.ts +35 -0
  25. package/dist/adt/crud.d.ts.map +1 -0
  26. package/dist/adt/crud.js +87 -0
  27. package/dist/adt/crud.js.map +1 -0
  28. package/dist/adt/devtools.d.ts +32 -0
  29. package/dist/adt/devtools.d.ts.map +1 -0
  30. package/dist/adt/devtools.js +154 -0
  31. package/dist/adt/devtools.js.map +1 -0
  32. package/dist/adt/errors.d.ts +49 -0
  33. package/dist/adt/errors.d.ts.map +1 -0
  34. package/dist/adt/errors.js +80 -0
  35. package/dist/adt/errors.js.map +1 -0
  36. package/dist/adt/features.d.ts +44 -0
  37. package/dist/adt/features.d.ts.map +1 -0
  38. package/dist/adt/features.js +173 -0
  39. package/dist/adt/features.js.map +1 -0
  40. package/dist/adt/http.d.ts +116 -0
  41. package/dist/adt/http.d.ts.map +1 -0
  42. package/dist/adt/http.js +374 -0
  43. package/dist/adt/http.js.map +1 -0
  44. package/dist/adt/safety.d.ts +70 -0
  45. package/dist/adt/safety.d.ts.map +1 -0
  46. package/dist/adt/safety.js +222 -0
  47. package/dist/adt/safety.js.map +1 -0
  48. package/dist/adt/transport.d.ts +18 -0
  49. package/dist/adt/transport.d.ts.map +1 -0
  50. package/dist/adt/transport.js +66 -0
  51. package/dist/adt/transport.js.map +1 -0
  52. package/dist/adt/types.d.ts +91 -0
  53. package/dist/adt/types.d.ts.map +1 -0
  54. package/dist/adt/types.js +9 -0
  55. package/dist/adt/types.js.map +1 -0
  56. package/dist/adt/xml-parser.d.ts +109 -0
  57. package/dist/adt/xml-parser.d.ts.map +1 -0
  58. package/dist/adt/xml-parser.js +283 -0
  59. package/dist/adt/xml-parser.js.map +1 -0
  60. package/dist/cache/cache.d.ts +61 -0
  61. package/dist/cache/cache.d.ts.map +1 -0
  62. package/dist/cache/cache.js +14 -0
  63. package/dist/cache/cache.js.map +1 -0
  64. package/dist/cache/memory.d.ts +25 -0
  65. package/dist/cache/memory.d.ts.map +1 -0
  66. package/dist/cache/memory.js +69 -0
  67. package/dist/cache/memory.js.map +1 -0
  68. package/dist/cache/sqlite.d.ts +26 -0
  69. package/dist/cache/sqlite.d.ts.map +1 -0
  70. package/dist/cache/sqlite.js +130 -0
  71. package/dist/cache/sqlite.js.map +1 -0
  72. package/dist/cli.d.ts +14 -0
  73. package/dist/cli.d.ts.map +1 -0
  74. package/dist/cli.js +101 -0
  75. package/dist/cli.js.map +1 -0
  76. package/dist/context/compressor.d.ts +33 -0
  77. package/dist/context/compressor.d.ts.map +1 -0
  78. package/dist/context/compressor.js +208 -0
  79. package/dist/context/compressor.js.map +1 -0
  80. package/dist/context/contract.d.ts +14 -0
  81. package/dist/context/contract.d.ts.map +1 -0
  82. package/dist/context/contract.js +202 -0
  83. package/dist/context/contract.js.map +1 -0
  84. package/dist/context/deps.d.ts +32 -0
  85. package/dist/context/deps.d.ts.map +1 -0
  86. package/dist/context/deps.js +240 -0
  87. package/dist/context/deps.js.map +1 -0
  88. package/dist/context/types.d.ts +56 -0
  89. package/dist/context/types.d.ts.map +1 -0
  90. package/dist/context/types.js +10 -0
  91. package/dist/context/types.js.map +1 -0
  92. package/dist/handlers/intent.d.ts +46 -0
  93. package/dist/handlers/intent.d.ts.map +1 -0
  94. package/dist/handlers/intent.js +539 -0
  95. package/dist/handlers/intent.js.map +1 -0
  96. package/dist/handlers/tools.d.ts +21 -0
  97. package/dist/handlers/tools.d.ts.map +1 -0
  98. package/dist/handlers/tools.js +260 -0
  99. package/dist/handlers/tools.js.map +1 -0
  100. package/dist/index.d.ts +10 -0
  101. package/dist/index.d.ts.map +1 -0
  102. package/dist/index.js +16 -0
  103. package/dist/index.js.map +1 -0
  104. package/dist/lint/lint.d.ts +35 -0
  105. package/dist/lint/lint.d.ts.map +1 -0
  106. package/dist/lint/lint.js +67 -0
  107. package/dist/lint/lint.js.map +1 -0
  108. package/dist/server/audit.d.ts +96 -0
  109. package/dist/server/audit.d.ts.map +1 -0
  110. package/dist/server/audit.js +27 -0
  111. package/dist/server/audit.js.map +1 -0
  112. package/dist/server/config.d.ts +19 -0
  113. package/dist/server/config.d.ts.map +1 -0
  114. package/dist/server/config.js +101 -0
  115. package/dist/server/config.js.map +1 -0
  116. package/dist/server/context.d.ts +20 -0
  117. package/dist/server/context.d.ts.map +1 -0
  118. package/dist/server/context.js +20 -0
  119. package/dist/server/context.js.map +1 -0
  120. package/dist/server/elicit.d.ts +43 -0
  121. package/dist/server/elicit.d.ts.map +1 -0
  122. package/dist/server/elicit.js +183 -0
  123. package/dist/server/elicit.js.map +1 -0
  124. package/dist/server/http.d.ts +34 -0
  125. package/dist/server/http.d.ts.map +1 -0
  126. package/dist/server/http.js +328 -0
  127. package/dist/server/http.js.map +1 -0
  128. package/dist/server/logger.d.ts +57 -0
  129. package/dist/server/logger.d.ts.map +1 -0
  130. package/dist/server/logger.js +129 -0
  131. package/dist/server/logger.js.map +1 -0
  132. package/dist/server/server.d.ts +25 -0
  133. package/dist/server/server.d.ts.map +1 -0
  134. package/dist/server/server.js +307 -0
  135. package/dist/server/server.js.map +1 -0
  136. package/dist/server/sinks/btp-auditlog.d.ts +48 -0
  137. package/dist/server/sinks/btp-auditlog.d.ts.map +1 -0
  138. package/dist/server/sinks/btp-auditlog.js +232 -0
  139. package/dist/server/sinks/btp-auditlog.js.map +1 -0
  140. package/dist/server/sinks/file.d.ts +22 -0
  141. package/dist/server/sinks/file.d.ts.map +1 -0
  142. package/dist/server/sinks/file.js +59 -0
  143. package/dist/server/sinks/file.js.map +1 -0
  144. package/dist/server/sinks/stderr.d.ts +19 -0
  145. package/dist/server/sinks/stderr.d.ts.map +1 -0
  146. package/dist/server/sinks/stderr.js +63 -0
  147. package/dist/server/sinks/stderr.js.map +1 -0
  148. package/dist/server/sinks/types.d.ts +14 -0
  149. package/dist/server/sinks/types.d.ts.map +1 -0
  150. package/dist/server/sinks/types.js +8 -0
  151. package/dist/server/sinks/types.js.map +1 -0
  152. package/dist/server/types.d.ts +54 -0
  153. package/dist/server/types.d.ts.map +1 -0
  154. package/dist/server/types.js +42 -0
  155. package/dist/server/types.js.map +1 -0
  156. package/dist/server/xsuaa.d.ts +77 -0
  157. package/dist/server/xsuaa.d.ts.map +1 -0
  158. package/dist/server/xsuaa.js +364 -0
  159. package/dist/server/xsuaa.js.map +1 -0
  160. package/package.json +66 -0
@@ -0,0 +1,260 @@
1
+ /**
2
+ * Tool definitions for ARC-1's 11 intent-based MCP tools.
3
+ *
4
+ * Each tool has:
5
+ * - name: The MCP tool name (SAPRead, SAPWrite, etc.)
6
+ * - description: Rich LLM-friendly description
7
+ * - inputSchema: JSON Schema for tool arguments
8
+ *
9
+ * The 11 intent-based design is ARC-1's key differentiator:
10
+ * instead of 200+ individual tools (one per object type per operation),
11
+ * we group by *intent* with a `type` parameter for routing.
12
+ * This keeps the LLM's tool selection simple and the context window small.
13
+ */
14
+ export function getToolDefinitions(config) {
15
+ const tools = [
16
+ {
17
+ name: 'SAPRead',
18
+ description: 'Read SAP ABAP objects. Types: PROG, CLAS, INTF, FUNC (requires group param), FUGR, INCL, DDLS, BDEF, SRVD, TABL, VIEW, TABLE_CONTENTS, DEVC, SYSTEM, COMPONENTS, MESSAGES, TEXT_ELEMENTS, VARIANTS. For CLAS: omit include to get the full class source (definition + implementation combined). The include param is optional — use it only to read class-local sections: definitions (local types), implementations (local helper classes), macros, testclasses (ABAP Unit).',
19
+ inputSchema: {
20
+ type: 'object',
21
+ properties: {
22
+ type: {
23
+ type: 'string',
24
+ enum: [
25
+ 'PROG',
26
+ 'CLAS',
27
+ 'INTF',
28
+ 'FUNC',
29
+ 'FUGR',
30
+ 'INCL',
31
+ 'DDLS',
32
+ 'BDEF',
33
+ 'SRVD',
34
+ 'TABL',
35
+ 'VIEW',
36
+ 'TABLE_CONTENTS',
37
+ 'DEVC',
38
+ 'SYSTEM',
39
+ 'COMPONENTS',
40
+ 'MESSAGES',
41
+ 'TEXT_ELEMENTS',
42
+ 'VARIANTS',
43
+ ],
44
+ description: 'Object type to read',
45
+ },
46
+ name: { type: 'string', description: 'Object name (e.g., ZTEST_PROGRAM, ZCL_ORDER, MARA)' },
47
+ include: {
48
+ type: 'string',
49
+ description: 'For CLAS only. DO NOT use this to read the main class — omit include entirely to get the full class source (CLASS DEFINITION + CLASS IMPLEMENTATION). This parameter reads class-LOCAL auxiliary files only: definitions (local type definitions, NOT the main class definition), implementations (local helper class implementations), macros, testclasses (ABAP Unit). Comma-separated. Not all classes have these sections — missing ones return a note instead of an error.',
50
+ },
51
+ group: {
52
+ type: 'string',
53
+ description: 'Required for FUNC type. The function group containing the function module. Use SAPSearch to find it if unknown.',
54
+ },
55
+ maxRows: { type: 'number', description: 'For TABLE_CONTENTS: max rows to return (default 100)' },
56
+ sqlFilter: { type: 'string', description: 'For TABLE_CONTENTS: SQL WHERE clause filter' },
57
+ },
58
+ required: ['type'],
59
+ },
60
+ },
61
+ {
62
+ name: 'SAPSearch',
63
+ description: 'Search for ABAP objects by name pattern. Supports wildcards (* for any characters). Returns object type, name, package, and description.',
64
+ inputSchema: {
65
+ type: 'object',
66
+ properties: {
67
+ query: { type: 'string', description: 'Search pattern (e.g., ZCL_ORDER*, Z*TEST*)' },
68
+ maxResults: { type: 'number', description: 'Maximum results (default 100)' },
69
+ },
70
+ required: ['query'],
71
+ },
72
+ },
73
+ ];
74
+ // Write tools — only registered when not in read-only mode
75
+ if (!config.readOnly) {
76
+ tools.push({
77
+ name: 'SAPWrite',
78
+ description: 'Create or update ABAP source code. Handles lock/modify/unlock automatically. Supports PROG, CLAS, INTF, FUNC, INCL.',
79
+ inputSchema: {
80
+ type: 'object',
81
+ properties: {
82
+ action: { type: 'string', enum: ['create', 'update', 'delete'], description: 'Write action' },
83
+ type: { type: 'string', enum: ['PROG', 'CLAS', 'INTF', 'FUNC', 'INCL'], description: 'Object type' },
84
+ name: { type: 'string', description: 'Object name' },
85
+ source: { type: 'string', description: 'ABAP source code (for create/update)' },
86
+ package: { type: 'string', description: 'Package for new objects (default $TMP)' },
87
+ transport: { type: 'string', description: 'Transport request number (for transportable packages)' },
88
+ },
89
+ required: ['action', 'type', 'name'],
90
+ },
91
+ });
92
+ tools.push({
93
+ name: 'SAPActivate',
94
+ description: 'Activate (publish) ABAP objects. Activates the object and reports any activation errors.',
95
+ inputSchema: {
96
+ type: 'object',
97
+ properties: {
98
+ name: { type: 'string', description: 'Object name to activate' },
99
+ type: { type: 'string', description: 'Object type (PROG, CLAS, etc.)' },
100
+ },
101
+ required: ['name', 'type'],
102
+ },
103
+ });
104
+ }
105
+ tools.push({
106
+ name: 'SAPNavigate',
107
+ description: 'Navigate code: find definitions, references, and code completion. Use for "go to definition", "where is this used?", and auto-complete.',
108
+ inputSchema: {
109
+ type: 'object',
110
+ properties: {
111
+ action: {
112
+ type: 'string',
113
+ enum: ['definition', 'references', 'completion'],
114
+ description: 'Navigation action',
115
+ },
116
+ uri: { type: 'string', description: 'Source URI of the object' },
117
+ line: { type: 'number', description: 'Line number (1-based)' },
118
+ column: { type: 'number', description: 'Column number (1-based)' },
119
+ source: { type: 'string', description: 'Current source code (for definition/completion)' },
120
+ },
121
+ required: ['action', 'uri'],
122
+ },
123
+ }, {
124
+ name: 'SAPQuery',
125
+ description: 'Execute ABAP SQL queries against SAP tables. Returns structured data with column names and rows.',
126
+ inputSchema: {
127
+ type: 'object',
128
+ properties: {
129
+ sql: { type: 'string', description: 'ABAP SQL SELECT statement' },
130
+ maxRows: { type: 'number', description: 'Maximum rows (default 100)' },
131
+ },
132
+ required: ['sql'],
133
+ },
134
+ }, {
135
+ name: 'SAPLint',
136
+ description: 'Check ABAP code quality. Runs abaplint rules locally and/or ATC checks on the SAP system.',
137
+ inputSchema: {
138
+ type: 'object',
139
+ properties: {
140
+ action: { type: 'string', enum: ['lint', 'atc', 'syntax'], description: 'Check type' },
141
+ source: { type: 'string', description: 'ABAP source code (for lint)' },
142
+ name: { type: 'string', description: 'Object name (for atc/syntax)' },
143
+ type: { type: 'string', description: 'Object type (for atc/syntax)' },
144
+ },
145
+ required: ['action'],
146
+ },
147
+ }, {
148
+ name: 'SAPDiagnose',
149
+ description: 'Run diagnostics on ABAP objects: syntax check, ABAP unit tests, and ATC (ABAP Test Cockpit) code quality checks.',
150
+ inputSchema: {
151
+ type: 'object',
152
+ properties: {
153
+ action: {
154
+ type: 'string',
155
+ enum: ['syntax', 'unittest', 'atc'],
156
+ description: 'Diagnostic action',
157
+ },
158
+ name: { type: 'string', description: 'Object name' },
159
+ type: { type: 'string', description: 'Object type (PROG, CLAS, etc.)' },
160
+ variant: { type: 'string', description: 'ATC check variant (for atc action)' },
161
+ },
162
+ required: ['action', 'name', 'type'],
163
+ },
164
+ });
165
+ // SAPContext — always available (read-only tool)
166
+ tools.push({
167
+ name: 'SAPContext',
168
+ description: 'Get compressed dependency context for an ABAP object. Returns only the public API contracts ' +
169
+ '(method signatures, interface definitions, type declarations) of all objects that the target depends on — ' +
170
+ 'NOT the full source code. This is the most token-efficient way to understand dependencies. ' +
171
+ 'Instead of N separate SAPRead calls returning full source (~200 lines each), SAPContext returns ONE response ' +
172
+ 'with compressed contracts (~15-30 lines each). Typical compression: 7-30x fewer tokens.\n\n' +
173
+ 'What gets extracted per dependency:\n' +
174
+ '- Classes: CLASS DEFINITION with PUBLIC SECTION only (methods, types, constants). PROTECTED, PRIVATE and IMPLEMENTATION stripped.\n' +
175
+ '- Interfaces: Full interface definition (interfaces are already public contracts).\n' +
176
+ '- Function modules: FUNCTION signature block only (IMPORTING/EXPORTING parameters).\n\n' +
177
+ 'Filtering: SAP standard objects (CL_ABAP_*, IF_ABAP_*, CX_SY_*) are excluded — the LLM already knows standard SAP APIs. ' +
178
+ 'Custom objects (Z*, Y*) are prioritized.\n\n' +
179
+ 'Use SAPContext BEFORE writing code that modifies or extends existing objects. ' +
180
+ 'Use SAPRead to get the full source of the target object, then SAPContext to understand its dependencies.',
181
+ inputSchema: {
182
+ type: 'object',
183
+ properties: {
184
+ type: {
185
+ type: 'string',
186
+ enum: ['CLAS', 'INTF', 'PROG', 'FUNC'],
187
+ description: 'Object type',
188
+ },
189
+ name: {
190
+ type: 'string',
191
+ description: 'Object name (e.g., ZCL_ORDER)',
192
+ },
193
+ source: {
194
+ type: 'string',
195
+ description: 'Optional: provide source directly instead of fetching from SAP. ' +
196
+ 'Saves one round-trip if you already have the source from SAPRead.',
197
+ },
198
+ group: {
199
+ type: 'string',
200
+ description: 'Required for FUNC type. The function group containing the function module.',
201
+ },
202
+ maxDeps: {
203
+ type: 'number',
204
+ description: 'Maximum dependencies to resolve (default 20). Lower = faster + fewer tokens.',
205
+ },
206
+ depth: {
207
+ type: 'number',
208
+ description: 'Dependency depth: 1 = direct deps only (default), 2 = deps of deps, 3 = maximum. ' +
209
+ 'Higher depth = more context but more SAP calls.',
210
+ },
211
+ },
212
+ required: ['type', 'name'],
213
+ },
214
+ });
215
+ // SAPManage — registered when not in read-only mode
216
+ if (!config.readOnly) {
217
+ tools.push({
218
+ name: 'SAPManage',
219
+ description: 'Probe and report SAP system capabilities. Use this BEFORE attempting operations that depend on optional ' +
220
+ 'features (abapGit, RAP/CDS, AMDP, HANA, UI5/Fiori, CTS transports).\n\n' +
221
+ 'Actions:\n' +
222
+ '- "features": Get cached feature status from last probe (fast, no SAP round-trip). ' +
223
+ 'Returns which features are available, their mode (auto/on/off), and when they were last probed.\n' +
224
+ '- "probe": Re-probe the SAP system now (makes 6 parallel HEAD requests, ~1-2s). ' +
225
+ 'Use this on first use or if you suspect feature availability has changed.\n\n' +
226
+ 'Returns JSON with 6 features, each having: id, available (bool), mode, message, and probedAt timestamp. ' +
227
+ '"available: false" means do NOT attempt operations that depend on it.',
228
+ inputSchema: {
229
+ type: 'object',
230
+ properties: {
231
+ action: {
232
+ type: 'string',
233
+ enum: ['features', 'probe'],
234
+ description: 'Action: "features" for cached status, "probe" to re-check SAP system',
235
+ },
236
+ },
237
+ required: ['action'],
238
+ },
239
+ });
240
+ }
241
+ // Transport tools — registered when transports are enabled or not in read-only mode
242
+ if (config.enableTransports || !config.readOnly) {
243
+ tools.push({
244
+ name: 'SAPTransport',
245
+ description: 'Manage CTS transport requests: list, get details, create, and release.',
246
+ inputSchema: {
247
+ type: 'object',
248
+ properties: {
249
+ action: { type: 'string', enum: ['list', 'get', 'create', 'release'], description: 'Transport action' },
250
+ id: { type: 'string', description: 'Transport request ID (for get/release)' },
251
+ description: { type: 'string', description: 'Description (for create)' },
252
+ user: { type: 'string', description: 'Filter by user (for list)' },
253
+ },
254
+ required: ['action'],
255
+ },
256
+ });
257
+ }
258
+ return tools;
259
+ }
260
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../ts-src/handlers/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,MAAM,UAAU,kBAAkB,CAAC,MAAoB;IACrD,MAAM,KAAK,GAAqB;Q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Q,EAAE,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC;YACT,IAAI,EAAE,cAAc;YACpB,WAAW,EAAE,wEAAwE;YACrF,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE;oBACvG,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,wCAAwC,EAAE;oBAC7E,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0BAA0B,EAAE;oBACxE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2BAA2B,EAAE;iBACnE;gBACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;aACrB;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * ARC-1 — ABAP Relay Connector
3
+ *
4
+ * MCP (Model Context Protocol) server for SAP ABAP systems.
5
+ * Provides 11 intent-based tools for AI agents to interact with SAP ADT.
6
+ *
7
+ * Entry point: starts the MCP server on stdio (default) or HTTP Streamable transport.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts-src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * ARC-1 — ABAP Relay Connector
3
+ *
4
+ * MCP (Model Context Protocol) server for SAP ABAP systems.
5
+ * Provides 11 intent-based tools for AI agents to interact with SAP ADT.
6
+ *
7
+ * Entry point: starts the MCP server on stdio (default) or HTTP Streamable transport.
8
+ */
9
+ import { config } from 'dotenv';
10
+ import { parseArgs } from './server/config.js';
11
+ import { createAndStartServer } from './server/server.js';
12
+ // Load .env file (if present) before anything else
13
+ config();
14
+ const serverConfig = parseArgs(process.argv.slice(2));
15
+ await createAndStartServer(serverConfig);
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts-src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,mDAAmD;AACnD,MAAM,EAAE,CAAC;AAET,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACtD,MAAM,oBAAoB,CAAC,YAAY,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * ABAP Lint wrapper using @abaplint/core.
3
+ *
4
+ * In the Go version, we had a custom port of the abaplint lexer (1,700 LOC).
5
+ * Now that we're in TypeScript, we use @abaplint/core directly — it's the
6
+ * original implementation, maintained by the abaplint author.
7
+ *
8
+ * This gives us the full lexer + parser + linter with 100+ rules,
9
+ * instead of our Go port's 8 rules and 48 token types.
10
+ */
11
+ import { Config } from '@abaplint/core';
12
+ /** Lint result from @abaplint/core */
13
+ export interface LintResult {
14
+ rule: string;
15
+ message: string;
16
+ line: number;
17
+ column: number;
18
+ endLine: number;
19
+ endColumn: number;
20
+ severity: 'error' | 'warning' | 'info';
21
+ }
22
+ /**
23
+ * Lint ABAP source code using @abaplint/core.
24
+ *
25
+ * @param source - ABAP source code
26
+ * @param filename - Filename with appropriate extension (.prog.abap, .clas.abap, etc.)
27
+ * @param config - Optional abaplint configuration (defaults to standard ABAP rules)
28
+ */
29
+ export declare function lintAbapSource(source: string, filename: string, config?: Config): LintResult[];
30
+ /**
31
+ * Auto-detect the correct filename for ABAP source based on content.
32
+ * abaplint uses the file extension to determine the object type.
33
+ */
34
+ export declare function detectFilename(source: string, objectName: string): string;
35
+ //# sourceMappingURL=lint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../ts-src/lint/lint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAiC,MAAM,gBAAgB,CAAC;AAEvE,sCAAsC;AACtC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;CACxC;AAKD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,EAAE,CAc9F;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAazE"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * ABAP Lint wrapper using @abaplint/core.
3
+ *
4
+ * In the Go version, we had a custom port of the abaplint lexer (1,700 LOC).
5
+ * Now that we're in TypeScript, we use @abaplint/core directly — it's the
6
+ * original implementation, maintained by the abaplint author.
7
+ *
8
+ * This gives us the full lexer + parser + linter with 100+ rules,
9
+ * instead of our Go port's 8 rules and 48 token types.
10
+ */
11
+ import { Config, MemoryFile, Registry, Version } from '@abaplint/core';
12
+ /** Default abaplint configuration for ARC-1 */
13
+ const DEFAULT_CONFIG = Config.getDefault(Version.v702);
14
+ /**
15
+ * Lint ABAP source code using @abaplint/core.
16
+ *
17
+ * @param source - ABAP source code
18
+ * @param filename - Filename with appropriate extension (.prog.abap, .clas.abap, etc.)
19
+ * @param config - Optional abaplint configuration (defaults to standard ABAP rules)
20
+ */
21
+ export function lintAbapSource(source, filename, config) {
22
+ const reg = new Registry(config ?? DEFAULT_CONFIG);
23
+ reg.addFile(new MemoryFile(filename, source));
24
+ reg.parse();
25
+ return reg.findIssues().map((issue) => ({
26
+ rule: issue.getKey(),
27
+ message: issue.getMessage(),
28
+ line: issue.getStart().getRow(),
29
+ column: issue.getStart().getCol(),
30
+ endLine: issue.getEnd().getRow(),
31
+ endColumn: issue.getEnd().getCol(),
32
+ severity: mapSeverity(issue.getSeverity()),
33
+ }));
34
+ }
35
+ /**
36
+ * Auto-detect the correct filename for ABAP source based on content.
37
+ * abaplint uses the file extension to determine the object type.
38
+ */
39
+ export function detectFilename(source, objectName) {
40
+ // Strip leading comment lines ("! doc comments, * comments) and blank lines to find the first keyword
41
+ const stripped = source.replace(/^(\s*(["*!].*)?[\r\n]*)*/m, '');
42
+ const upper = stripped.toUpperCase().trimStart();
43
+ if (upper.startsWith('CLASS'))
44
+ return `${objectName.toLowerCase()}.clas.abap`;
45
+ if (upper.startsWith('INTERFACE'))
46
+ return `${objectName.toLowerCase()}.intf.abap`;
47
+ if (upper.startsWith('FUNCTION-POOL') || upper.startsWith('FUNCTION'))
48
+ return `${objectName.toLowerCase()}.fugr.abap`;
49
+ if (upper.startsWith('REPORT') || upper.startsWith('PROGRAM'))
50
+ return `${objectName.toLowerCase()}.prog.abap`;
51
+ if (upper.startsWith('DEFINE VIEW') || upper.startsWith('@'))
52
+ return `${objectName.toLowerCase()}.ddls.asddls`;
53
+ if (upper.startsWith('MANAGED') || upper.startsWith('UNMANAGED') || upper.startsWith('ABSTRACT'))
54
+ return `${objectName.toLowerCase()}.bdef.asbdef`;
55
+ // Default to class (enables most rules)
56
+ return `${objectName.toLowerCase()}.clas.abap`;
57
+ }
58
+ /** Map abaplint severity to our severity levels */
59
+ function mapSeverity(severity) {
60
+ const s = severity.toString().toLowerCase();
61
+ if (s === 'error')
62
+ return 'error';
63
+ if (s === 'warning')
64
+ return 'warning';
65
+ return 'info';
66
+ }
67
+ //# sourceMappingURL=lint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint.js","sourceRoot":"","sources":["../../ts-src/lint/lint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAavE,+CAA+C;AAC/C,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,QAAgB,EAAE,MAAe;IAC9E,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,MAAM,IAAI,cAAc,CAAC,CAAC;IACnD,GAAG,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9C,GAAG,CAAC,KAAK,EAAE,CAAC;IAEZ,OAAO,GAAG,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACtC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE;QACpB,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE;QAC3B,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE;QAC/B,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE;QACjC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE;QAChC,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE;QAClC,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;KAC3C,CAAC,CAAC,CAAC;AACN,CAA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,EAAE,CAAC,WAAW,EAAE,CAAC;IAC5C,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IAClC,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACtC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Audit event types for ARC-1.
3
+ *
4
+ * Every structured log entry is one of these typed events.
5
+ * They are written to all registered sinks (stderr, file, BTP audit log).
6
+ *
7
+ * requestId correlates all events within a single MCP tool call,
8
+ * including nested HTTP requests and auth events.
9
+ */
10
+ import type { LogLevel } from './logger.js';
11
+ /** Base shape for all audit events */
12
+ export interface AuditEventBase {
13
+ timestamp: string;
14
+ level: LogLevel;
15
+ event: string;
16
+ requestId?: string;
17
+ user?: string;
18
+ clientId?: string;
19
+ }
20
+ /** MCP tool call started */
21
+ export interface ToolCallStartEvent extends AuditEventBase {
22
+ event: 'tool_call_start';
23
+ tool: string;
24
+ args: Record<string, unknown>;
25
+ }
26
+ /** MCP tool call completed (success or error) */
27
+ export interface ToolCallEndEvent extends AuditEventBase {
28
+ event: 'tool_call_end';
29
+ tool: string;
30
+ durationMs: number;
31
+ status: 'success' | 'error';
32
+ errorClass?: string;
33
+ errorMessage?: string;
34
+ resultSize?: number;
35
+ }
36
+ /** HTTP request to SAP ADT */
37
+ export interface HttpRequestEvent extends AuditEventBase {
38
+ event: 'http_request';
39
+ method: string;
40
+ path: string;
41
+ statusCode: number;
42
+ durationMs: number;
43
+ errorBody?: string;
44
+ }
45
+ /** CSRF token fetch */
46
+ export interface HttpCsrfFetchEvent extends AuditEventBase {
47
+ event: 'http_csrf_fetch';
48
+ durationMs: number;
49
+ success: boolean;
50
+ }
51
+ /** Auth scope denied */
52
+ export interface AuthScopeDeniedEvent extends AuditEventBase {
53
+ event: 'auth_scope_denied';
54
+ tool: string;
55
+ requiredScope: string;
56
+ availableScopes: string[];
57
+ }
58
+ /** Per-user ADT client created via principal propagation */
59
+ export interface AuthPPCreatedEvent extends AuditEventBase {
60
+ event: 'auth_pp_created';
61
+ destination: string;
62
+ success: boolean;
63
+ errorMessage?: string;
64
+ }
65
+ /** Safety system blocked an operation */
66
+ export interface SafetyBlockedEvent extends AuditEventBase {
67
+ event: 'safety_blocked';
68
+ operation: string;
69
+ reason: string;
70
+ }
71
+ /** Server started */
72
+ export interface ServerStartEvent extends AuditEventBase {
73
+ event: 'server_start';
74
+ version: string;
75
+ transport: string;
76
+ readOnly: boolean;
77
+ url: string;
78
+ }
79
+ /** Elicitation sent to client */
80
+ export interface ElicitationSentEvent extends AuditEventBase {
81
+ event: 'elicitation_sent';
82
+ tool: string;
83
+ message: string;
84
+ fields?: string[];
85
+ }
86
+ /** Elicitation response from client */
87
+ export interface ElicitationResponseEvent extends AuditEventBase {
88
+ event: 'elicitation_response';
89
+ tool: string;
90
+ action: string;
91
+ }
92
+ /** Discriminated union of all audit events */
93
+ export type AuditEvent = ToolCallStartEvent | ToolCallEndEvent | HttpRequestEvent | HttpCsrfFetchEvent | AuthScopeDeniedEvent | AuthPPCreatedEvent | SafetyBlockedEvent | ServerStartEvent | ElicitationSentEvent | ElicitationResponseEvent;
94
+ /** Sanitize tool call arguments — remove values that might contain sensitive data */
95
+ export declare function sanitizeArgs(args: Record<string, unknown>): Record<string, unknown>;
96
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../ts-src/server/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC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O,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,yCAAyC;AACzC,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,KAAK,EAAE,gBAAgB,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAqB;AACrB,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,KAAK,EAAE,cAAc,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,iCAAiC;AACjC,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,uCAAuC;AACvC,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,KAAK,EAAE,sBAAsB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,8CAA8C;AAC9C,MAAM,MAAM,UAAU,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,kBAAkB,GAClB,oBAAoB,GACpB,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,oBAAoB,GACpB,wBAAwB,CAAC;AAE7B,qFAAqF;AACrF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAanF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Audit event types for ARC-1.
3
+ *
4
+ * Every structured log entry is one of these typed events.
5
+ * They are written to all registered sinks (stderr, file, BTP audit log).
6
+ *
7
+ * requestId correlates all events within a single MCP tool call,
8
+ * including nested HTTP requests and auth events.
9
+ */
10
+ /** Sanitize tool call arguments — remove values that might contain sensitive data */
11
+ export function sanitizeArgs(args) {
12
+ const sensitiveKeys = ['password', 'token', 'secret', 'cookie', 'authorization', 'csrf', 'apikey'];
13
+ const result = {};
14
+ for (const [key, value] of Object.entries(args)) {
15
+ if (sensitiveKeys.some((s) => key.toLowerCase().includes(s))) {
16
+ result[key] = '[REDACTED]';
17
+ }
18
+ else if (typeof value === 'string' && value.length > 500) {
19
+ result[key] = `${value.slice(0, 200)}... [truncated ${value.length} chars]`;
20
+ }
21
+ else {
22
+ result[key] = value;
23
+ }
24
+ }
25
+ return result;
26
+ }
27
+ //# sourceMappingURL=audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.js","sourceRoot":"","sources":["../../ts-src/server/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA6GH,qFAAqF;AACrF,MAAM,UAAU,YAAY,CAAC,IAA6B;IACxD,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnG,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7D,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC;QAC7B,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YAC3D,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,kBAAkB,KAAK,CAAC,MAAM,SAAS,CAAC;QAC9E,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Configuration parser for ARC-1.
3
+ *
4
+ * Resolves configuration from CLI flags, environment variables, and defaults.
5
+ * Priority: CLI > env > .env > defaults
6
+ *
7
+ * Environment variable names match the Go version exactly (SAP_URL, SAP_USER, etc.)
8
+ * for drop-in compatibility with existing deployments and documentation.
9
+ */
10
+ import type { ServerConfig } from './types.js';
11
+ /**
12
+ * Parse CLI arguments and environment variables into a ServerConfig.
13
+ *
14
+ * We use a simple hand-rolled parser here (not commander) because
15
+ * the MCP server entry point needs to be fast and lightweight.
16
+ * Commander is used for the full CLI (cli.ts), not the server startup.
17
+ */
18
+ export declare function parseArgs(args: string[]): ServerConfig;
19
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../ts-src/server/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAiB,MAAM,YAAY,CAAC;AAG7E;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,YAAY,CAgGtD"}