Class AiToolContext
java.lang.Object
com.kingsrook.qqq.backend.core.actions.ai.tools.AiToolContext
Per-call context for an AI tool: the kernel's instance, settings, exposure
policy and redactor, the result being built - and the shared checks and
output shaping every tool uses (so no tool can forget one):
- visibility (the meta-data customizer, and DENY_HIDE) and exposure checks,
- the table READ permission check (recorded in the result's permissionCheck),
- action-input preparation (input source USER, omit hidden fields, mask
passwords, and the core-enforcement hook),
- value shaping: exposure post-filter, masking, redaction and truncation.
Created by the kernel, inside the requesting user's QContext.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAiToolContext(QInstance qInstance, AiToolKernelSettings settings, AiExposurePolicy exposurePolicy, AiRedactor redactor, AiToolResult result) Constructor -
Method Summary
Modifier and TypeMethodDescriptionbooleancanReadTable(QTableMetaData table) Whether the session may read a table through the assistant (same checks as requireReadableTable, without recording or throwing).displayValue(QTableMetaData table, QFieldMetaData field, QRecord record) The value of one field of a record, shaped for its exposure: - NONE / METADATA_ONLY: null (and nothing should be output), - MASKED: the masked display (or raw) value, - VALUES: the display value (or raw value), redacted and truncated.How the data tools read data: the settings' gateway (the assistant's UI API gateway), else the core actions.getDefaultValueFields(QTableMetaData personalizedTable) The fields whose values may be sent to the model by default: exposure MASKED or VALUES, and not heavy or binary.getFieldAccessReason(QTableMetaData table, QFieldMetaData field) The reason from the single core decision, used by access reports.getFieldExposure(QTableMetaData table, QFieldMetaData field) Deprecated.use FieldAccessHelper.getDecision for access decisions.intThe maximum rows to send to the model.getNameableFields(QTableMetaData personalizedTable) The fields of a (personalized) table the assistant may name - in filters, sorts and field lists - that is, those whose exposure is not NONE.Getter for qInstanceThe redactions made so far (sorted, distinct).Getter for resultGetter for settingsgetTableExposure(QTableMetaData table) The effective exposure of a table.booleanhasTablePermission(QTableMetaData table, TablePermissionSubType permissionSubType) Whether the session has a (non-READ) permission on a table.booleanisAllowed(MetaDataWithPermissionRules object) Whether a meta-data object is visible to the session AND its permission check fully allows it (not DENY_HIDE, not DENY_DISABLE).booleanisVisible(MetaDataWithPermissionRules object) Whether a meta-data object (table, process, report, widget, app) is visible to the session - the same rule as MetaDataAction: allowed by any meta-data action customizer, and its permission check is not DENY_HIDE.mask(QTableMetaData table, QFieldMetaData field, String value) Mask a value of a MASKED field (noting the masking in the redactions).personalize(QTableMetaData table) The table as personalized for this session (fields the session may not see removed by any table personalizer).voidprepareInput(AbstractActionInput input) Prepare an action input the kernel will run: input source USER (for table, search and widget inputs) and, for query and get, omit hidden fields and mask passwords - then the core permission-enforcement hook.voidputModelValue(Map<String, Object> values, QTableMetaData table, QFieldMetaData field, QRecord record) Add the value of one field of a record to a map for the model: for VALUES fields, the raw value (numbers and booleans as-is, others redacted and truncated) - plus, when it differs, the display value as {field}__display; for MASKED fields, only the masked value; for others, nothing.recordLabel(QTableMetaData personalizedTable, QRecord record) A label for a record that is safe to send: the record's label if every field in the table's record label is exposed with VALUES - else the table label and the record's id.recordRef(QTableMetaData personalizedTable, QRecord record) A record reference (for a record chip) - with a safe label.requireReadableTable(String tableName) The table, if this session may read it through the assistant: it exists, is visible to the session (not DENY_HIDE, allowed by any meta-data action customizer), is exposed (not NONE), and the session has READ on it.Redact, then truncate, a string for the model (or the UI).static Stringstringify(Serializable value) A value as a string (temporal values in ISO form, decimals plain).static AiToolExceptiontableNotAvailable(String tableName) The DENIED exception for a table that is missing, invisible, unexposed or not readable.booleanwouldTruncate(String value) Whether sanitize would truncate a value.
-
Field Details
-
TRUNCATION_MARKER
- See Also:
-
-
Constructor Details
-
AiToolContext
public AiToolContext(QInstance qInstance, AiToolKernelSettings settings, AiExposurePolicy exposurePolicy, AiRedactor redactor, AiToolResult result) Constructor
-
-
Method Details
-
getDataGateway
How the data tools read data: the settings' gateway (the assistant's UI API gateway), else the core actions. -
requireReadableTable
The table, if this session may read it through the assistant: it exists, is visible to the session (not DENY_HIDE, allowed by any meta-data action customizer), is exposed (not NONE), and the session has READ on it. Otherwise a DENIED exception - with the same message in every case, so a caller can't tell a missing table from a forbidden one.- Throws:
AiToolException
-
tableNotAvailable
The DENIED exception for a table that is missing, invisible, unexposed or not readable. -
canReadTable
Whether the session may read a table through the assistant (same checks as requireReadableTable, without recording or throwing). -
hasTablePermission
Whether the session has a (non-READ) permission on a table. -
isVisible
Whether a meta-data object (table, process, report, widget, app) is visible to the session - the same rule as MetaDataAction: allowed by any meta-data action customizer, and its permission check is not DENY_HIDE. -
isAllowed
Whether a meta-data object is visible to the session AND its permission check fully allows it (not DENY_HIDE, not DENY_DISABLE). -
personalize
The table as personalized for this session (fields the session may not see removed by any table personalizer).- Throws:
QException
-
getNameableFields
The fields of a (personalized) table the assistant may name - in filters, sorts and field lists - that is, those whose exposure is not NONE. -
getDefaultValueFields
The fields whose values may be sent to the model by default: exposure MASKED or VALUES, and not heavy or binary. -
getFieldExposure
Deprecated.use FieldAccessHelper.getDecision for access decisions.Compatibility projection of the core decision. Metadata-only still omits values from model output, so retain that channel policy reason. -
getFieldAccessReason
The reason from the single core decision, used by access reports. -
getTableExposure
The effective exposure of a table. -
prepareInput
Prepare an action input the kernel will run: input source USER (for table, search and widget inputs) and, for query and get, omit hidden fields and mask passwords - then the core permission-enforcement hook. -
sanitize
-
wouldTruncate
Whether sanitize would truncate a value. -
mask
Mask a value of a MASKED field (noting the masking in the redactions). -
displayValue
The value of one field of a record, shaped for its exposure: - NONE / METADATA_ONLY: null (and nothing should be output), - MASKED: the masked display (or raw) value, - VALUES: the display value (or raw value), redacted and truncated. -
putModelValue
public void putModelValue(Map<String, Object> values, QTableMetaData table, QFieldMetaData field, QRecord record) Add the value of one field of a record to a map for the model: for VALUES fields, the raw value (numbers and booleans as-is, others redacted and truncated) - plus, when it differs, the display value as {field}__display; for MASKED fields, only the masked value; for others, nothing. -
recordLabel
A label for a record that is safe to send: the record's label if every field in the table's record label is exposed with VALUES - else the table label and the record's id. -
recordRef
A record reference (for a record chip) - with a safe label. -
stringify
A value as a string (temporal values in ISO form, decimals plain). -
getQInstance
Getter for qInstance -
getSettings
Getter for settings -
getMaxRowsToModel
public int getMaxRowsToModel()The maximum rows to send to the model. -
getResult
Getter for result -
getRedactions
-