arc-1 0.6.5 → 0.6.7

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 (59) hide show
  1. package/dist/adt/client.d.ts +2 -0
  2. package/dist/adt/client.d.ts.map +1 -1
  3. package/dist/adt/client.js +8 -0
  4. package/dist/adt/client.js.map +1 -1
  5. package/dist/adt/config.d.ts +2 -0
  6. package/dist/adt/config.d.ts.map +1 -1
  7. package/dist/adt/config.js.map +1 -1
  8. package/dist/adt/devtools.d.ts +2 -2
  9. package/dist/adt/devtools.d.ts.map +1 -1
  10. package/dist/adt/devtools.js +4 -4
  11. package/dist/adt/devtools.js.map +1 -1
  12. package/dist/adt/discovery.d.ts +13 -0
  13. package/dist/adt/discovery.d.ts.map +1 -0
  14. package/dist/adt/discovery.js +104 -0
  15. package/dist/adt/discovery.js.map +1 -0
  16. package/dist/adt/errors.d.ts +15 -0
  17. package/dist/adt/errors.d.ts.map +1 -1
  18. package/dist/adt/errors.js +132 -5
  19. package/dist/adt/errors.js.map +1 -1
  20. package/dist/adt/features.d.ts.map +1 -1
  21. package/dist/adt/features.js +5 -2
  22. package/dist/adt/features.js.map +1 -1
  23. package/dist/adt/http.d.ts +12 -1
  24. package/dist/adt/http.d.ts.map +1 -1
  25. package/dist/adt/http.js +110 -5
  26. package/dist/adt/http.js.map +1 -1
  27. package/dist/adt/semaphore.d.ts +24 -0
  28. package/dist/adt/semaphore.d.ts.map +1 -0
  29. package/dist/adt/semaphore.js +56 -0
  30. package/dist/adt/semaphore.js.map +1 -0
  31. package/dist/adt/types.d.ts +4 -0
  32. package/dist/adt/types.d.ts.map +1 -1
  33. package/dist/adt/xml-parser.d.ts +7 -0
  34. package/dist/adt/xml-parser.d.ts.map +1 -1
  35. package/dist/adt/xml-parser.js +80 -0
  36. package/dist/adt/xml-parser.js.map +1 -1
  37. package/dist/handlers/intent.d.ts +4 -0
  38. package/dist/handlers/intent.d.ts.map +1 -1
  39. package/dist/handlers/intent.js +71 -10
  40. package/dist/handlers/intent.js.map +1 -1
  41. package/dist/handlers/schemas.d.ts +10 -0
  42. package/dist/handlers/schemas.d.ts.map +1 -1
  43. package/dist/handlers/schemas.js +34 -4
  44. package/dist/handlers/schemas.js.map +1 -1
  45. package/dist/handlers/tools.d.ts.map +1 -1
  46. package/dist/handlers/tools.js +29 -7
  47. package/dist/handlers/tools.js.map +1 -1
  48. package/dist/server/config.d.ts.map +1 -1
  49. package/dist/server/config.js +6 -0
  50. package/dist/server/config.js.map +1 -1
  51. package/dist/server/server.d.ts +1 -1
  52. package/dist/server/server.d.ts.map +1 -1
  53. package/dist/server/server.js +8 -2
  54. package/dist/server/server.js.map +1 -1
  55. package/dist/server/types.d.ts +2 -0
  56. package/dist/server/types.d.ts.map +1 -1
  57. package/dist/server/types.js +1 -0
  58. package/dist/server/types.js.map +1 -1
  59. package/package.json +1 -1
