Skip to content

feat: add agent adl commands for Agentforce Data Library management @W-22787736#435

Open
bobby-sf wants to merge 6 commits into
salesforcecli:mainfrom
bobby-sf:feat/adl-integration
Open

feat: add agent adl commands for Agentforce Data Library management @W-22787736#435
bobby-sf wants to merge 6 commits into
salesforcecli:mainfrom
bobby-sf:feat/adl-integration

Conversation

@bobby-sf
Copy link
Copy Markdown

@bobby-sf bobby-sf commented Jun 2, 2026

Implements CLI commands for the ADL Connect API under agent adl:

Library CRUD:

  • list, create, get, update, delete, status

File operations (SFDRIVE):

  • upload (multi-step: readiness → presigned URL → S3 PUT → indexing)
  • file add (day-1 additions to READY libraries)
  • file list (via detail endpoint groundingFileRefs)
  • file delete

Source type support:

  • SFDRIVE: full upload + indexing lifecycle with --wait polling
  • KNOWLEDGE: auto-triggers /indexing on create; update supports --content-fields and --restrict-to-public-articles (server-side re-index)
  • RETRIEVER: immediately READY on create with --retriever-id

Key behaviors:

  • Upload-readiness retries up to 3x (6 min total) for slow UDLO activation
  • S3 upload uses fetch() directly (not connection.request) with verbatim headers
  • Polling gates on retrieverId from detail endpoint (not top-level status)
  • All commands in preview state pending ADL GA
  • Table output for list command

Includes 21 unit tests + NUT tests for all three source types:
TARGET_ORG=sdb3 RETRIEVER_ID= yarn test:nuts --grep "agent adl"

Also fixes pre-existing TS error in agent test create (testRunner option).

What does this PR do?

Adds sf agent adl CLI commands for Agentforce Data Library management — thin wrappers around AgentDataLibrary from @salesforce/agents. 10 commands covering library CRUD, indexing status, file upload (Day-0), and file additions (Day-1) for SFDRIVE, KNOWLEDGE, and RETRIEVER source types. All commands in preview state.

Depends on: forcedotcom/agents#296

What issues does this PR fix or reference?

@W-22787736@

…W-22787736@

Implements CLI commands for the ADL Connect API under `agent adl`:

Library CRUD:
- list, create, get, update, delete, status

File operations (SFDRIVE):
- upload (multi-step: readiness → presigned URL → S3 PUT → indexing)
- file add (day-1 additions to READY libraries)
- file list (via detail endpoint groundingFileRefs)
- file delete

Source type support:
- SFDRIVE: full upload + indexing lifecycle with --wait polling
- KNOWLEDGE: auto-triggers /indexing on create; update supports
  --content-fields and --restrict-to-public-articles (server-side re-index)
- RETRIEVER: immediately READY on create with --retriever-id

Key behaviors:
- Upload-readiness retries up to 3x (6 min total) for slow UDLO activation
- S3 upload uses fetch() directly (not connection.request) with verbatim headers
- Polling gates on retrieverId from detail endpoint (not top-level status)
- All commands in preview state pending ADL GA
- Table output for list command

Includes 21 unit tests + NUT tests for all three source types:
  TARGET_ORG=sdb3 RETRIEVER_ID=<id> yarn test:nuts --grep "agent adl"

Also fixes pre-existing TS error in agent test create (testRunner option).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bobby-sf bobby-sf requested a review from a team as a code owner June 2, 2026 05:28
@salesforce-cla
Copy link
Copy Markdown

salesforce-cla Bot commented Jun 2, 2026

Thanks for the contribution! It looks like @bobby-sf is an internal user so signing the CLA is not required. However, we need to confirm this.

@bobby-sf
Copy link
Copy Markdown
Author

bobby-sf commented Jun 2, 2026

Manual Testing Nuts tests (against an test org with Data Cloud Tenant provisioned in sdb14).

% TARGET_ORG=sdb14-d1R RETRIEVER_ID=1CxRZ0000006CGD0A2 yarn test:nuts --grep "agent adl"
yarn run v1.22.22
$ nyc mocha "test/nuts/**/*.nut.ts" --slow 4500 --timeout 600000 --reporter-options maxDiffSize=15000 --exit --grep 'agent adl'
(node:50967) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:50967) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:50967) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:50967) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:50967) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:50967) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)


  agent adl SFDRIVE NUTs
ADL API accessible — 8 existing libraries
    ✔ should verify ADL prerequisites (Data Cloud + API access) (3828ms)
