@takeshape/schema 11.99.0 → 11.102.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents.d.ts +11 -8
- package/dist/agents.js +34 -19
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/migration/types.d.ts +6 -3
- package/dist/migration/types.js +3 -1
- package/dist/project-schema/latest.d.ts +2 -2
- package/dist/project-schema/v3.48.0.d.ts +2 -2
- package/dist/project-schema/v3.49.0.d.ts +2 -2
- package/dist/project-schema/v3.50.0.d.ts +2 -2
- package/dist/project-schema/v3.51.0.d.ts +2 -2
- package/dist/project-schema/v3.52.0.d.ts +2 -2
- package/dist/project-schema/v3.53.0.d.ts +2 -2
- package/dist/project-schema/v3.54.0.d.ts +2 -2
- package/dist/project-schema/v3.55.0.d.ts +2 -2
- package/dist/refs.js +1 -1
- package/dist/schema-util.js +3 -2
- package/dist/schemas/project-schema/experimental.json +3 -3
- package/dist/util/mcp.d.ts +2 -2
- package/dist/util/patch-schema.d.ts +1 -1
- package/dist/util/patch-schema.js +4 -3
- package/dist/validate/ai.js +3 -3
- package/examples/latest/agent-schema.json +10 -18
- package/examples/source/agent-schema.json +7 -7
- package/package.json +8 -8
package/dist/agents.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentJSON, AgentMap, GuardJSON, ProjectSchemaJSON, QueryJSON } from './project-schema/index.ts';
|
|
1
|
+
import type { AgentJSON, AgentMap, GuardJSON, GuardMap, ProjectSchemaJSON, QueryJSON } from './project-schema/index.ts';
|
|
2
2
|
export declare const START_AGENT_EXECUTION = "START";
|
|
3
3
|
/**
|
|
4
4
|
* Special transition destination ID for agent transitions that end the agent execution.
|
|
@@ -8,12 +8,7 @@ export declare const END_AGENT_EXECUTION = "END";
|
|
|
8
8
|
* Special history strategy ID that indicates the history should be cleared.
|
|
9
9
|
*/
|
|
10
10
|
export declare const CLEAR_HISTORY_STRATEGY_ID = "clearHistory";
|
|
11
|
-
export
|
|
12
|
-
type: 'done' | 'progress';
|
|
13
|
-
originStateId: string;
|
|
14
|
-
};
|
|
15
|
-
export declare const getAgentEndTransitions: (agent: AgentJSON, includeSuspend?: boolean) => AgentEndTransition[];
|
|
16
|
-
export declare const getAgentEndStates: (agent: AgentJSON, includeSuspend?: boolean) => Set<string>;
|
|
11
|
+
export declare function getAgentEndStates(agent: AgentJSON, includeSuspend?: boolean): Set<string>;
|
|
17
12
|
export declare const getInspectAgentSessionQueryName: (agentName: string) => string;
|
|
18
13
|
export declare function getAgentQueries(agents: AgentMap): Pick<ProjectSchemaJSON, 'queries' | 'mutations'>;
|
|
19
14
|
export declare function isValidAgentMutation(projectSchema: ProjectSchemaJSON, name: string): boolean;
|
|
@@ -27,9 +22,12 @@ export declare const AGENTS_SCHEMA_PATH: readonly ["ai-experimental", "agents"];
|
|
|
27
22
|
* Check if a guard is enabled.
|
|
28
23
|
*/
|
|
29
24
|
export declare const isGuardEnabled: (guard: GuardJSON | undefined) => boolean;
|
|
25
|
+
export declare function getGuardMap(schema: ProjectSchemaJSON): GuardMap | undefined;
|
|
30
26
|
export declare function getGuards(schema: ProjectSchemaJSON): (GuardJSON & {
|
|
31
27
|
id: string;
|
|
32
28
|
})[];
|
|
29
|
+
export declare function setGuardMap<S extends Partial<ProjectSchemaJSON>>(schema: S, guards: GuardMap): S;
|
|
30
|
+
export declare function setGuard<S extends Partial<ProjectSchemaJSON>>(schema: S, id: string, guard: GuardJSON): S;
|
|
33
31
|
/**
|
|
34
32
|
* Get a guard configuration from the project schema.
|
|
35
33
|
*/
|
|
@@ -38,7 +36,12 @@ export declare function getGuardConfig(schema: ProjectSchemaJSON, guardId: strin
|
|
|
38
36
|
* Get a guard configuration from the project schema, but only if it is enabled.
|
|
39
37
|
*/
|
|
40
38
|
export declare function getEnabledGuardConfig(schema: ProjectSchemaJSON, guardId: string): GuardJSON | undefined;
|
|
41
|
-
export declare function getAgentMap(projectSchema: ProjectSchemaJSON): AgentMap | undefined;
|
|
39
|
+
export declare function getAgentMap(projectSchema: Pick<ProjectSchemaJSON, 'ai-experimental'>): AgentMap | undefined;
|
|
40
|
+
export declare function getAgents(projectSchema: Pick<ProjectSchemaJSON, 'ai-experimental'>): (AgentJSON & {
|
|
41
|
+
name: string;
|
|
42
|
+
})[] | undefined;
|
|
43
|
+
export declare function setAgentMap<S extends Partial<ProjectSchemaJSON>>(projectSchema: S, agents: AgentMap): S;
|
|
44
|
+
export declare function setAgent<S extends Partial<ProjectSchemaJSON>>(projectSchema: S, name: string, agent: AgentJSON): S;
|
|
42
45
|
export declare function getAgent(projectSchema: ProjectSchemaJSON, name: string): AgentJSON | undefined;
|
|
43
46
|
export declare function ensureAgent(projectSchema: ProjectSchemaJSON, name: string): AgentJSON;
|
|
44
47
|
export declare function isAgentQuery(query: QueryJSON, agentName: string): boolean;
|
package/dist/agents.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import set from 'lodash/fp/set.js';
|
|
1
2
|
import get from 'lodash/get.js';
|
|
2
3
|
import uniq from 'lodash/uniq.js';
|
|
3
4
|
import upperFirst from 'lodash/upperFirst.js';
|
|
@@ -10,11 +11,12 @@ export const END_AGENT_EXECUTION = 'END';
|
|
|
10
11
|
* Special history strategy ID that indicates the history should be cleared.
|
|
11
12
|
*/
|
|
12
13
|
export const CLEAR_HISTORY_STRATEGY_ID = 'clearHistory';
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
function canEndOnState(state, includeSuspend = false) {
|
|
15
|
+
const { transitions } = state;
|
|
16
|
+
if (!transitions?.length) {
|
|
15
17
|
return true;
|
|
16
18
|
}
|
|
17
|
-
for (const step of
|
|
19
|
+
for (const step of transitions) {
|
|
18
20
|
if (includeSuspend && step.type === 'suspend') {
|
|
19
21
|
return true;
|
|
20
22
|
}
|
|
@@ -26,22 +28,16 @@ const transitionCanEnd = (transition, includeSuspend = false) => {
|
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
return true;
|
|
29
|
-
}
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
31
|
+
}
|
|
32
|
+
export function getAgentEndStates(agent, includeSuspend = false) {
|
|
33
|
+
const endStates = new Set();
|
|
34
|
+
for (const [stateId, state] of Object.entries(agent.states)) {
|
|
35
|
+
if (canEndOnState(state, includeSuspend)) {
|
|
36
|
+
endStates.add(stateId);
|
|
35
37
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
export const getAgentEndStates = (agent, includeSuspend = false) => {
|
|
40
|
-
return getAgentEndTransitions(agent, includeSuspend).reduce((acc, { originStateId }) => {
|
|
41
|
-
acc.add(originStateId);
|
|
42
|
-
return acc;
|
|
43
|
-
}, new Set());
|
|
44
|
-
};
|
|
38
|
+
}
|
|
39
|
+
return endStates;
|
|
40
|
+
}
|
|
45
41
|
export const getInspectAgentSessionQueryName = (agentName) => {
|
|
46
42
|
return `inspect${upperFirst(agentName)}`;
|
|
47
43
|
};
|
|
@@ -144,10 +140,19 @@ export const AGENTS_SCHEMA_PATH = ['ai-experimental', 'agents'];
|
|
|
144
140
|
export const isGuardEnabled = (guard) => {
|
|
145
141
|
return Boolean(guard && guard.enabled !== false);
|
|
146
142
|
};
|
|
143
|
+
export function getGuardMap(schema) {
|
|
144
|
+
return schema['ai-experimental']?.guards;
|
|
145
|
+
}
|
|
147
146
|
export function getGuards(schema) {
|
|
148
|
-
const guards = schema
|
|
147
|
+
const guards = getGuardMap(schema);
|
|
149
148
|
return guards ? Object.entries(guards).map(([id, guard]) => ({ id, ...guard })) : [];
|
|
150
149
|
}
|
|
150
|
+
export function setGuardMap(schema, guards) {
|
|
151
|
+
return set(GUARDS_SCHEMA_PATH, guards, schema);
|
|
152
|
+
}
|
|
153
|
+
export function setGuard(schema, id, guard) {
|
|
154
|
+
return set([...GUARDS_SCHEMA_PATH, id], guard, schema);
|
|
155
|
+
}
|
|
151
156
|
/**
|
|
152
157
|
* Get a guard configuration from the project schema.
|
|
153
158
|
*/
|
|
@@ -166,6 +171,16 @@ export function getEnabledGuardConfig(schema, guardId) {
|
|
|
166
171
|
export function getAgentMap(projectSchema) {
|
|
167
172
|
return projectSchema['ai-experimental']?.agents;
|
|
168
173
|
}
|
|
174
|
+
export function getAgents(projectSchema) {
|
|
175
|
+
const agentMap = getAgentMap(projectSchema);
|
|
176
|
+
return agentMap && Object.entries(agentMap).map(([name, agent]) => ({ name, ...agent }));
|
|
177
|
+
}
|
|
178
|
+
export function setAgentMap(projectSchema, agents) {
|
|
179
|
+
return set(AGENTS_SCHEMA_PATH, agents, projectSchema);
|
|
180
|
+
}
|
|
181
|
+
export function setAgent(projectSchema, name, agent) {
|
|
182
|
+
return set([...AGENTS_SCHEMA_PATH, name], agent, projectSchema);
|
|
183
|
+
}
|
|
169
184
|
export function getAgent(projectSchema, name) {
|
|
170
185
|
return getAgentMap(projectSchema)?.[name];
|
|
171
186
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './get-is-leaf.ts';
|
|
|
11
11
|
export * from './interfaces.ts';
|
|
12
12
|
export * from './migration/index.ts';
|
|
13
13
|
export type { ProjectSchemaUpdate } from './migration/types.ts';
|
|
14
|
+
export { AGENTS_UPDATE_KEY, GUARDS_UPDATE_KEY, MCP_TOOLS_UPDATE_KEY } from './migration/types.ts';
|
|
14
15
|
export * from './mocks.ts';
|
|
15
16
|
export * from './models/runtime-schema.ts';
|
|
16
17
|
export * from './models/user-schema.ts';
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./flatten-templates.js";
|
|
|
9
9
|
export * from "./get-is-leaf.js";
|
|
10
10
|
export * from "./interfaces.js";
|
|
11
11
|
export * from "./migration/index.js";
|
|
12
|
+
export { AGENTS_UPDATE_KEY, GUARDS_UPDATE_KEY, MCP_TOOLS_UPDATE_KEY } from "./migration/types.js";
|
|
12
13
|
export * from "./mocks.js";
|
|
13
14
|
export * from "./models/runtime-schema.js";
|
|
14
15
|
export * from "./models/user-schema.js";
|
|
@@ -5,13 +5,16 @@ export type ProjectSchemaMigrationContext = {
|
|
|
5
5
|
encryptFn: EncryptFn;
|
|
6
6
|
decryptFn: SafeDecryptFn;
|
|
7
7
|
};
|
|
8
|
+
export declare const AGENTS_UPDATE_KEY = "ai-experimental.agents";
|
|
9
|
+
export declare const GUARDS_UPDATE_KEY = "ai-experimental.guards";
|
|
10
|
+
export declare const MCP_TOOLS_UPDATE_KEY = "ai-experimental.mcp.tools";
|
|
8
11
|
export type ProjectSchemaUpdate = {
|
|
9
12
|
queries?: Record<string, QueryJSON | null>;
|
|
10
13
|
mutations?: Record<string, QueryJSON | null>;
|
|
11
14
|
shapes?: Record<string, ShapeJSON | null>;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
[AGENTS_UPDATE_KEY]?: Record<string, AgentJSON | null>;
|
|
16
|
+
[GUARDS_UPDATE_KEY]?: Record<string, GuardJSON | null>;
|
|
17
|
+
[MCP_TOOLS_UPDATE_KEY]?: Record<string, ToolJSON | null>;
|
|
15
18
|
forms?: Record<string, FormConfig | null>;
|
|
16
19
|
workflows?: Record<string, Workflow | null>;
|
|
17
20
|
services?: Record<string, ServiceConfigJSON | null>;
|
package/dist/migration/types.js
CHANGED
|
@@ -1792,7 +1792,7 @@ export interface AgentSessionMemory {
|
|
|
1792
1792
|
* Configuration for the start of an agent's execution
|
|
1793
1793
|
*/
|
|
1794
1794
|
export interface AgentStart {
|
|
1795
|
-
|
|
1795
|
+
transitions: AgentTransitionSuspend[];
|
|
1796
1796
|
}
|
|
1797
1797
|
export interface AgentTransitionSuspend {
|
|
1798
1798
|
type: 'suspend';
|
|
@@ -1823,7 +1823,7 @@ export interface AgentState {
|
|
|
1823
1823
|
name: string;
|
|
1824
1824
|
variables?: Variables;
|
|
1825
1825
|
execution: AgentExecution;
|
|
1826
|
-
|
|
1826
|
+
transitions?: AgentTransition[];
|
|
1827
1827
|
}
|
|
1828
1828
|
export interface AgentVariable {
|
|
1829
1829
|
name: string;
|
|
@@ -1640,7 +1640,7 @@ export interface AgentSessionMemoryV3_48_0 {
|
|
|
1640
1640
|
* Configuration for the start of an agent's execution
|
|
1641
1641
|
*/
|
|
1642
1642
|
export interface AgentStartV3_48_0 {
|
|
1643
|
-
|
|
1643
|
+
transitions: AgentTransitionSuspendV3_48_0[];
|
|
1644
1644
|
}
|
|
1645
1645
|
export interface AgentTransitionSuspendV3_48_0 {
|
|
1646
1646
|
type: 'suspend';
|
|
@@ -1671,7 +1671,7 @@ export interface AgentStateV3_48_0 {
|
|
|
1671
1671
|
name: string;
|
|
1672
1672
|
variables?: VariablesV3_48_0;
|
|
1673
1673
|
execution: AgentExecutionV3_48_0;
|
|
1674
|
-
|
|
1674
|
+
transitions?: AgentTransitionV3_48_0[];
|
|
1675
1675
|
}
|
|
1676
1676
|
export interface AgentVariableV3_48_0 {
|
|
1677
1677
|
name: string;
|
|
@@ -1640,7 +1640,7 @@ export interface AgentSessionMemoryV3_49_0 {
|
|
|
1640
1640
|
* Configuration for the start of an agent's execution
|
|
1641
1641
|
*/
|
|
1642
1642
|
export interface AgentStartV3_49_0 {
|
|
1643
|
-
|
|
1643
|
+
transitions: AgentTransitionSuspendV3_49_0[];
|
|
1644
1644
|
}
|
|
1645
1645
|
export interface AgentTransitionSuspendV3_49_0 {
|
|
1646
1646
|
type: 'suspend';
|
|
@@ -1671,7 +1671,7 @@ export interface AgentStateV3_49_0 {
|
|
|
1671
1671
|
name: string;
|
|
1672
1672
|
variables?: VariablesV3_49_0;
|
|
1673
1673
|
execution: AgentExecutionV3_49_0;
|
|
1674
|
-
|
|
1674
|
+
transitions?: AgentTransitionV3_49_0[];
|
|
1675
1675
|
}
|
|
1676
1676
|
export interface AgentVariableV3_49_0 {
|
|
1677
1677
|
name: string;
|
|
@@ -1692,7 +1692,7 @@ export interface AgentSessionMemoryV3_50_0 {
|
|
|
1692
1692
|
* Configuration for the start of an agent's execution
|
|
1693
1693
|
*/
|
|
1694
1694
|
export interface AgentStartV3_50_0 {
|
|
1695
|
-
|
|
1695
|
+
transitions: AgentTransitionSuspendV3_50_0[];
|
|
1696
1696
|
}
|
|
1697
1697
|
export interface AgentTransitionSuspendV3_50_0 {
|
|
1698
1698
|
type: 'suspend';
|
|
@@ -1723,7 +1723,7 @@ export interface AgentStateV3_50_0 {
|
|
|
1723
1723
|
name: string;
|
|
1724
1724
|
variables?: VariablesV3_50_0;
|
|
1725
1725
|
execution: AgentExecutionV3_50_0;
|
|
1726
|
-
|
|
1726
|
+
transitions?: AgentTransitionV3_50_0[];
|
|
1727
1727
|
}
|
|
1728
1728
|
export interface AgentVariableV3_50_0 {
|
|
1729
1729
|
name: string;
|
|
@@ -1692,7 +1692,7 @@ export interface AgentSessionMemoryV3_51_0 {
|
|
|
1692
1692
|
* Configuration for the start of an agent's execution
|
|
1693
1693
|
*/
|
|
1694
1694
|
export interface AgentStartV3_51_0 {
|
|
1695
|
-
|
|
1695
|
+
transitions: AgentTransitionSuspendV3_51_0[];
|
|
1696
1696
|
}
|
|
1697
1697
|
export interface AgentTransitionSuspendV3_51_0 {
|
|
1698
1698
|
type: 'suspend';
|
|
@@ -1723,7 +1723,7 @@ export interface AgentStateV3_51_0 {
|
|
|
1723
1723
|
name: string;
|
|
1724
1724
|
variables?: VariablesV3_51_0;
|
|
1725
1725
|
execution: AgentExecutionV3_51_0;
|
|
1726
|
-
|
|
1726
|
+
transitions?: AgentTransitionV3_51_0[];
|
|
1727
1727
|
}
|
|
1728
1728
|
export interface AgentVariableV3_51_0 {
|
|
1729
1729
|
name: string;
|
|
@@ -1692,7 +1692,7 @@ export interface AgentSessionMemoryV3_52_0 {
|
|
|
1692
1692
|
* Configuration for the start of an agent's execution
|
|
1693
1693
|
*/
|
|
1694
1694
|
export interface AgentStartV3_52_0 {
|
|
1695
|
-
|
|
1695
|
+
transitions: AgentTransitionSuspendV3_52_0[];
|
|
1696
1696
|
}
|
|
1697
1697
|
export interface AgentTransitionSuspendV3_52_0 {
|
|
1698
1698
|
type: 'suspend';
|
|
@@ -1723,7 +1723,7 @@ export interface AgentStateV3_52_0 {
|
|
|
1723
1723
|
name: string;
|
|
1724
1724
|
variables?: VariablesV3_52_0;
|
|
1725
1725
|
execution: AgentExecutionV3_52_0;
|
|
1726
|
-
|
|
1726
|
+
transitions?: AgentTransitionV3_52_0[];
|
|
1727
1727
|
}
|
|
1728
1728
|
export interface AgentVariableV3_52_0 {
|
|
1729
1729
|
name: string;
|
|
@@ -1773,7 +1773,7 @@ export interface AgentSessionMemoryV3_53_0 {
|
|
|
1773
1773
|
* Configuration for the start of an agent's execution
|
|
1774
1774
|
*/
|
|
1775
1775
|
export interface AgentStartV3_53_0 {
|
|
1776
|
-
|
|
1776
|
+
transitions: AgentTransitionSuspendV3_53_0[];
|
|
1777
1777
|
}
|
|
1778
1778
|
export interface AgentTransitionSuspendV3_53_0 {
|
|
1779
1779
|
type: 'suspend';
|
|
@@ -1804,7 +1804,7 @@ export interface AgentStateV3_53_0 {
|
|
|
1804
1804
|
name: string;
|
|
1805
1805
|
variables?: VariablesV3_53_0;
|
|
1806
1806
|
execution: AgentExecutionV3_53_0;
|
|
1807
|
-
|
|
1807
|
+
transitions?: AgentTransitionV3_53_0[];
|
|
1808
1808
|
}
|
|
1809
1809
|
export interface AgentVariableV3_53_0 {
|
|
1810
1810
|
name: string;
|
|
@@ -1792,7 +1792,7 @@ export interface AgentSessionMemoryV3_54_0 {
|
|
|
1792
1792
|
* Configuration for the start of an agent's execution
|
|
1793
1793
|
*/
|
|
1794
1794
|
export interface AgentStartV3_54_0 {
|
|
1795
|
-
|
|
1795
|
+
transitions: AgentTransitionSuspendV3_54_0[];
|
|
1796
1796
|
}
|
|
1797
1797
|
export interface AgentTransitionSuspendV3_54_0 {
|
|
1798
1798
|
type: 'suspend';
|
|
@@ -1823,7 +1823,7 @@ export interface AgentStateV3_54_0 {
|
|
|
1823
1823
|
name: string;
|
|
1824
1824
|
variables?: VariablesV3_54_0;
|
|
1825
1825
|
execution: AgentExecutionV3_54_0;
|
|
1826
|
-
|
|
1826
|
+
transitions?: AgentTransitionV3_54_0[];
|
|
1827
1827
|
}
|
|
1828
1828
|
export interface AgentVariableV3_54_0 {
|
|
1829
1829
|
name: string;
|
|
@@ -1792,7 +1792,7 @@ export interface AgentSessionMemoryV3_55_0 {
|
|
|
1792
1792
|
* Configuration for the start of an agent's execution
|
|
1793
1793
|
*/
|
|
1794
1794
|
export interface AgentStartV3_55_0 {
|
|
1795
|
-
|
|
1795
|
+
transitions: AgentTransitionSuspendV3_55_0[];
|
|
1796
1796
|
}
|
|
1797
1797
|
export interface AgentTransitionSuspendV3_55_0 {
|
|
1798
1798
|
type: 'suspend';
|
|
@@ -1823,7 +1823,7 @@ export interface AgentStateV3_55_0 {
|
|
|
1823
1823
|
name: string;
|
|
1824
1824
|
variables?: VariablesV3_55_0;
|
|
1825
1825
|
execution: AgentExecutionV3_55_0;
|
|
1826
|
-
|
|
1826
|
+
transitions?: AgentTransitionV3_55_0[];
|
|
1827
1827
|
}
|
|
1828
1828
|
export interface AgentVariableV3_55_0 {
|
|
1829
1829
|
name: string;
|
package/dist/refs.js
CHANGED
|
@@ -526,7 +526,7 @@ export function getAllPropertyRefs(projectSchema) {
|
|
|
526
526
|
return false;
|
|
527
527
|
}
|
|
528
528
|
const parent = get(projectSchema, path.slice(0, -1));
|
|
529
|
-
return isRecord(parent) && parent.type === 'generate';
|
|
529
|
+
return isRecord(parent) && (parent.type === 'generate' || parent.type === 'chat');
|
|
530
530
|
};
|
|
531
531
|
const pushRef = (refStr) => {
|
|
532
532
|
const parsed = parsePropertyRef(refStr);
|
package/dist/schema-util.js
CHANGED
|
@@ -6,6 +6,7 @@ import isString from 'lodash/isString.js';
|
|
|
6
6
|
import keyBy from 'lodash/keyBy.js';
|
|
7
7
|
import mapValues from 'lodash/mapValues.js';
|
|
8
8
|
import uniq from 'lodash/uniq.js';
|
|
9
|
+
import { AGENTS_SCHEMA_PATH, getAgentMap } from './agents.js';
|
|
9
10
|
import { workflowsEnabled } from "./api-version.js";
|
|
10
11
|
import { builtInForms, builtInShapes } from "./builtin-schema.js";
|
|
11
12
|
import { SERVICE_OBJECT_PATTERN_NAME } from "./constants.js";
|
|
@@ -711,10 +712,10 @@ export function getAllRefsInShapes(projectSchema, predicate) {
|
|
|
711
712
|
}
|
|
712
713
|
export function getRefsInAgents(context, predicate) {
|
|
713
714
|
const refs = [];
|
|
714
|
-
const agents = context
|
|
715
|
+
const agents = getAgentMap(context);
|
|
715
716
|
if (agents) {
|
|
716
717
|
for (const [agentKey, agent] of Object.entries(agents)) {
|
|
717
|
-
const agentPath = [
|
|
718
|
+
const agentPath = [...AGENTS_SCHEMA_PATH, agentKey];
|
|
718
719
|
agent.api.inputs.forEach((input, index) => {
|
|
719
720
|
const ref = {
|
|
720
721
|
...parseRef(context, input.args),
|
|
@@ -264,14 +264,14 @@
|
|
|
264
264
|
"description": "Configuration for the start of an agent's execution",
|
|
265
265
|
"type": "object",
|
|
266
266
|
"properties": {
|
|
267
|
-
"
|
|
267
|
+
"transitions": {
|
|
268
268
|
"type": "array",
|
|
269
269
|
"items": {
|
|
270
270
|
"$ref": "#/definitions/agentTransitionSuspend"
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
},
|
|
274
|
-
"required": ["
|
|
274
|
+
"required": ["transitions"],
|
|
275
275
|
"additionalProperties": false
|
|
276
276
|
},
|
|
277
277
|
"agentStateMap": {
|
|
@@ -304,7 +304,7 @@
|
|
|
304
304
|
"execution": {
|
|
305
305
|
"$ref": "#/definitions/agentExecution"
|
|
306
306
|
},
|
|
307
|
-
"
|
|
307
|
+
"transitions": {
|
|
308
308
|
"type": "array",
|
|
309
309
|
"items": {
|
|
310
310
|
"$ref": "#/definitions/agentTransition"
|
package/dist/util/mcp.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export declare function getMcpToolMap(projectSchema: ProjectSchemaJSON): ToolMap
|
|
|
4
4
|
export declare function getMcpTools(projectSchema: ProjectSchemaJSON): ToolJSON[] | undefined;
|
|
5
5
|
export declare function getMcpToolNames(projectSchema: ProjectSchemaJSON): string[];
|
|
6
6
|
export declare function getMcpTool(projectSchema: ProjectSchemaJSON, toolName: string): ToolJSON | undefined;
|
|
7
|
-
export declare function setMcpToolMap<S extends ProjectSchemaJSON
|
|
8
|
-
export declare function setMcpTool<S extends ProjectSchemaJSON
|
|
7
|
+
export declare function setMcpToolMap<S extends Partial<ProjectSchemaJSON>>(projectSchema: S, tools: ToolMap): S;
|
|
8
|
+
export declare function setMcpTool<S extends Partial<ProjectSchemaJSON>>(projectSchema: S, tool: ToolJSON): S;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ProjectSchemaUpdate } from '../migration/types.ts';
|
|
2
2
|
import type { ProjectSchemaJSON } from '../project-schema/index.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Apply a schema update to a schema. This can operate on a schema with frozen properties,
|
|
@@ -2,6 +2,7 @@ import set from 'lodash/fp/set.js';
|
|
|
2
2
|
import get from 'lodash/get.js';
|
|
3
3
|
import omit from 'lodash/omit.js';
|
|
4
4
|
import unset from 'lodash/unset.js';
|
|
5
|
+
import { AGENTS_UPDATE_KEY, GUARDS_UPDATE_KEY, MCP_TOOLS_UPDATE_KEY } from "../migration/types.js";
|
|
5
6
|
/**
|
|
6
7
|
* Array of lodash.get paths to keys that are merged when applying a schema update.
|
|
7
8
|
*/
|
|
@@ -12,9 +13,9 @@ const schemaUpdateMergedKeys = [
|
|
|
12
13
|
'workflows',
|
|
13
14
|
'forms',
|
|
14
15
|
'services',
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
AGENTS_UPDATE_KEY,
|
|
17
|
+
GUARDS_UPDATE_KEY,
|
|
18
|
+
MCP_TOOLS_UPDATE_KEY
|
|
18
19
|
];
|
|
19
20
|
function shallowMerge(original, update) {
|
|
20
21
|
const result = { ...original };
|
package/dist/validate/ai.js
CHANGED
|
@@ -87,7 +87,7 @@ export function validateAgents(projectSchema) {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
pushErrors(errors, validateAgentTransitions([...agentPath, 'start', '
|
|
90
|
+
pushErrors(errors, validateAgentTransitions([...agentPath, 'start', 'transitions'], inputNames, agent.start.transitions));
|
|
91
91
|
for (const [stateId, state] of Object.entries(agent.states)) {
|
|
92
92
|
const statePath = [...agentPath, 'states', stateId];
|
|
93
93
|
if (stateNames.has(state.name)) {
|
|
@@ -125,8 +125,8 @@ export function validateAgents(projectSchema) {
|
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
if (state.
|
|
129
|
-
errors.push(...validateAgentTransitions([...statePath, '
|
|
128
|
+
if (state.transitions) {
|
|
129
|
+
errors.push(...validateAgentTransitions([...statePath, 'transitions'], inputNames, state.transitions));
|
|
130
130
|
}
|
|
131
131
|
if (state.execution.type === 'generate' || state.execution.type === 'chat') {
|
|
132
132
|
if (!state.execution.tools) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"projectId": "1c0dc45d-695e-4a87-ac52-13db5e1fd781",
|
|
3
3
|
"defaultLocale": "en-us",
|
|
4
|
-
"locales": [
|
|
5
|
-
"en-us"
|
|
6
|
-
],
|
|
4
|
+
"locales": ["en-us"],
|
|
7
5
|
"queries": {
|
|
8
6
|
"dogDelegate": {
|
|
9
7
|
"resolver": {
|
|
@@ -122,10 +120,7 @@
|
|
|
122
120
|
"type": "string"
|
|
123
121
|
}
|
|
124
122
|
},
|
|
125
|
-
"required": [
|
|
126
|
-
"answered",
|
|
127
|
-
"message"
|
|
128
|
-
]
|
|
123
|
+
"required": ["answered", "message"]
|
|
129
124
|
}
|
|
130
125
|
}
|
|
131
126
|
},
|
|
@@ -141,10 +136,7 @@
|
|
|
141
136
|
"widget": "singleLineText"
|
|
142
137
|
}
|
|
143
138
|
},
|
|
144
|
-
"order": [
|
|
145
|
-
"name",
|
|
146
|
-
"color"
|
|
147
|
-
]
|
|
139
|
+
"order": ["name", "color"]
|
|
148
140
|
}
|
|
149
141
|
}
|
|
150
142
|
},
|
|
@@ -196,7 +188,7 @@
|
|
|
196
188
|
]
|
|
197
189
|
},
|
|
198
190
|
"start": {
|
|
199
|
-
"
|
|
191
|
+
"transitions": [
|
|
200
192
|
{
|
|
201
193
|
"type": "suspend",
|
|
202
194
|
"input": "findDogColor",
|
|
@@ -228,7 +220,7 @@
|
|
|
228
220
|
"query": "query ($input: String!) {\n getDogList(terms: $input) {\n items {\n name\n color\n }\n }\n}\n",
|
|
229
221
|
"path": "getDogList.items[0]"
|
|
230
222
|
},
|
|
231
|
-
"
|
|
223
|
+
"transitions": [
|
|
232
224
|
{
|
|
233
225
|
"type": "immediate",
|
|
234
226
|
"destination": "ccc"
|
|
@@ -265,7 +257,7 @@
|
|
|
265
257
|
},
|
|
266
258
|
"outputShape": "AnswerResponse"
|
|
267
259
|
},
|
|
268
|
-
"
|
|
260
|
+
"transitions": [
|
|
269
261
|
{
|
|
270
262
|
"type": "immediate",
|
|
271
263
|
"condition": "stateOutputs['ccc'].answered",
|
|
@@ -303,7 +295,7 @@
|
|
|
303
295
|
"inputTemplate": "Please summarize this information:\n\n{{results}}"
|
|
304
296
|
}
|
|
305
297
|
},
|
|
306
|
-
"
|
|
298
|
+
"transitions": []
|
|
307
299
|
},
|
|
308
300
|
"eee": {
|
|
309
301
|
"name": "apologize",
|
|
@@ -326,7 +318,7 @@
|
|
|
326
318
|
"inputTemplate": "Please provide a generic polite apology that there were no search results."
|
|
327
319
|
}
|
|
328
320
|
},
|
|
329
|
-
"
|
|
321
|
+
"transitions": []
|
|
330
322
|
}
|
|
331
323
|
},
|
|
332
324
|
"historyStrategies": {}
|
|
@@ -342,7 +334,7 @@
|
|
|
342
334
|
]
|
|
343
335
|
},
|
|
344
336
|
"start": {
|
|
345
|
-
"
|
|
337
|
+
"transitions": [
|
|
346
338
|
{
|
|
347
339
|
"type": "suspend",
|
|
348
340
|
"input": "chat",
|
|
@@ -362,7 +354,7 @@
|
|
|
362
354
|
},
|
|
363
355
|
"systemPrompt": "You are a helpful assistant. If the user says they have no further questions, end your response with the string ALL_DONE."
|
|
364
356
|
},
|
|
365
|
-
"
|
|
357
|
+
"transitions": [
|
|
366
358
|
{
|
|
367
359
|
"type": "immediate",
|
|
368
360
|
"condition": "contains(currentStateOutput.content, 'ALL_DONE')",
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
]
|
|
179
179
|
},
|
|
180
180
|
"start": {
|
|
181
|
-
"
|
|
181
|
+
"transitions": [
|
|
182
182
|
{
|
|
183
183
|
"type": "suspend",
|
|
184
184
|
"input": "findDogColor",
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
"query": "query ($input: String!) {\n getDogList(terms: $input) {\n items {\n name\n color\n }\n }\n}\n",
|
|
211
211
|
"path": "getDogList.items[0]"
|
|
212
212
|
},
|
|
213
|
-
"
|
|
213
|
+
"transitions": [
|
|
214
214
|
{
|
|
215
215
|
"type": "immediate",
|
|
216
216
|
"destination": "ccc"
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
},
|
|
248
248
|
"outputShape": "AnswerResponse"
|
|
249
249
|
},
|
|
250
|
-
"
|
|
250
|
+
"transitions": [
|
|
251
251
|
{
|
|
252
252
|
"type": "immediate",
|
|
253
253
|
"condition": "stateOutputs['ccc'].answered",
|
|
@@ -285,7 +285,7 @@
|
|
|
285
285
|
"inputTemplate": "Please summarize this information:\n\n{{results}}"
|
|
286
286
|
}
|
|
287
287
|
},
|
|
288
|
-
"
|
|
288
|
+
"transitions": []
|
|
289
289
|
},
|
|
290
290
|
"eee": {
|
|
291
291
|
"name": "apologize",
|
|
@@ -308,7 +308,7 @@
|
|
|
308
308
|
"inputTemplate": "Please provide a generic polite apology that there were no search results."
|
|
309
309
|
}
|
|
310
310
|
},
|
|
311
|
-
"
|
|
311
|
+
"transitions": []
|
|
312
312
|
}
|
|
313
313
|
},
|
|
314
314
|
"historyStrategies": {}
|
|
@@ -324,7 +324,7 @@
|
|
|
324
324
|
]
|
|
325
325
|
},
|
|
326
326
|
"start": {
|
|
327
|
-
"
|
|
327
|
+
"transitions": [
|
|
328
328
|
{
|
|
329
329
|
"type": "suspend",
|
|
330
330
|
"input": "chat",
|
|
@@ -344,7 +344,7 @@
|
|
|
344
344
|
},
|
|
345
345
|
"systemPrompt": "You are a helpful assistant. If the user says they have no further questions, end your response with the string ALL_DONE."
|
|
346
346
|
},
|
|
347
|
-
"
|
|
347
|
+
"transitions": [
|
|
348
348
|
{
|
|
349
349
|
"type": "immediate",
|
|
350
350
|
"condition": "contains(currentStateOutput.content, 'ALL_DONE')",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/schema",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.102.0",
|
|
4
4
|
"description": "TakeShape Schema",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"p-reduce": "^2.1.0",
|
|
59
59
|
"semver": "^7.3.2",
|
|
60
60
|
"tiny-invariant": "^1.2.0",
|
|
61
|
-
"@takeshape/errors": "11.
|
|
62
|
-
"@takeshape/json-schema": "11.
|
|
63
|
-
"@takeshape/util": "11.
|
|
61
|
+
"@takeshape/errors": "11.102.0",
|
|
62
|
+
"@takeshape/json-schema": "11.102.0",
|
|
63
|
+
"@takeshape/util": "11.102.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@takeshape/json-schema-to-typescript": "^11.0.0",
|
|
@@ -76,10 +76,10 @@
|
|
|
76
76
|
"glob": "^7.1.6",
|
|
77
77
|
"json-schema-to-ts": "^3.1.1",
|
|
78
78
|
"shortid": "^2.2.15",
|
|
79
|
-
"@takeshape/infra": "11.
|
|
79
|
+
"@takeshape/infra": "11.102.0"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
|
-
"node": ">=
|
|
82
|
+
"node": ">=22"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
|
85
85
|
"build": "tsc --project tsconfig.build.json",
|
|
@@ -92,9 +92,9 @@
|
|
|
92
92
|
"deploy:ci": "pnpm run deploy",
|
|
93
93
|
"json2ts": "node scripts/json-schema-to-typescript.mjs",
|
|
94
94
|
"lint": "trap 'RC=1' ERR; pnpm lint:biome; pnpm lint:eslint; exit $RC",
|
|
95
|
-
"lint:biome": "biome check",
|
|
95
|
+
"lint:biome": "biome check ./",
|
|
96
96
|
"lint:eslint": "eslint src -c ../../eslint.config.mjs",
|
|
97
|
-
"lint:ci:biome": "mkdir -p \"${GITHUB_WORKSPACE}/test-results/${npm_package_name#*\\/}\" && biome check --diagnostic-level error --reporter=junit > \"${GITHUB_WORKSPACE}/test-results/${npm_package_name#*\\/}/biome-results.xml\"",
|
|
97
|
+
"lint:ci:biome": "mkdir -p \"${GITHUB_WORKSPACE}/test-results/${npm_package_name#*\\/}\" && biome check ./ --diagnostic-level error --reporter=junit > \"${GITHUB_WORKSPACE}/test-results/${npm_package_name#*\\/}/biome-results.xml\"",
|
|
98
98
|
"lint:ci:eslint": "ESLINT_SUITE_NAME=${npm_package_name} ESLINT_JUNIT_OUTPUT=\"${GITHUB_WORKSPACE}/test-results/${npm_package_name#*\\/}/eslint-results.xml\" pnpm lint:eslint --quiet --format ../../node_modules/eslint-junit/index.js",
|
|
99
99
|
"test": "TZ=UTC vitest run",
|
|
100
100
|
"test-changed": "pnpm run test --changedSince=master",
|