Skip to content

Commit 474d921

Browse files
Copilothotlong
andauthored
Merge origin/main into claude/add-metadata-history-support, resolve CHANGELOG conflict
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
2 parents a56cc68 + 83964b8 commit 474d921

42 files changed

Lines changed: 3136 additions & 177 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
ServiceNow Update Sets. See `docs/METADATA_HISTORY.md` for detailed usage.
2323
([Phase 4a: Metadata Versioning & History](https://github.com/objectstack-ai/framework/issues/XXXX))
2424

25+
- **CLI: Remote API Commands** - Added 12 new CLI commands for interacting with remote ObjectStack servers:
26+
- **Authentication**: `os auth login`, `os auth logout`, `os auth whoami`
27+
- **Data API**: `os data query`, `os data get`, `os data create`, `os data update`, `os data delete`
28+
- **Metadata API**: `os meta list`, `os meta get`, `os meta register`, `os meta delete`
29+
- All commands support `--url` and `--token` flags, or use stored credentials from `~/.objectstack/credentials.json`
30+
- Multiple output formats: `--format json|table|yaml` (yaml available on all commands)
31+
- Environment variable support: `OBJECTSTACK_URL`, `OBJECTSTACK_TOKEN`
32+
- See [REMOTE_API_COMMANDS.md](./REMOTE_API_COMMANDS.md) for full documentation
33+
2534
### Changed
2635
- **i18n: `I18nLabelSchema` now accepts `string` only**`label`, `description`, `title`,
2736
and other display-text fields across all UI schemas (`AppSchema`, `NavigationArea`,
@@ -86,6 +95,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8695
absent, fixing the CI `@objectstack/client#test` failure.
8796

8897
### Added
98+
- **Metadata Assistant Agent (`service-ai`)** — New `metadata_assistant` agent definition that
99+
binds all 6 metadata management tools (`create_object`, `add_field`, `modify_field`,
100+
`delete_field`, `list_metadata_objects`, `describe_metadata_object`). Includes a tailored
101+
system prompt that guides the AI to use snake_case naming, verify existing schemas before
102+
modifications, and warn about destructive operations. Configured with `react` planning
103+
strategy (10 iterations, replan enabled) for multi-step schema design conversations.
104+
- **Tool Confirmation Flags** — Added `requiresConfirmation: true` to `create_object` and
105+
`delete_field` tool definitions. These destructive/creation operations now signal to the
106+
frontend that user approval is needed before execution.
107+
- **Frontend Tool Call Display (`AiChatPanel`)** — Enhanced the AI Chat Panel to render tool
108+
invocation parts from the Vercel AI SDK v6 stream protocol. Displays tool call status with
109+
visual indicators:
110+
- **Calling**: Spinner animation with tool name and argument summary
111+
- **Confirmation**: Yellow-bordered card with Approve/Deny buttons for `requiresConfirmation` tools
112+
- **Success**: Green success indicator with result preview
113+
- **Error**: Red error indicator with error message
114+
- **Denied**: Muted indicator for user-denied operations
115+
- **Operation Confirmation Mechanism** — Integrated the Vercel AI SDK `addToolApprovalResponse`
116+
hook to support approval/denial workflows for tools marked with `requiresConfirmation`.
117+
When the server sends an `approval-requested` state, the chat panel shows Approve and Deny
118+
buttons. User decisions are sent back to the server to continue or abort the tool execution.
89119
- **Metadata Management Tools (`service-ai`)** — Added 6 built-in AI tools for metadata
90120
CRUD operations, each defined as a first-class `Tool` metadata file using `defineTool()`
91121
from `@objectstack/spec/ai`:

REMOTE_API_COMMANDS.md

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# Remote API Commands
2+
3+
The ObjectStack CLI now includes commands to interact with a running ObjectStack server via its REST APIs.
4+
5+
## Authentication
6+
7+
Before using remote API commands, you need to authenticate:
8+
9+
```bash
10+
# Login and store credentials
11+
os auth login --url https://api.example.com
12+
13+
# Show current session
14+
os auth whoami
15+
16+
# Logout (clear stored credentials)
17+
os auth logout
18+
```
19+
20+
Credentials are stored in `~/.objectstack/credentials.json` and automatically used for subsequent commands.
21+
22+
Alternatively, you can provide credentials via environment variables or flags:
23+
24+
```bash
25+
# Using environment variables
26+
export OBJECTSTACK_URL=https://api.example.com
27+
export OBJECTSTACK_TOKEN=your-token-here
28+
29+
# Using flags
30+
os data query project_task --url https://api.example.com --token your-token-here
31+
```
32+
33+
## Data API Commands
34+
35+
### Query Records
36+
37+
```bash
38+
# Query all records
39+
os data query project_task
40+
41+
# Filter records
42+
os data query project_task --filter '{"status":"open"}'
43+
44+
# Limit and pagination
45+
os data query project_task --limit 10 --offset 0
46+
47+
# Select specific fields
48+
os data query project_task --fields name,status,created_at
49+
50+
# Sort results
51+
os data query project_task --sort -created_at # descending
52+
os data query project_task --sort created_at # ascending
53+
54+
# Output formats
55+
os data query project_task --format json
56+
os data query project_task --format yaml
57+
os data query project_task --format table # default
58+
```
59+
60+
### Get a Single Record
61+
62+
```bash
63+
os data get project_task abc123
64+
os data get project_task abc123 --format json
65+
```
66+
67+
### Create a Record
68+
69+
```bash
70+
# From JSON string
71+
os data create project_task '{"name":"New Task","status":"open"}'
72+
73+
# From JSON file
74+
os data create project_task --data task.json
75+
```
76+
77+
### Update a Record
78+
79+
```bash
80+
# From JSON string
81+
os data update project_task abc123 '{"status":"completed"}'
82+
83+
# From JSON file
84+
os data update project_task abc123 --data update.json
85+
```
86+
87+
### Delete a Record
88+
89+
```bash
90+
os data delete project_task abc123
91+
```
92+
93+
## Metadata API Commands
94+
95+
### List Metadata Types
96+
97+
```bash
98+
# List all available metadata types
99+
os meta list
100+
101+
# List items of a specific type
102+
os meta list object
103+
os meta list plugin
104+
os meta list view
105+
```
106+
107+
### Get Metadata Item
108+
109+
```bash
110+
os meta get object project_task
111+
os meta get plugin my-plugin --format json
112+
```
113+
114+
### Register Metadata
115+
116+
```bash
117+
# Register from JSON file
118+
os meta register object --data object-definition.json
119+
os meta register plugin --data plugin-manifest.json
120+
```
121+
122+
The metadata file must include a `name` field:
123+
124+
```json
125+
{
126+
"name": "my_custom_object",
127+
"label": "My Custom Object",
128+
"fields": {
129+
"name": {
130+
"type": "text",
131+
"label": "Name"
132+
}
133+
}
134+
}
135+
```
136+
137+
### Delete Metadata
138+
139+
```bash
140+
os meta delete object my_custom_object
141+
os meta delete plugin my-plugin
142+
```
143+
144+
## Output Formats
145+
146+
Most commands support multiple output formats via the `--format` flag:
147+
148+
- `json` - Machine-readable JSON output
149+
- `yaml` - Human-readable YAML output
150+
- `table` - Formatted table output (default for most commands)
151+
152+
## Environment Variables
153+
154+
The following environment variables are supported:
155+
156+
- `OBJECTSTACK_URL` - Default server URL (default: `http://localhost:3000`)
157+
- `OBJECTSTACK_TOKEN` - Authentication token (alternative to `os auth login`)
158+
159+
## Examples
160+
161+
### Complete Workflow
162+
163+
```bash
164+
# 1. Login
165+
os auth login --url https://api.example.com
166+
Email: user@example.com
167+
Password: ********
168+
169+
# 2. Query data
170+
os data query project_task --filter '{"status":"open"}' --limit 5
171+
172+
# 3. Create a new record
173+
os data create project_task '{"name":"Implement feature","status":"open","priority":"high"}'
174+
175+
# 4. Update the record
176+
os data update project_task abc123 '{"status":"in_progress"}'
177+
178+
# 5. List metadata
179+
os meta list object
180+
181+
# 6. Get object definition
182+
os meta get object project_task --format yaml
183+
```
184+
185+
### CI/CD Integration
186+
187+
```bash
188+
# Use token authentication in CI/CD pipelines
189+
export OBJECTSTACK_URL=https://api.production.com
190+
export OBJECTSTACK_TOKEN=${{ secrets.OBJECTSTACK_TOKEN }}
191+
192+
# Deploy metadata
193+
os meta register object --data objects/project_task.json
194+
195+
# Verify deployment
196+
os meta get object project_task --format json
197+
```

0 commit comments

Comments
 (0)