-
Notifications
You must be signed in to change notification settings - Fork 465
[Monorepo] 3. Shared Entities package #3554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: agenta-packages/agenta-ui-initial
Are you sure you want to change the base?
[Monorepo] 3. Shared Entities package #3554
Conversation
Initialize the @agenta/entities workspace package with: - package.json with peer dependencies (jotai, tanstack-query, antd, zod) - TypeScript configuration - Main README with architecture overview - Root index.ts exporting shared utilities Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add the core entity management infrastructure: - molecule/ - Jotai atom factories (createMolecule, extendMolecule, createEntityController, createListExtension) - utils/ - Schema utilities, Zod helpers, transforms, batch operations - user/ - User resolution atoms and UserAuthorLabel component The molecule pattern provides a unified API for entity state management with draft state, dirty detection, and lifecycle management. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Complete testcase entity management with: - core/ - Zod schemas, types, flatten/unflatten utilities - api/ - HTTP functions (single, batch, paginated fetch) - state/ - testcaseMolecule with cell-level subscriptions Features: - Flat/unflatten for table display - Cell-level atom subscriptions (minimal re-renders) - Pagination support with cursor-based navigation - Batch update operations - @internal JSDoc warning for low-level store atoms Co-Authored-By: Claude Opus 4.5 <[email protected]>
Complete testset/revision entity management with: - core/ - Zod schemas for testset, revision, variant - api/ - CRUD operations, file upload/download, clone - state/ - revisionMolecule, testsetMolecule, table state Features: - Revision immutability (editing creates new revision) - Latest revision batch fetching optimization - Table column/row operations with pending state - Clone and archive operations - @internal JSDoc warning for low-level store atoms Co-Authored-By: Claude Opus 4.5 <[email protected]>
Complete trace/span entity management with: - core/ - Zod schemas for TraceSpan, SpanAttributes, enums - api/ - Fetch traces/spans, delete, sessions - state/ - traceSpanMolecule with batch fetching - utils/ - Data selectors (inputs, outputs, agData) Features: - Two-level abstraction (trace for read, span for edit) - Batch fetching with cache redirect - Retry logic for not-yet-ingested data - Auto-mapping for testset column creation - Lifecycle event tracking (mount/unmount) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Entity-agnostic UI components for molecule-based entities: DrillInView/ - MoleculeDrillInView - Hierarchical data navigation - Breadcrumb, FieldList, FieldItem components - ClassNames API for Ant Design v6 style customization modals/ - EntityDeleteModal, EntityCommitModal, EntitySaveModal - Adapter registry for entity-agnostic operations - useSaveOrCommit unified hook selection/ - EntityPicker, EntityCascader, EntityListWithPopover - Hierarchical selection with lazy loading - Pre-built adapters (appRevision, evaluatorRevision, testset) - Renamed CreateAdapterOptions to CreateSelectionAdapterOptions Co-Authored-By: Claude Opus 4.5 <[email protected]>
…/agenta-shared-entities-initial
…itialization with server data awareness - Export InitializeEmptyRevisionParams type from testcase module index and state index - Add InitializeEmptyRevisionParams interface with revisionId, serverTotalCount, and isNewTestset fields - Update initializeEmptyRevisionAtom to accept params object instead of only revisionId string for better API flexibility - Add server data detection using serverTotalCount parameter instead of unre
…and cache redirect support - Add api.ts with HTTP functions and data transformers for app revision entity - Add ApiRevision, EnhancedVariantLike, and RevisionRequest types for API responses and batch operations - Add transformEnhancedVariant function to enable cache redirect from variant revisions cache - Add transformApiRevision function to normalize API responses to internal AppRevisionData format - Add extractAgConfigFromEn
…ents and JSON editor integration - Add BooleanField component with Switch toggle and value mode support for string/native boolean values - Add NumberField component with InputNumber and value mode handling for string/native number values - Add JsonArrayField component with navigation select, JSON editor, and drill-in support for array items - Add JsonObjectField component with ChatMessageEditor detection for message objects an
…and dynamic width based on diff data availability - Add DiffView component from @agenta/ui for displaying configuration changes - Add two-column layout when diff data is available (form left, diff right) - Add diff preview section with changes count header and scrollable content area - Add dynamic modal width: 900px with diff, 520px without diff - Add overflow handling with fixed form width (320px) and flexible diff section - Update
…guration and entity selector enhancements - Add initializeSelection.ts with centralized configuration for all selection adapters (testset, appRevision, evaluatorRevision, user) - Add SelectionSystemConfig, TestsetSelectionConfig, AppRevisionSelectionConfig, and EvaluatorRevisionSelectionConfig types - Add initializeSelectionSystem, resetSelectionSystem, and isSelectionSystemInitialized functions with safe multi-call handling - Export
…ntrols, and selection system initialization to agenta-entities UI module - Add MoleculeDrillInView components (View, Breadcrumb, FieldList, FieldItem, Provider) and useDrillIn hook - Add DrillInUIProvider, useDrillInUI, and defaultShowMessage for UI injection context - Add field renderer components (BooleanField, JsonArrayField, JsonObjectField, MessagesField, NumberField, TextField, RawModeDisplay) - Add field utilities (tryPar
… optional entity implementations - Add evaluatorRevision/index.ts with stub molecule implementation using createStubMolecule factory - Add EvaluatorRevisionData and SettingsPreset types for evaluator revision entity structure - Add evaluatorRevisionMolecule with presets selector (returns empty array) and applyPreset action (no-op) - Add shared/stubMolecule.ts factory for creating placeholder molecule implementations - Add StubQueryState,
…estcase integration, and comprehensive documentation - Add loadable/README.md with architecture overview, API reference, source types (testcase, future trace), and integration details - Add loadable/bridge.ts with loadableBridge configuration using createLoadableBridge factory and testcase source integration - Add loadable/controller.ts with testset-specific controller, testcaseMolecule bridge atoms, and row/column/execution actions
…ema extraction, and comprehensive documentation - Add runnable/README.md with architecture overview, API reference, runnable types (appRevision, evaluatorRevision), execution utilities, and legacy API compatibility notes - Add runnable/bridge.ts with runnableBridge configuration using createRunnableBridge factory and appRevision/evaluatorRevision integrations - Add runnable/context/PlaygroundEntityContext.tsx with legacy DI provider for
…vision, loadable, runnable) with comprehensive peer dependencies for Lexical editor, floating UI, and YAML support; update index.ts documentation to reference subpath imports for all entity modules; export stub molecule and playground bridge utilities from shared/index.ts; update selection adapter README with appRevisionMolecule and evaluatorRevisionMolecule import paths
…o settings_values, and change applyPreset action signature to accept payload object with revisionId and preset instead of separate evaluatorId and presetId parameters
…ider types to separate file - Delete context/PlaygroundEntityContext.tsx with React context implementation (PlaygroundEntityProvider, usePlaygroundEntities, usePlaygroundEntitiesOptional) - Add providerTypes.ts with PlaygroundEntityProviders, EntityRevisionSelectors, EvaluatorRevisionSelectors, EvaluatorRevisionActions, SettingsPreset, AppRevisionRawData, and EvaluatorRevisionRawData type definitions - Update README.md to document provider
…PlaygroundBridge to createEntityBridge
… runnable bridge implementations - Add createEntityBridge.ts with bridge pattern factories for unified entity access across different molecule implementations - Add createLoadableBridge factory with source type configuration (testcase, trace), row/column management, connection state, execution results, and dynamic input support - Add createRunnableBridge factory with runnable type configuration (appRevision, evaluatorRevision),
…/agenta-shared-entities-initial
… in revision queries - Add ReferenceWithLimit model extending Reference with optional limit field for batch query constraints - Update TestsetRevisionQueryRequest to use ReferenceWithLimit for testset_refs to support per-testset limits (e.g., limit=1 for latest) - Implement per-artifact limit in GitDAO.fetch_revisions using ROW_NUMBER() window function partitioned by artifact_id - Add query_variant_revisions endpoint in variants
…/agenta-shared-entities-initial
…g to use shared types - Include ../css-modules.d.ts in tsconfig.json to enable CSS module type support - Remove local SimpleChatMessage interface and import from @agenta/shared instead - Update parseMessageObject to use MessageContent type from shared package with proper type casting for array content - Fix ResponseFormatControl to use handleChange prop instead of onChange for JsonEditor component - Export SimpleChatMessage type
…/agenta-shared-entities-initial
…tices documentation Add detailed documentation for loadable system architecture, reactive patterns, and anti-patterns: - Document abstraction layers (UI → bridge → molecules → state) - Add reactive column derivation pattern (avoid React effect syncs) - Document metadata-based context passing (avoid reverse lookup atoms) - Add compound actions pattern for multi-step operations - Document reactive effect atoms for auto-initialization (
…orts and invocation URL Add optional selector atoms to RunnableTypeConfig for reactive derivation of input/output ports and invocation URL: - Add inputPortsSelector, outputPortsSelector, and invocationUrlSelector to RunnableTypeConfig - Update bridge selectors to prefer selector atoms over extraction functions - Implement selector-based derivation for appRevision (inputPorts, outputPorts, invocationUrl) - Add fallback to extraction functions when selectors not
docs(entities): add comprehensive appRevision entity documentation and API functions Add detailed README for appRevision entity covering architecture, molecule API, and best practices: - Document entity model (App → Variant → Revisions hierarchy) - Add molecule API reference (atoms, selectors, reducers, imperative API) - Document reactive input ports derivation from agConfig template - Document invocation URL resolution from schema query - Add runnable extension and execution modes (direct
feat(entities): add column grouping utilities and selection draft state for testcase entity Add comprehensive column grouping system for hierarchical table display: - Add groupColumns utility with recursive grouping, collapse state, and max depth control - Add isGroupedColumnKey, parseGroupedColumnKey, getLeafColumnName helper functions - Support nested column headers (e.g., "a.b.c" creates a > b > c hierarchy) - Only group columns from object expansion (with parentKey), not flat columns with
feat(entities): add null-safe query selectors for testset molecule Add optional query and data selectors that handle null/undefined IDs: - Add nullQueryResultAtom for empty query results - Add nullDataAtom for null data states - Add queryOptional selector to prevent unnecessary network requests for empty IDs - Add dataOptional selector for null-safe data access - Add JSDoc documentation with usage examples ```
…/agenta-shared-entities-initial
…/agenta-shared-entities-initial
…/agenta-shared-entities-initial
…/agenta-shared-entities-initial
- Add optional chaining for safer property access in schema extraction and state management - Replace 'any' types with proper type assertions and Record types for dynamic access - Add ESLint disable comments with justifications for necessary 'any' usage in Jotai atoms - Improve type safety in runnable hooks with explicit type assertions for provider-specific data - Update QueryState to properly handle null data values - Enhance
…/agenta-shared-entities-initial
…/agenta-shared-entities-initial
…etter type assertions - Add isArray, isRecord, and toArray type guard utilities in appRevision API - Replace unsafe array/object casts with type guards in revision transformers - Add explanatory comments for necessary type assertions in molecule state management - Update FlexibleWritableAtomFamily export and usage in trace molecule - Improve type safety in EntityCascader option rendering with justification comment - Replace 'unknown' c
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| const variables: string[] = [] | ||
|
|
||
| let match: RegExpExecArray | null | ||
| while ((match = variablePattern.exec(input)) !== null) { |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
regular expression
library input
This
regular expression
library input
This
regular expression
library input
This
regular expression
library input
| ? mapping.keyInObject[0] | ||
| : mapping.keyInObject | ||
| if (keyName) { | ||
| targetObj[keyName] = value |
Check warning
Code scanning / CodeQL
Prototype-polluting assignment Medium
library input
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 days ago
In general terms, to fix this problem we must prevent untrusted strings from being used as property names on objects that inherit from Object.prototype. We can do this by either: (a) using a prototype-less object (Object.create(null)) so that even if the key is "__proto__" it does not affect Object.prototype, or (b) validating and rejecting dangerous key names ("__proto__", "prototype", "constructor"), or (c) switching to Map. Given the current code and the need to avoid changing functionality, the least intrusive fix is to keep using plain objects for the API shape but: create the targetObj as a prototype-less object when first created, and/or reject dangerous keys before assignment.
The single best fix here with minimal behavioral change is: when we create targetObj for a given mapping.targetKey, use Object.create(null) instead of {} so it has no prototype, and also explicitly skip assignments when keyName is a prototype-polluting key. We must also ensure that if result[mapping.targetKey] already exists and is not an object, we create a new safe object instead of reusing it unsafely. Concretely, in resolveChainInputs, lines 139–149 are where we construct targetObj and assign targetObj[keyName] = value. We should replace the current initialization:
const targetObj = (result[mapping.targetKey] as Record<string, unknown>) ?? {}
// ...
if (keyName) {
targetObj[keyName] = value
}
result[mapping.targetKey] = targetObjwith logic that:
- Retrieves any existing object for
result[mapping.targetKey]. - If none exists or it is not a plain object, initializes a new prototype-less object via
Object.create(null). - Computes
keyNameas before. - Checks
keyNameis truthy and is not"__proto__","prototype", or"constructor". - Only then assigns
safeTargetObj[keyName] = value. - Stores
safeTargetObjback intoresult[mapping.targetKey].
No new imports or external dependencies are needed; Object.create is part of standard JavaScript.
-
Copy modified lines R140-R144 -
Copy modified lines R149-R155
| @@ -137,12 +137,22 @@ | ||
|
|
||
| // Handle object-type inputs with keyInObject | ||
| if (mapping.keyInObject) { | ||
| const targetObj = (result[mapping.targetKey] as Record<string, unknown>) ?? {} | ||
| const existing = result[mapping.targetKey] | ||
| const targetObj: Record<string, unknown> = | ||
| existing && typeof existing === "object" && existing !== null | ||
| ? (existing as Record<string, unknown>) | ||
| : Object.create(null) | ||
| // keyInObject can be string or string[] - use first element if array | ||
| const keyName = Array.isArray(mapping.keyInObject) | ||
| ? mapping.keyInObject[0] | ||
| : mapping.keyInObject | ||
| if (keyName) { | ||
| // Avoid prototype pollution by rejecting dangerous keys | ||
| if ( | ||
| keyName && | ||
| keyName !== "__proto__" && | ||
| keyName !== "constructor" && | ||
| keyName !== "prototype" | ||
| ) { | ||
| targetObj[keyName] = value | ||
| } | ||
| result[mapping.targetKey] = targetObj |
…/agenta-shared-entities-initial
…g and testcase selection - Add totalRowCountAtomFamily for displaying hidden testcase counts - Extend connectedHasLocalChangesAtomFamily to detect output mapping changes - Fix updateTestcaseSelectionAtom to reset before setting IDs - Apply pending output mappings before committing changes - Add shared index export
…support - Add getItemLabel and getItemDescription to adapter types - Enhance appRevisionAdapter with label/description support - Update evaluatorRevisionAdapter with new type fields - Extend revisionLevelFactory for better revision handling - Update testsetAdapter with label support - Improve adapter README documentation
…upport - Add useEntitySelection facade hook with cascading/breadcrumb/list-popover modes - Add useEntitySelectionCore for shared adapter resolution and state - Add mode-specific hooks: useCascadingMode, useBreadcrumbMode, useListPopoverMode - Add utility hooks: useAutoSelect, useLevelData, usePathBuilder - Support for pagination, auto-select, and disabled items
…e variants - Add UnifiedEntityPicker as main entry point for entity selection UI - Add CascadingVariant for cascading dropdown selection - Add BreadcrumbVariant for breadcrumb-style navigation - Add ListPopoverVariant for list with hover popovers - Add shared components: LevelSelect, AutoSelectHandler, ChildPopoverContent - Support for all selection modes with consistent API
… hooks - Remove EntityCascader, EntityListWithPopover, EntityPicker components - Remove useEntityList, useHierarchicalSelection, useInfiniteList hooks - Remove useLazyChildren, useMultiSelect hooks - Remove INFINITE_SCROLL_PLAN.md planning document These are replaced by UnifiedEntityPicker and useEntitySelection hooks.
… refactor - Update selection module exports for new hooks and components - Update component index to export UnifiedEntityPicker - Update hooks index to export useEntitySelection and related hooks - Add new types for selection modes and results - Update README documentation for all selection modules - Update TestsetPicker to use new selection patterns - Update main UI index exports
…/agenta-shared-entities-initial
…/agenta-shared-entities-initial
…genta/shared - Remove entire src/ui/ directory (DrillInView, modals, selection, testcase UI) - Update package.json to remove './ui' export - Update src/index.ts comments to reference @agenta/entity-ui package - Migrate path utility imports from '../../ui' to '@agenta/shared' in: - testcase/state/molecule.ts - testset/state/revisionMolecule.ts - testset/state/testsetMolecule.ts - trace/state/molecule.ts - appRevision/state/molecule.ts UI components have been moved to the @agenta/entity-ui package.
- Add WorkflowServiceConfiguration schema and types (headers, schemas, script, runtime) - Add HeaderValue schema for secret references in headers - Add LegacyServiceConfig schema for backward compatibility - Extend EnhancedVariantLike interface with workflow fields (url, headers, schemas, script, runtime) - Update transformEnhancedVariant to map new workflow fields - Add documentation for ApiConfigResponse mapping to backend WorkflowRevisionData This aligns the frontend AppRevision types with the backend WorkflowRevisionData structure.
…mation Document the version field transformation from backend string to frontend number in revisionSchema and revisionListItemSchema. This clarifies the type mismatch between backend (Optional[str]) and frontend (number) representations.
- Remove testset/state/adapters.ts (moved to @agenta/entity-ui) - Update testset/state/index.ts to remove adapter exports - Update testset/index.ts to remove adapter re-exports
- Update main README.md with current package structure - Update testcase/README.md with module documentation
Uh oh!
There was an error while loading. Please reload this page.