Created SFDRIVE library: 1JDRZ000000p2kX4AQ
    ✔ should create an SFDRIVE library (10827ms)
    ✔ should list libraries and include the created one (10821ms)
    ✔ should get library detail (9960ms)
    ✔ should get indexing status (10791ms)
    ✔ should upload a file and wait for READY (73850ms)
    ✔ should update library metadata (9238ms)
    ✔ should add a second file (day-1 flow) (21800ms)
    ✔ should list files in the library (10143ms)
Deleted library 1JDRZ000000p2kX4AQ
    ✔ should delete the library (best-effort cleanup) (12782ms)

  agent adl KNOWLEDGE NUTs
Created KNOWLEDGE library: 1JDRZ000000p2m94AA
    ✔ should create a KNOWLEDGE library (auto-triggers indexing) (20163ms)
    ✔ should get Knowledge library detail (10782ms)
    ✔ should get Knowledge indexing status (9800ms)
Update skipped — library still provisioning (expected for freshly created Knowledge)
    ✔ should update Knowledge metadata (best-effort — may fail if still provisioning) (10819ms)
Deleted Knowledge library 1JDRZ000000p2m94AA
    ✔ should delete Knowledge library (best-effort cleanup) (15785ms)

  agent adl RETRIEVER NUTs
Created RETRIEVER library: 1JDRZ000000p2nl4AA
    ✔ should create a RETRIEVER library (immediately READY) (6162ms)
    ✔ should get Retriever library detail with status READY (8795ms)
    ✔ should update Retriever library metadata (10814ms)
Deleted Retriever library 1JDRZ000000p2nl4AA
    ✔ should delete Retriever library (11798ms)


  19 passing (5m)

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |
----------|---------|----------|---------|---------|-------------------
✨  Done in 285.23s.

Unit Tests

% ./node_modules/.bin/mocha "test/commands/agent/adl/**/*.test.ts" --timeout 30000 --exit
(node:64255) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:64255) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:64255) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:64255) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)


  agent adl create
    ✔ should create an SFDRIVE library
    ✔ should require primary-index-field1 and field2 for KNOWLEDGE
    ✔ should require retriever-id for RETRIEVER
(node:64255) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
    ✔ should create a KNOWLEDGE library with index fields (9217ms)
    ✔ should throw CreateFailed on API error

  agent adl delete
    ✔ should delete a library and return success
    ✔ should throw DeleteFailed on API error

  agent adl file list
    ✔ should return files from groundingSource.groundingFileRefs
(node:64255) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
(node:64255) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
(node:64255) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGHUP listeners added to [process]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
    ✔ should return empty array when no files
    ✔ should handle missing groundingSource gracefully
(node:64255) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGBREAK listeners added to [process]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
    ✔ should throw ListFailed on API error

  agent adl get
    ✔ should return library detail
    ✔ should throw GetFailed on API error

  agent adl list
    ✔ should return libraries from the API
    ✔ should throw ListFailed on API error

  agent adl status
    ✔ should return indexing status with stage details
    ✔ should throw StatusFailed on API error

  agent adl update
    ✔ should update metadata fields
    ✔ should include knowledgeConfig when content-fields provided
    ✔ should include restrict-to-public-articles flag
    ✔ should throw UpdateFailed on API error


  21 passing (9s)

bobby-sf added 3 commits June 2, 2026 09:26
  - update command now validates sourceType is KNOWLEDGE before sending knowledgeConfig
  - Fix Answer**c typo in messages (should be Answer__c)
  - Revert test/create.ts type assertion (not our change to own)
  - Update unit tests for new update validation flow
…le delete

  - F-003: --index-mode enhanced passes ENHANCED to groundingSource
  - K-010: knowledge flags on non-KNOWLEDGE library triggers warning
  - F-013: file delete command unit tests (success + error)
…file list

  - RETRIEVER described as existing active Custom Retriever in create description
  - retriever-id flag clarifies retriever must be active
  - source-type flag describes each type inline
  - upload description mentions RETRIEVER does not need upload
  - file list removes paginated (not using paginated endpoint yet)
@bobby-sf
Copy link
Copy Markdown
Author

bobby-sf commented Jun 2, 2026

/cla

@bobby-sf
Copy link
Copy Markdown
Author

bobby-sf commented Jun 2, 2026

recheck

@bobby-sf
Copy link
Copy Markdown
Author

bobby-sf commented Jun 2, 2026

/cla

@bobby-sf
Copy link
Copy Markdown
Author

bobby-sf commented Jun 2, 2026

recheck

@bobby-sf
Copy link
Copy Markdown
Author

bobby-sf commented Jun 2, 2026

/cla

@bobby-sf
Copy link
Copy Markdown
Author

bobby-sf commented Jun 2, 2026

recheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants