Files
sim/apps
Waleed 586b97fd17 feat(attio): add attribute tools + fix API alignment gaps (#5445)
* feat(attio): add attribute tools + fix API alignment gaps

- Add 4 new tools: attio_list_attributes, get_attribute, create_attribute, update_attribute
- Add missing completed_at field to task tools
- Fix note tags output to match Attio's actual response shape (workspace-member vs record tags)
- Fix attribute outputs missing is_default_value_enabled, default_value, relationship
- Fix create_comment sending both entry and thread_id (Attio requires exactly one)
- Wire attribute pagination + task sort into the block

* fix(attio): address review feedback on attribute tools

- Throw on invalid config JSON instead of silently overwriting with {}
  (create_attribute, update_attribute)
- create_attribute: omit config field entirely when not provided instead
  of always sending {}
- Add "Leave unchanged" option to Required/Unique dropdowns so
  update_attribute no longer clears existing constraints on unrelated
  field updates
- Fix stale sort param description on list_tasks (was missing
  completed_at:asc/desc variants)

* fix(attio): fix silent update-clobber bugs + complete comment mutual-exclusion

- create_comment: support all 3 of Attio's mutually-exclusive comment
  targets (thread_id, record, entry), not just thread_id/entry
- Fix update_task silently clearing is_completed on unrelated field
  updates (taskIsCompletedUpdate now defaults to "leave unchanged")
- Fix update_list silently resetting workspace_access to full-access on
  unrelated field updates (listWorkspaceAccessUpdate, same pattern)
- create_attribute: restore config:{} as always-required per Attio's
  schema (previously omitted it entirely, which is invalid on create)
- create_record/update_record/assert_record/list_records: throw on
  invalid values/filter/sorts JSON instead of silently substituting {}
  (was a silent data-loss risk on malformed input)
- get_task: drop stray Content-Type header on a GET request
- types.ts: remove two dead unreferenced interfaces, fix
  workspaceMemberAccess type (was string, is actually an array)

* fix(attio): gate operation-specific param mapping on current operation

Params like taskIsCompleted/listWorkspaceAccess/attributeIsMultiselect/
attributeIsArchived are only meant for one specific operation, but their
mapping wasn't checking params.operation. A stale value persisted in
block state from a prior operation selection (e.g. switching the
dropdown from create_task to update_task) could leak through and
override the "leave unchanged" default on the other operation.

* fix(attio): explicit comment target selector + attribute archived tri-state

- Add "Leave unchanged" default to attributeIsArchived dropdown, same
  pattern as isRequired/isUnique, so a stale archived flag from an
  earlier edit can't unarchive an attribute on an unrelated update
- create_comment: replace field-presence inference (which let stale
  record fields hijack a list-entry comment or vice versa) with an
  explicit commentTarget selector (List Entry / Record / Reply to
  Thread). Only the fields for the selected target are ever forwarded

* fix(attio): gate remaining unscoped param mappings + comment-target back-compat

- taskFilterCompleted (list_tasks filter) was mapped to isCompleted for
  every operation; gate it to list_tasks so it can't override the
  isCompleted value on an unrelated update_task call
- Generic threadId (get_thread) was unconditionally forwarded and
  create_comment prioritizes thread_id first, so a leftover threadId
  from configuring get_thread could silently hijack a comment meant for
  a list entry or record; gate it to get_thread
- Default commentTarget to the pre-existing behavior (entry, or thread
  if commentThreadId is set) when absent, so blocks saved before this
  field existed keep working instead of throwing

* fix(attio): gate every param mapping by its operation, eliminate stale-value class of bugs

The params() function reuses cleanParams keys (title, content, apiSlug,
filter, sorts, recordId, entryId, list, object, threadId, ...) across
several unrelated operation families. Every mapping was unconditional on
presence alone, so a stale value left in block state from a previously
selected operation could silently leak into an unrelated request and
overwrite the intended value (last-write-wins on a shared key).

Rewrote the whole function to gate every line by params.operation
against the exact operation set its subBlock's condition exposes it
under, closing this entire bug class in one pass instead of patching
individual instances as they were found in review.

Also split attributeIsRequired/attributeIsUnique into create-only
(default false) and update-only (tri-state, default "leave unchanged")
variants — the shared field let an explicit Yes/No choice from
create_attribute carry over and silently change constraints on an
unrelated update_attribute call.

* fix(attio): preserve legacy taskIsCompleted/listWorkspaceAccess on update

taskIsCompleted and listWorkspaceAccess pre-date this PR as fields
shared between create and update operations (confirmed present on
origin/staging). Splitting them into create/update variants earlier
this session meant existing saved blocks with a value stored under the
legacy field name would silently stop applying it on update_task /
update_list once the new -Update field (always undefined for old
blocks) took over. Fall back to the legacy field when the new field is
untouched, so old saved workflows keep behaving exactly as before.
2026-07-06 17:01:15 -07:00
..