Developers / SDKs

Request an account brief

The installed example asks Dex for an account summary, open opportunities, risks, source references, and missing data. It shows the pattern for any task: read-only policy, a background worker, approval decisions, and receipts.

Before starting

This installed example reads a CRM. Its handling of checkpoints, approvals, and receipts is the same for a task whose actions change a connected system under your policy.

Install the package and configure credentials. Connect your CRM and apply a workspace policy that permits CRM reads only. The prompt asks Dex to leave records unchanged; the workspace policy enforces which actions are allowed.

Replace the account name and channel ID below. Use the ID of the business event that triggered the request for --trigger. Each new request needs a different trigger ID.

Check setup, submit, and retrieve the brief

Python · Shell
python -m deixic.examples.account_brief check --channel company
python -m deixic.examples.account_brief start account-brief.json \
  --channel company --account 'Example account' --trigger crm-event-001 --structured

# Run in a separate process after submission:
python -m deixic.examples.account_brief resume account-brief.json --progress

TypeScript · Shell
npx --no-install deixic-account-brief check --channel company
npx --no-install deixic-account-brief start account-brief.json \
  --channel company --account 'Example account' --trigger crm-event-001 --structured

# Run in a separate process after submission:
npx --no-install deixic-account-brief resume account-brief.json --progress

check reads channel access, workspace prerequisites, and model availability. An accessible result confirms read access. Write authorization is checked when you submit. Review the reported requirements and model readiness before starting.

Read the result

start creates the private checkpoint before sending and reports acceptance. resume prints the validated JSON brief and referenced receipt outcomes. --structured saves the requested format in the original request; a restarted worker validates it automatically. --progress writes matching event IDs, turn IDs, and event kinds to stderr; final JSON goes to stdout.

Account-brief command exit codes
CodeMeaning
0Submission or decision was accepted, or the resumed answer passed validation with no returned receipt needing attention.
2The work is unfinished, waiting, invalid, failed, or has a receipt needing attention.
1A configuration, storage, or SDK error occurred.

If CRM data is missing, check the CRM connection and its read permissions.

Validate the brief before using it

The versioned format separates facts, source references, and missing data. This sample shows its fields; its records are illustrative.

{
  "schemaVersion": "deixic.account-brief.v1",
  "accountName": "Example account",
  "summary": {"text": "An active account", "sourceIds": ["account"]},
  "opportunities": [],
  "risks": [],
  "sources": [{"id": "account", "system": "crm", "resourceId": "account-1"}],
  "missingData": ["Contract end date"]
}

Each opportunity has name, stage, andsourceIds. Each risk has description andsourceIds. Factual items require at least one unique ID from sources. The parser rejects unknown or duplicate fields, unsupported versions, invalid types, empty facts, and dangling references. Lists are limited to 100 items. The account name must match the original request.

When CRM data is unavailable, the answer uses summary: null, empty factual lists, and an explanation in missingData. Validation checks the format and reference linkage. Verify the actual source records and freshness before relying on the claims.

Invalid output returns invalid_result with remote statuscompleted and exit code 2. Inspect the completed answer. The application never silently resubmits or retries the model. Plain-text requests remain supported when --structured is omitted.

Connect a trigger to a background worker

Map one CRM event to one stable trigger ID and one checkpoint path. The event handler runs start and exits after acceptance. A separately scheduled worker runs resume. Retain the checkpoint when observation ends so the next worker observes the same task.

Use one writer per checkpoint; submission and observation must not run concurrently for the same file. Deduplicate progress effects by event ID, because callbacks may repeat after a crash. Python's--timeout uses seconds; TypeScript's uses milliseconds.

The file example requires a private directory on a durable POSIX filesystem supporting atomic rename, hard links, and fsync. It publishes complete private checkpoint files and syncs them before submission. For a hosted application, use your existing job queue and tenant-bound durable storage callback. Apply your customer-data retention policy to checkpoints, results, and abandoned temporary files.

Review an approval request

A waiting result contains its retained request ID. Review the requested action in Deixic, then choose approve or denywith an operator credential authorized to make that decision. A task token does not grant approval rights.

Python · Shell
# Review the action and choose approve or deny using an authorized operator token.
python -m deixic.examples.account_brief approve account-brief.json \
  --request APPROVAL_REQUEST_ID --decision-key decision-001
python -m deixic.examples.account_brief resume account-brief.json

TypeScript · Shell
# Review the action and choose approve or deny using an authorized operator token.
npx --no-install deixic-account-brief approve account-brief.json \
  --request APPROVAL_REQUEST_ID --decision-key decision-001
npx --no-install deixic-account-brief resume account-brief.json

The command re-fetches the current request and refuses mismatched IDs, non-approval requests, and unavailable history. Deixic authorizes the decision. Keep the same decision and key if its response is lost. Resume to observe the outcome after a decision is submitted. Missing history stays waiting/request_not_visible; use Deixic's approval view. Observation sends no automatic approvals.

Inspect each action receipt

completed means the accepted turn produced its linked final answer. The separate actions list contains receipt IDs, owner services, object IDs, lifecycle states, and evidence references. TypeScript field names use camelCase; Python uses snake_case.

owner_reported_success means every returned receipt is SUCCEEDED or VERIFIED. Confirm the relevant owner, object, action, and source evidence before telling a customer a CRM record changed. Failed, denied, unavailable, waiting, and unspecified states require attention and return exit code 2 even if the answer completed. No receipts meansnot_reported. This account-brief request asks for CRM reads.

After a restart

Run resume with the saved file to observe the same accepted task without submitting another request. Python and TypeScript share the checkpoint format; either example resumes the file with the same organization, workspace, and service URL.

Protect the checkpoint as company data and use one writer per file. A new start refuses an existing checkpoint path. If the submission response was lost, replay the saved request explicitly.