-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcreate-object.tool.ts
More file actions
70 lines (68 loc) · 2.54 KB
/
Copy pathcreate-object.tool.ts
File metadata and controls
70 lines (68 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { defineTool } from '@objectstack/spec/ai';
/**
* create_object — AI Tool Metadata
*
* Creates a new data object (table) with schema validation.
* Validates snake_case naming for object and initial fields,
* checks for duplicates, and registers the object definition.
*/
export const createObjectTool = defineTool({
name: 'create_object',
label: 'Create Object',
description:
'Creates a new data object (table) with the specified name, label, and optional field definitions. ' +
'Use this when the user wants to create a new entity, table, or data model.',
category: 'data',
builtIn: true,
// NOTE: requiresConfirmation is intentionally false (default) because the
// server-side tool-call loop in AIService.chatWithTools/streamChatWithTools
// executes tool calls immediately without checking this flag. The flag
// should only be set once server-side approval gating is implemented to
// avoid giving users a false sense of safety.
parameters: {
type: 'object',
properties: {
name: {
type: 'string',
description: 'Machine name for the object (snake_case, e.g. project_task)',
},
label: {
type: 'string',
description: 'Human-readable display name (e.g. Project Task)',
},
packageId: {
type: 'string',
description: 'Package ID that will own this object (e.g., com.acme.crm). If not provided, uses the active package from conversation context.',
},
fields: {
type: 'array',
description: 'Initial fields to create with the object',
items: {
type: 'object',
properties: {
name: { type: 'string', description: 'Field machine name (snake_case)' },
label: { type: 'string', description: 'Field display name' },
type: {
type: 'string',
description: 'Field data type',
enum: ['text', 'textarea', 'number', 'boolean', 'date', 'datetime', 'select', 'lookup', 'formula', 'autonumber'],
},
required: { type: 'boolean', description: 'Whether the field is required' },
},
required: ['name', 'type'],
},
},
enableFeatures: {
type: 'object',
description: 'Object capability flags',
properties: {
trackHistory: { type: 'boolean' },
apiEnabled: { type: 'boolean' },
},
},
},
required: ['name', 'label'],
additionalProperties: false,
},
});