@@ -14,7 +14,7 @@ import { createObject, deleteObject, lockObject, safeUpdateObject, safeUpdateSou
14
14
  import { buildDataElementXml, buildDomainXml, buildMessageClassXml, buildPackageXml, buildServiceBindingXml, } from '../adt/ddic-xml.js';
15
15
  import { activate, activateBatch, applyFixProposal, getFixProposals, publishServiceBinding, runAtcCheck, runUnitTests, syntaxCheck, unpublishServiceBinding, } from '../adt/devtools.js';
16
16
  import { getDump, getTraceDbAccesses, getTraceHitlist, getTraceStatements, listDumps, listTraces, } from '../adt/diagnostics.js';
17
- import { AdtApiError, AdtNetworkError, AdtSafetyError, isNotFoundError } from '../adt/errors.js';
17
+ import { AdtApiError, AdtNetworkError, AdtSafetyError, classifySapDomainError, isNotFoundError, } from '../adt/errors.js';
18
18
  import { classifyTextSearchError, mapSapReleaseToAbaplintVersion, probeFeatures } from '../adt/features.js';
19
19
  import { addTileToGroup, createCatalog, createGroup, createTile, deleteCatalog, listCatalogs, listGroups, listTiles, } from '../adt/flp.js';
20
20
  import { checkOperation, checkPackage, isOperationAllowed, OperationType } from '../adt/safety.js';
@@ -77,8 +77,8 @@ function textResult(text) {
77
77
  function errorResult(message) {
78
78
  return { content: [{ type: 'text', text: message }], isError: true };
79
79
  }
80
- const DDIC_SAVE_HINT_TYPES = new Set(['TABL', 'DDLS', 'BDEF', 'SRVD', 'SRVB', 'DDLX', 'DOMA', 'DTEL']);
81
- const DDIC_POST_SAVE_CHECK_TYPES = new Set(['TABL', 'DDLS', 'BDEF', 'SRVD', 'SRVB', 'DDLX']);
80
+ const DDIC_SAVE_HINT_TYPES = new Set(['TABL', 'DDLS', 'DCLS', 'BDEF', 'SRVD', 'SRVB', 'DDLX', 'DOMA', 'DTEL']);
81
+ const DDIC_POST_SAVE_CHECK_TYPES = new Set(['TABL', 'DDLS', 'DCLS', 'BDEF', 'SRVD', 'SRVB', 'DDLX']);
82
82
  // ─── Search Helpers ─────────────────────────────────────────────────
83
83
  /**
84
84
  * Transliterate non-ASCII characters in search queries.
@@ -125,6 +125,11 @@ function formatErrorForLLM(err, message, _tool, args) {
125
125
  // Append additional SAP messages (line numbers, secondary errors) if available
126
126
  const enriched = enrichWithSapDetails(err, message);
127
127
  const argType = String(args.type ?? '').toUpperCase();
128
+ const classification = classifySapDomainError(err.statusCode, err.responseBody);
129
+ if (classification) {
130
+ const transactionLine = classification.transaction ? `\nSAP Transaction: ${classification.transaction}` : '';
131
+ return `${enriched}\n\nHint: ${classification.hint}${transactionLine}`;
132
+ }
128
133
  if (err.isNotFound) {
129
134
  const name = String(args.name ?? '');
130
135
  const type = String(args.type ?? '');
@@ -144,6 +149,12 @@ function formatErrorForLLM(err, message, _tool, args) {
144
149
  }
145
150
  // Server errors (500, 502, 503, etc.)
146
151
  if (err.isServerError) {
152
+ // Detect syntax errors in dependent objects (e.g., BDEF syntax errors blocking SRVB activation)
153
+ const syntaxMatch = err.message.match(/[Ss]yntax error in program (\S+)/);
154
+ if (syntaxMatch) {
155
+ const program = syntaxMatch[1].replace(/=+\w*$/, ''); // Strip "====BD" padding
156
+ return `${enriched}\n\nHint: A dependent object has syntax errors that block this operation. The program "${program}" has syntax errors — fix those first, then retry. Use SAPRead to inspect the object, or SAPDiagnose(action="dumps") for details.`;
157
+ }
147
158
  return `${enriched}\n\nHint: SAP application server error (${err.statusCode}). This is often transient — wait 10-30 seconds and retry. If the error persists, check SAPDiagnose(action="dumps") for short dumps, or verify the SAP system is responding via SAPRead(type="SYSTEM").`;
148
159
  }
149
160
  return enriched;
@@ -242,8 +253,10 @@ function getTransportHint(err) {
242
253
  return undefined;
243
254
  }
244
255
  function classifyError(err) {
245
- if (err instanceof AdtApiError)
246
- return 'AdtApiError';
256
+ if (err instanceof AdtApiError) {
257
+ const classification = classifySapDomainError(err.statusCode, err.responseBody);
258
+ return classification ? `AdtApiError:${classification.category}` : 'AdtApiError';
259
+ }
247
260
  if (err instanceof AdtNetworkError)
248
261
  return 'AdtNetworkError';
249
262
  if (err instanceof AdtSafetyError)
@@ -550,6 +563,10 @@ async function handleSAPRead(client, args, cachingLayer) {
550
563
  }
551
564
  return cachedTextResult(ddlSource, cacheHit);
552
565
  }
566
+ case 'DCLS': {
567
+ const { source, cacheHit } = await cachedGet('DCLS', name, () => client.getDcl(name));
568
+ return cachedTextResult(source, cacheHit);
569
+ }
553
570
  case 'BDEF': {
554
571
  const { source, cacheHit } = await cachedGet('BDEF', name, () => client.getBdef(name));
555
572
  return cachedTextResult(source, cacheHit);
@@ -616,7 +633,7 @@ async function handleSAPRead(client, args, cachingLayer) {
616
633
  const explicitType = normalizeObjectType(String(args.objectType ?? ''));
617
634
  const inferredType = explicitType || inferObjectType(name);
618
635
  if (!inferredType) {
619
- return errorResult(`Cannot infer object type from name "${name}". Please specify objectType explicitly (e.g., objectType="CLAS", "INTF", "PROG", "TABL", "DDLS", "FUGR", "DOMA", "DTEL", "SRVD", "SRVB", "BDEF").`);
636
+ return errorResult(`Cannot infer object type from name "${name}". Please specify objectType explicitly (e.g., objectType="CLAS", "INTF", "PROG", "TABL", "DDLS", "DCLS", "FUGR", "DOMA", "DTEL", "SRVD", "SRVB", "BDEF").`);
620
637
  }
621
638
  // Use raw URI (no name encoding) — getApiReleaseState encodes the full URI as a single path segment
622
639
  const objectUri = objectUrlForTypeRaw(inferredType, name);
@@ -730,8 +747,8 @@ async function handleSAPRead(client, args, cachingLayer) {
730
747
  }
731
748
  }
732
749
  default:
733
- return errorResult(`Unknown SAPRead type: "${type}". Supported types: PROG, CLAS, INTF, FUNC, FUGR, INCL, DDLS, DDLX, BDEF, SRVD, SRVB, TABL, VIEW, STRU, DOMA, DTEL, TRAN, TABLE_CONTENTS, DEVC, SOBJ, SYSTEM, COMPONENTS, MESSAGES, TEXT_ELEMENTS, VARIANTS, BSP, BSP_DEPLOY, API_STATE, INACTIVE_OBJECTS. ` +
734
- 'Tip: Type aliases are auto-normalized (e.g., DDLS/DF → DDLS, CLAS/OC → CLAS, PROG/P → PROG). ' +
750
+ return errorResult(`Unknown SAPRead type: "${type}". Supported types: PROG, CLAS, INTF, FUNC, FUGR, INCL, DDLS, DCLS, DDLX, BDEF, SRVD, SRVB, TABL, VIEW, STRU, DOMA, DTEL, TRAN, TABLE_CONTENTS, DEVC, SOBJ, SYSTEM, COMPONENTS, MESSAGES, TEXT_ELEMENTS, VARIANTS, BSP, BSP_DEPLOY, API_STATE, INACTIVE_OBJECTS. ` +
751
+ 'Tip: Type aliases are auto-normalized (e.g., DDLS/DF → DDLS, DCLS/DL → DCLS, CLAS/OC → CLAS, PROG/P → PROG). ' +
735
752
  'Do not pass a URI — use the "type" and "name" parameters instead.');
736
753
  }
737
754
  }
@@ -1228,6 +1245,18 @@ export function buildCreateXml(type, name, pkg, description, properties) {
1228
1245
  adtcore:responsible="DEVELOPER">
1229
1246
  <adtcore:packageRef adtcore:name="${escapeXml(pkg)}"/>
1230
1247
  </ddl:ddlSource>`;
1248
+ case 'DCLS':
1249
+ return `<?xml version="1.0" encoding="UTF-8"?>
1250
+ <dcl:dclSource xmlns:dcl="http://www.sap.com/adt/acm/dclsources"
1251
+ xmlns:adtcore="http://www.sap.com/adt/core"
1252
+ adtcore:description="${escapeXml(description)}"
1253
+ adtcore:name="${escapeXml(name)}"
1254
+ adtcore:type="DCLS/DL"
1255
+ adtcore:masterLanguage="EN"
1256
+ adtcore:masterSystem="H00"
1257
+ adtcore:responsible="DEVELOPER">
1258
+ <adtcore:packageRef adtcore:name="${escapeXml(pkg)}"/>
1259
+ </dcl:dclSource>`;
1231
1260
  case 'TABL':
1232
1261
  // TABL creation also uses SAP's "blue" framework envelope, then source is written via /source/main.
1233
1262
  return `<?xml version="1.0" encoding="UTF-8"?>
@@ -1393,6 +1422,7 @@ const SLASH_TYPE_MAP = {
1393
1422
  'FUGR/F': 'FUGR',
1394
1423
  'FUGR/FF': 'FUGR',
1395
1424
  'DDLS/DF': 'DDLS',
1425
+ 'DCLS/DL': 'DCLS',
1396
1426
  'BDEF/BDO': 'BDEF',
1397
1427
  'SRVD/SRV': 'SRVD',
1398
1428
  'SRVB/SVB': 'SRVB',
@@ -1491,6 +1521,8 @@ function objectBasePath(type) {
1491
1521
  return '/sap/bc/adt/functions/groups/';
1492
1522
  case 'DDLS':
1493
1523
  return '/sap/bc/adt/ddic/ddl/sources/';
1524
+ case 'DCLS':
1525
+ return '/sap/bc/adt/acm/dcl/sources/';
1494
1526
  case 'BDEF':
1495
1527
  return '/sap/bc/adt/bo/behaviordefinitions/';
1496
1528
  case 'SRVD':
@@ -1998,12 +2030,30 @@ async function handleSAPActivate(client, args) {
1998
2030
  const action = String(args.action ?? 'activate');
1999
2031
  const name = String(args.name ?? '');
2000
2032
  const version = String(args.version ?? '0001');
2033
+ const explicitServiceType = args.service_type;
2034
+ // Resolve the OData service type for publish/unpublish endpoints.
2035
+ // Explicit service_type parameter takes precedence; otherwise auto-detect from SRVB metadata.
2036
+ async function resolveServiceType() {
2037
+ if (explicitServiceType === 'odatav4' || explicitServiceType === 'odatav2')
2038
+ return explicitServiceType;
2039
+ try {
2040
+ const srvbJson = await client.getSrvb(name);
2041
+ const srvb = JSON.parse(srvbJson);
2042
+ if (srvb.odataVersion === 'V4')
2043
+ return 'odatav4';
2044
+ }
2045
+ catch {
2046
+ // If readback fails, fall back to odatav2 (legacy default)
2047
+ }
2048
+ return 'odatav2';
2049
+ }
2001
2050
  // Publish service binding
2002
2051
  if (action === 'publish_srvb') {
2003
2052
  if (!name) {
2004
2053
  return errorResult('Missing required "name" parameter for publish_srvb action.');
2005
2054
  }
2006
- const result = await publishServiceBinding(client.http, client.safety, name, version);
2055
+ const serviceType = await resolveServiceType();
2056
+ const result = await publishServiceBinding(client.http, client.safety, name, version, serviceType);
2007
2057
  if (result.severity === 'ERROR') {
2008
2058
  return errorResult(`Failed to publish service binding ${name}: ${result.shortText}${result.longText ? ` — ${result.longText}` : ''}`);
2009
2059
  }
@@ -2037,7 +2087,8 @@ async function handleSAPActivate(client, args) {
2037
2087
  if (!name) {
2038
2088
  return errorResult('Missing required "name" parameter for unpublish_srvb action.');
2039
2089
  }
2040
- const result = await unpublishServiceBinding(client.http, client.safety, name, version);
2090
+ const serviceType = await resolveServiceType();
2091
+ const result = await unpublishServiceBinding(client.http, client.safety, name, version, serviceType);
2041
2092
  if (result.severity === 'ERROR') {
2042
2093
  return errorResult(`Failed to unpublish service binding ${name}: ${result.shortText}${result.longText ? ` — ${result.longText}` : ''}`);
2043
2094
  }
@@ -2567,6 +2618,7 @@ async function handleSAPContext(client, args, cachingLayer) {
2567
2618
  // ─── SAPManage Handler ────────────────────────────────────────────────
2568
2619
  /** Cached feature status — populated on first probe */
2569
2620
  let cachedFeatures;
2621
+ let cachedDiscovery = new Map();
2570
2622
  async function handleSAPManage(client, config, args, cachingLayer, isPerUserClient) {
2571
2623
  const action = String(args.action ?? '');
2572
2624
  const flpUnavailableMessage = 'FLP customization service (PAGE_BUILDER_CUST) is not available on this system. Check ICF service activation in SICF.';
@@ -2831,6 +2883,7 @@ async function handleSAPManage(client, config, args, cachingLayer, isPerUserClie
2831
2883
  /** Reset cached features (for testing) */
2832
2884
  export function resetCachedFeatures() {
2833
2885
  cachedFeatures = undefined;
2886
+ cachedDiscovery = new Map();
2834
2887
  }
2835
2888
  /** Set cached features directly (for testing BTP mode, etc.) */
2836
2889
  export function setCachedFeatures(features) {
@@ -2840,4 +2893,12 @@ export function setCachedFeatures(features) {
2840
2893
  export function getCachedFeatures() {
2841
2894
  return cachedFeatures;
2842
2895
  }
2896
+ /** Set startup-cached ADT discovery MIME map. */
2897
+ export function setCachedDiscovery(map) {
2898
+ cachedDiscovery = map;
2899
+ }
2900
+ /** Get startup-cached ADT discovery MIME map. */
2901
+ export function getCachedDiscovery() {
2902
+ return cachedDiscovery;
2903
+ }
2843
2904
  //# sourceMappingURL=intent.js.map