contentful-management 11.66.0 → 11.67.1

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.
Files changed (30) hide show
  1. package/README.md +13 -10
  2. package/dist/contentful-management.browser.js +940 -449
  3. package/dist/contentful-management.browser.js.map +1 -1
  4. package/dist/contentful-management.browser.min.js +1 -1
  5. package/dist/contentful-management.node.js +923 -450
  6. package/dist/contentful-management.node.js.map +1 -1
  7. package/dist/contentful-management.node.min.js +1 -1
  8. package/dist/es-modules/adapters/REST/endpoints/agent-run.js +20 -0
  9. package/dist/es-modules/adapters/REST/endpoints/agent.js +24 -0
  10. package/dist/es-modules/adapters/REST/endpoints/index.js +4 -0
  11. package/dist/es-modules/create-environment-api.js +173 -0
  12. package/dist/es-modules/entities/agent-run.js +8 -0
  13. package/dist/es-modules/entities/agent.js +29 -0
  14. package/dist/es-modules/entities/index.js +4 -0
  15. package/dist/es-modules/plain/entities/agent-run.js +1 -0
  16. package/dist/es-modules/plain/entities/agent.js +1 -0
  17. package/dist/es-modules/plain/plain-client.js +9 -0
  18. package/dist/typings/adapters/REST/endpoints/agent-run.d.ts +3 -0
  19. package/dist/typings/adapters/REST/endpoints/agent.d.ts +4 -0
  20. package/dist/typings/adapters/REST/endpoints/index.d.ts +4 -0
  21. package/dist/typings/common-types.d.ts +45 -0
  22. package/dist/typings/create-environment-api.d.ts +112 -0
  23. package/dist/typings/entities/agent-run.d.ts +47 -0
  24. package/dist/typings/entities/agent.d.ts +49 -0
  25. package/dist/typings/entities/index.d.ts +4 -0
  26. package/dist/typings/export-types.d.ts +2 -0
  27. package/dist/typings/plain/common-types.d.ts +4 -0
  28. package/dist/typings/plain/entities/agent-run.d.ts +27 -0
  29. package/dist/typings/plain/entities/agent.d.ts +34 -0
  30. package/package.json +3 -3
@@ -0,0 +1,20 @@
1
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ import * as raw from './raw';
7
+ const AgentRunAlphaHeaders = {
8
+ 'x-contentful-enable-alpha-feature': 'agents-api'
9
+ };
10
+ export const get = (http, params, headers) => {
11
+ return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/ai_agents/runs/${params.runId}`, {
12
+ headers: _objectSpread(_objectSpread({}, AgentRunAlphaHeaders), headers)
13
+ });
14
+ };
15
+ export const getMany = (http, params, headers) => {
16
+ return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/ai_agents/runs`, {
17
+ params: params.query,
18
+ headers: _objectSpread(_objectSpread({}, AgentRunAlphaHeaders), headers)
19
+ });
20
+ };
@@ -0,0 +1,24 @@
1
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ import * as raw from './raw';
7
+ const AgentAlphaHeaders = {
8
+ 'x-contentful-enable-alpha-feature': 'agents-api'
9
+ };
10
+ export const get = (http, params, headers) => {
11
+ return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/ai_agents/agents/${params.agentId}`, {
12
+ headers: _objectSpread(_objectSpread({}, AgentAlphaHeaders), headers)
13
+ });
14
+ };
15
+ export const getMany = (http, params, headers) => {
16
+ return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/ai_agents/agents`, {
17
+ headers: _objectSpread(_objectSpread({}, AgentAlphaHeaders), headers)
18
+ });
19
+ };
20
+ export const generate = (http, params, data, headers) => {
21
+ return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/ai_agents/agents/${params.agentId}/generate`, data, {
22
+ headers: _objectSpread(_objectSpread({}, AgentAlphaHeaders), headers)
23
+ });
24
+ };
@@ -1,5 +1,7 @@
1
1
  import * as AiAction from './ai-action';
2
2
  import * as AiActionInvocation from './ai-action-invocation';
3
+ import * as Agent from './agent';
4
+ import * as AgentRun from './agent-run';
3
5
  import * as AccessToken from './access-token';
4
6
  import * as ApiKey from './api-key';
5
7
  import * as AppAccessToken from './app-access-token';
@@ -74,6 +76,8 @@ import * as WorkflowsChangelog from './workflows-changelog';
74
76
  export default {
75
77
  AiAction,
76
78
  AiActionInvocation,
79
+ Agent,
80
+ AgentRun,
77
81
  ApiKey,
78
82
  AppAction,
79
83
  AppActionCall,
@@ -85,6 +85,14 @@ export default function createEnvironmentApi(makeRequest) {
85
85
  const {
86
86
  wrapAppAccessToken
87
87
  } = entities.appAccessToken;
88
+ const {
89
+ wrapAgent,
90
+ wrapAgentCollection
91
+ } = entities.agent;
92
+ const {
93
+ wrapAgentRun,
94
+ wrapAgentRunCollection
95
+ } = entities.agentRun;
88
96
  const {
89
97
  wrapResourceTypesForEnvironmentCollection
90
98
  } = entities.resourceType;
@@ -2845,6 +2853,171 @@ export default function createEnvironmentApi(makeRequest) {
2845
2853
  },
2846
2854
  payload
2847
2855
  }).then(data => wrapSemanticSearch(makeRequest, data));
2856
+ },
2857
+ /**
2858
+ * Gets an AI Agent
2859
+ * @param agentId - AI Agent ID
2860
+ * @return Promise for an AI Agent
2861
+ * @example ```javascript
2862
+ * const contentful = require('contentful-management')
2863
+ *
2864
+ * const client = contentful.createClient({
2865
+ * accessToken: '<content_management_api_key>'
2866
+ * })
2867
+ *
2868
+ * client.getSpace('<space_id>')
2869
+ * .then((space) => space.getEnvironment('<environment_id>'))
2870
+ * .then((environment) => environment.getAgent('<agent_id>'))
2871
+ * .then((agent) => console.log(agent))
2872
+ * .catch(console.error)
2873
+ * ```
2874
+ */
2875
+ getAgent(agentId) {
2876
+ const raw = this.toPlainObject();
2877
+ return makeRequest({
2878
+ entityType: 'Agent',
2879
+ action: 'get',
2880
+ params: {
2881
+ spaceId: raw.sys.space.sys.id,
2882
+ environmentId: raw.sys.id,
2883
+ agentId
2884
+ }
2885
+ }).then(data => wrapAgent(makeRequest, data));
2886
+ },
2887
+ /**
2888
+ * Gets a collection of AI Agents
2889
+ * @return Promise for a collection of AI Agents
2890
+ * @example ```javascript
2891
+ * const contentful = require('contentful-management')
2892
+ *
2893
+ * const client = contentful.createClient({
2894
+ * accessToken: '<content_management_api_key>'
2895
+ * })
2896
+ *
2897
+ * client.getSpace('<space_id>')
2898
+ * .then((space) => space.getEnvironment('<environment_id>'))
2899
+ * .then((environment) => environment.getAgents())
2900
+ * .then((response) => console.log(response.items))
2901
+ * .catch(console.error)
2902
+ * ```
2903
+ */
2904
+ getAgents() {
2905
+ const raw = this.toPlainObject();
2906
+ return makeRequest({
2907
+ entityType: 'Agent',
2908
+ action: 'getMany',
2909
+ params: {
2910
+ spaceId: raw.sys.space.sys.id,
2911
+ environmentId: raw.sys.id
2912
+ }
2913
+ }).then(data => wrapAgentCollection(makeRequest, data));
2914
+ },
2915
+ /**
2916
+ * Generates content using an AI Agent
2917
+ * @param agentId - AI Agent ID
2918
+ * @param payload - Generation payload
2919
+ * @return Promise for the generation response
2920
+ * @example ```javascript
2921
+ * const contentful = require('contentful-management')
2922
+ *
2923
+ * const client = contentful.createClient({
2924
+ * accessToken: '<content_management_api_key>'
2925
+ * })
2926
+ *
2927
+ * client.getSpace('<space_id>')
2928
+ * .then((space) => space.getEnvironment('<environment_id>'))
2929
+ * .then((environment) => environment.generateWithAgent('<agent_id>', {
2930
+ * messages: [
2931
+ * {
2932
+ * parts: [
2933
+ * {
2934
+ * type: 'text',
2935
+ * text: 'Write a short poem about Contentful'
2936
+ * }
2937
+ * ],
2938
+ * role: 'user'
2939
+ * }
2940
+ * ]
2941
+ * }))
2942
+ * .then((result) => console.log(result))
2943
+ * .catch(console.error)
2944
+ * ```
2945
+ */
2946
+ generateWithAgent(agentId, payload) {
2947
+ const raw = this.toPlainObject();
2948
+ return makeRequest({
2949
+ entityType: 'Agent',
2950
+ action: 'generate',
2951
+ params: {
2952
+ spaceId: raw.sys.space.sys.id,
2953
+ environmentId: raw.sys.id,
2954
+ agentId
2955
+ },
2956
+ payload
2957
+ }).then(data => wrapAgentRun(makeRequest, data));
2958
+ },
2959
+ /**
2960
+ * Gets an AI Agent Run
2961
+ * @param runId - AI Agent Run ID
2962
+ * @return Promise for an AI Agent Run
2963
+ * @example ```javascript
2964
+ * const contentful = require('contentful-management')
2965
+ *
2966
+ * const client = contentful.createClient({
2967
+ * accessToken: '<content_management_api_key>'
2968
+ * })
2969
+ *
2970
+ * client.getSpace('<space_id>')
2971
+ * .then((space) => space.getEnvironment('<environment_id>'))
2972
+ * .then((environment) => environment.getAgentRun('<run_id>'))
2973
+ * .then((run) => console.log(run))
2974
+ * .catch(console.error)
2975
+ * ```
2976
+ */
2977
+ getAgentRun(runId) {
2978
+ const raw = this.toPlainObject();
2979
+ return makeRequest({
2980
+ entityType: 'AgentRun',
2981
+ action: 'get',
2982
+ params: {
2983
+ spaceId: raw.sys.space.sys.id,
2984
+ environmentId: raw.sys.id,
2985
+ runId
2986
+ }
2987
+ }).then(data => wrapAgentRun(makeRequest, data));
2988
+ },
2989
+ /**
2990
+ * Gets a collection of AI Agent Runs with optional filtering
2991
+ * @param query - Object with search parameters (agentIn, statusIn)
2992
+ * @return Promise for a collection of AI Agent Runs
2993
+ * @example ```javascript
2994
+ * const contentful = require('contentful-management')
2995
+ *
2996
+ * const client = contentful.createClient({
2997
+ * accessToken: '<content_management_api_key>'
2998
+ * })
2999
+ *
3000
+ * client.getSpace('<space_id>')
3001
+ * .then((space) => space.getEnvironment('<environment_id>'))
3002
+ * .then((environment) => environment.getAgentRuns({
3003
+ * agentIn: ['agent1', 'agent2'],
3004
+ * statusIn: ['COMPLETED', 'IN_PROGRESS']
3005
+ * }))
3006
+ * .then((response) => console.log(response.items))
3007
+ * .catch(console.error)
3008
+ * ```
3009
+ */
3010
+ getAgentRuns(query = {}) {
3011
+ const raw = this.toPlainObject();
3012
+ return makeRequest({
3013
+ entityType: 'AgentRun',
3014
+ action: 'getMany',
3015
+ params: {
3016
+ spaceId: raw.sys.space.sys.id,
3017
+ environmentId: raw.sys.id,
3018
+ query
3019
+ }
3020
+ }).then(data => wrapAgentRunCollection(makeRequest, data));
2848
3021
  }
2849
3022
  };
2850
3023
  }
@@ -0,0 +1,8 @@
1
+ import { freezeSys, toPlainObject } from 'contentful-sdk-core';
2
+ import copy from 'fast-copy';
3
+ import { wrapCollection } from '../common-utils';
4
+ export function wrapAgentRun(_makeRequest, data) {
5
+ const agentRun = toPlainObject(copy(data));
6
+ return freezeSys(agentRun);
7
+ }
8
+ export const wrapAgentRunCollection = wrapCollection(wrapAgentRun);
@@ -0,0 +1,29 @@
1
+ import { freezeSys, toPlainObject } from 'contentful-sdk-core';
2
+ import copy from 'fast-copy';
3
+ import { wrapCollection } from '../common-utils';
4
+ import enhanceWithMethods from '../enhance-with-methods';
5
+ import { wrapAgentRun } from './agent-run';
6
+ function createAgentApi(makeRequest) {
7
+ const getParams = data => ({
8
+ spaceId: data.sys.space.sys.id,
9
+ environmentId: data.sys.environment.sys.id,
10
+ agentId: data.sys.id
11
+ });
12
+ return {
13
+ generate: function generate(payload) {
14
+ const self = this;
15
+ return makeRequest({
16
+ entityType: 'Agent',
17
+ action: 'generate',
18
+ params: getParams(self),
19
+ payload
20
+ }).then(data => wrapAgentRun(makeRequest, data));
21
+ }
22
+ };
23
+ }
24
+ export function wrapAgent(makeRequest, data) {
25
+ const agent = toPlainObject(copy(data));
26
+ const agentWithMethods = enhanceWithMethods(agent, createAgentApi(makeRequest));
27
+ return freezeSys(agentWithMethods);
28
+ }
29
+ export const wrapAgentCollection = wrapCollection(wrapAgent);
@@ -1,5 +1,7 @@
1
1
  import * as aiAction from './ai-action';
2
2
  import * as aiActionInvocation from './ai-action-invocation';
3
+ import * as agent from './agent';
4
+ import * as agentRun from './agent-run';
3
5
  import * as apiKey from './api-key';
4
6
  import * as appAction from './app-action';
5
7
  import * as appActionCall from './app-action-call';
@@ -68,6 +70,8 @@ import * as resource from './resource';
68
70
  export default {
69
71
  aiAction,
70
72
  aiActionInvocation,
73
+ agent,
74
+ agentRun,
71
75
  accessToken,
72
76
  appAction,
73
77
  appActionCall,
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -81,6 +81,15 @@ export const createPlainClient = (makeRequest, defaults) => {
81
81
  aiActionInvocation: {
82
82
  get: wrap(wrapParams, 'AiActionInvocation', 'get')
83
83
  },
84
+ agent: {
85
+ get: wrap(wrapParams, 'Agent', 'get'),
86
+ getMany: wrap(wrapParams, 'Agent', 'getMany'),
87
+ generate: wrap(wrapParams, 'Agent', 'generate')
88
+ },
89
+ agentRun: {
90
+ get: wrap(wrapParams, 'AgentRun', 'get'),
91
+ getMany: wrap(wrapParams, 'AgentRun', 'getMany')
92
+ },
84
93
  appAction: {
85
94
  get: wrap(wrapParams, 'AppAction', 'get'),
86
95
  getMany: wrap(wrapParams, 'AppAction', 'getMany'),
@@ -0,0 +1,3 @@
1
+ import type { RestEndpoint } from '../types';
2
+ export declare const get: RestEndpoint<'AgentRun', 'get'>;
3
+ export declare const getMany: RestEndpoint<'AgentRun', 'getMany'>;
@@ -0,0 +1,4 @@
1
+ import type { RestEndpoint } from '../types';
2
+ export declare const get: RestEndpoint<'Agent', 'get'>;
3
+ export declare const getMany: RestEndpoint<'Agent', 'getMany'>;
4
+ export declare const generate: RestEndpoint<'Agent', 'generate'>;
@@ -1,5 +1,7 @@
1
1
  import * as AiAction from './ai-action';
2
2
  import * as AiActionInvocation from './ai-action-invocation';
3
+ import * as Agent from './agent';
4
+ import * as AgentRun from './agent-run';
3
5
  import * as AccessToken from './access-token';
4
6
  import * as ApiKey from './api-key';
5
7
  import * as AppAccessToken from './app-access-token';
@@ -74,6 +76,8 @@ import * as WorkflowsChangelog from './workflows-changelog';
74
76
  declare const _default: {
75
77
  AiAction: typeof AiAction;
76
78
  AiActionInvocation: typeof AiActionInvocation;
79
+ Agent: typeof Agent;
80
+ AgentRun: typeof AgentRun;
77
81
  ApiKey: typeof ApiKey;
78
82
  AppAction: typeof AppAction;
79
83
  AppActionCall: typeof AppActionCall;
@@ -64,6 +64,8 @@ import type { CreateOAuthApplicationProps, OAuthApplicationProps, UpdateOAuthApp
64
64
  import type { FunctionLogProps } from './entities/function-log';
65
65
  import type { AiActionProps, AiActionQueryOptions, CreateAiActionProps } from './entities/ai-action';
66
66
  import type { AiActionInvocationProps, AiActionInvocationType } from './entities/ai-action-invocation';
67
+ import type { AgentGeneratePayload, AgentProps } from './entities/agent';
68
+ import type { AgentRunProps, AgentRunQueryOptions } from './entities/agent-run';
67
69
  import type { UpdateVectorizationStatusProps, VectorizationStatusProps } from './entities/vectorization-status';
68
70
  import type { GetSemanticDuplicatesProps, SemanticDuplicatesProps } from './entities/semantic-duplicates';
69
71
  import type { GetSemanticRecommendationsProps, SemanticRecommendationsProps } from './entities/semantic-recommendations';
@@ -267,6 +269,11 @@ type MRInternal<UA extends boolean> = {
267
269
  (opts: MROpts<'AiAction', 'unpublish', UA>): MRReturn<'AiAction', 'unpublish'>;
268
270
  (opts: MROpts<'AiAction', 'invoke', UA>): MRReturn<'AiAction', 'invoke'>;
269
271
  (opts: MROpts<'AiActionInvocation', 'get', UA>): MRReturn<'AiActionInvocation', 'get'>;
272
+ (opts: MROpts<'Agent', 'get', UA>): MRReturn<'Agent', 'get'>;
273
+ (opts: MROpts<'Agent', 'getMany', UA>): MRReturn<'Agent', 'getMany'>;
274
+ (opts: MROpts<'Agent', 'generate', UA>): MRReturn<'Agent', 'generate'>;
275
+ (opts: MROpts<'AgentRun', 'get', UA>): MRReturn<'AgentRun', 'get'>;
276
+ (opts: MROpts<'AgentRun', 'getMany', UA>): MRReturn<'AgentRun', 'getMany'>;
270
277
  (opts: MROpts<'AppAction', 'get', UA>): MRReturn<'AppAction', 'get'>;
271
278
  (opts: MROpts<'AppAction', 'getMany', UA>): MRReturn<'AppAction', 'getMany'>;
272
279
  (opts: MROpts<'AppAction', 'delete', UA>): MRReturn<'AppAction', 'delete'>;
@@ -793,6 +800,44 @@ export type MRActions = {
793
800
  return: AiActionInvocationProps;
794
801
  };
795
802
  };
803
+ Agent: {
804
+ get: {
805
+ params: GetSpaceEnvironmentParams & {
806
+ agentId: string;
807
+ };
808
+ headers?: RawAxiosRequestHeaders;
809
+ return: AgentProps;
810
+ };
811
+ getMany: {
812
+ params: GetSpaceEnvironmentParams;
813
+ headers?: RawAxiosRequestHeaders;
814
+ return: CollectionProp<AgentProps>;
815
+ };
816
+ generate: {
817
+ params: GetSpaceEnvironmentParams & {
818
+ agentId: string;
819
+ };
820
+ payload: AgentGeneratePayload;
821
+ headers?: RawAxiosRequestHeaders;
822
+ return: AgentRunProps;
823
+ };
824
+ };
825
+ AgentRun: {
826
+ get: {
827
+ params: GetSpaceEnvironmentParams & {
828
+ runId: string;
829
+ };
830
+ headers?: RawAxiosRequestHeaders;
831
+ return: AgentRunProps;
832
+ };
833
+ getMany: {
834
+ params: GetSpaceEnvironmentParams & {
835
+ query?: AgentRunQueryOptions;
836
+ };
837
+ headers?: RawAxiosRequestHeaders;
838
+ return: CollectionProp<AgentRunProps>;
839
+ };
840
+ };
796
841
  AppAction: {
797
842
  get: {
798
843
  params: GetAppActionParams;
@@ -17,6 +17,8 @@ import type { TagVisibility } from './entities/tag';
17
17
  import type { CreateAppAccessTokenProps } from './entities/app-access-token';
18
18
  import type { ResourceQueryOptions } from './entities/resource';
19
19
  import type { AiActionInvocationType } from './entities/ai-action-invocation';
20
+ import type { AgentGeneratePayload } from './entities/agent';
21
+ import type { AgentRunQueryOptions } from './entities/agent-run';
20
22
  import type { GetSemanticDuplicatesProps } from './entities/semantic-duplicates';
21
23
  import type { GetSemanticRecommendationsProps } from './entities/semantic-recommendations';
22
24
  import type { GetSemanticReferenceSuggestionsProps } from './entities/semantic-reference-suggestions';
@@ -1849,4 +1851,114 @@ export default function createEnvironmentApi(makeRequest: MakeRequest): {
1849
1851
  * })
1850
1852
  */
1851
1853
  getSemanticSearch(payload: GetSemanticSearchProps): Promise<import("./entities/semantic-search").SemanticSearch>;
1854
+ /**
1855
+ * Gets an AI Agent
1856
+ * @param agentId - AI Agent ID
1857
+ * @return Promise for an AI Agent
1858
+ * @example ```javascript
1859
+ * const contentful = require('contentful-management')
1860
+ *
1861
+ * const client = contentful.createClient({
1862
+ * accessToken: '<content_management_api_key>'
1863
+ * })
1864
+ *
1865
+ * client.getSpace('<space_id>')
1866
+ * .then((space) => space.getEnvironment('<environment_id>'))
1867
+ * .then((environment) => environment.getAgent('<agent_id>'))
1868
+ * .then((agent) => console.log(agent))
1869
+ * .catch(console.error)
1870
+ * ```
1871
+ */
1872
+ getAgent(agentId: string): Promise<import("./entities/agent").Agent>;
1873
+ /**
1874
+ * Gets a collection of AI Agents
1875
+ * @return Promise for a collection of AI Agents
1876
+ * @example ```javascript
1877
+ * const contentful = require('contentful-management')
1878
+ *
1879
+ * const client = contentful.createClient({
1880
+ * accessToken: '<content_management_api_key>'
1881
+ * })
1882
+ *
1883
+ * client.getSpace('<space_id>')
1884
+ * .then((space) => space.getEnvironment('<environment_id>'))
1885
+ * .then((environment) => environment.getAgents())
1886
+ * .then((response) => console.log(response.items))
1887
+ * .catch(console.error)
1888
+ * ```
1889
+ */
1890
+ getAgents(): Promise<import("./common-types").Collection<import("./entities/agent").Agent, import("./entities/agent").AgentProps>>;
1891
+ /**
1892
+ * Generates content using an AI Agent
1893
+ * @param agentId - AI Agent ID
1894
+ * @param payload - Generation payload
1895
+ * @return Promise for the generation response
1896
+ * @example ```javascript
1897
+ * const contentful = require('contentful-management')
1898
+ *
1899
+ * const client = contentful.createClient({
1900
+ * accessToken: '<content_management_api_key>'
1901
+ * })
1902
+ *
1903
+ * client.getSpace('<space_id>')
1904
+ * .then((space) => space.getEnvironment('<environment_id>'))
1905
+ * .then((environment) => environment.generateWithAgent('<agent_id>', {
1906
+ * messages: [
1907
+ * {
1908
+ * parts: [
1909
+ * {
1910
+ * type: 'text',
1911
+ * text: 'Write a short poem about Contentful'
1912
+ * }
1913
+ * ],
1914
+ * role: 'user'
1915
+ * }
1916
+ * ]
1917
+ * }))
1918
+ * .then((result) => console.log(result))
1919
+ * .catch(console.error)
1920
+ * ```
1921
+ */
1922
+ generateWithAgent(agentId: string, payload: AgentGeneratePayload): Promise<import("./entities/agent-run").AgentRun>;
1923
+ /**
1924
+ * Gets an AI Agent Run
1925
+ * @param runId - AI Agent Run ID
1926
+ * @return Promise for an AI Agent Run
1927
+ * @example ```javascript
1928
+ * const contentful = require('contentful-management')
1929
+ *
1930
+ * const client = contentful.createClient({
1931
+ * accessToken: '<content_management_api_key>'
1932
+ * })
1933
+ *
1934
+ * client.getSpace('<space_id>')
1935
+ * .then((space) => space.getEnvironment('<environment_id>'))
1936
+ * .then((environment) => environment.getAgentRun('<run_id>'))
1937
+ * .then((run) => console.log(run))
1938
+ * .catch(console.error)
1939
+ * ```
1940
+ */
1941
+ getAgentRun(runId: string): Promise<import("./entities/agent-run").AgentRun>;
1942
+ /**
1943
+ * Gets a collection of AI Agent Runs with optional filtering
1944
+ * @param query - Object with search parameters (agentIn, statusIn)
1945
+ * @return Promise for a collection of AI Agent Runs
1946
+ * @example ```javascript
1947
+ * const contentful = require('contentful-management')
1948
+ *
1949
+ * const client = contentful.createClient({
1950
+ * accessToken: '<content_management_api_key>'
1951
+ * })
1952
+ *
1953
+ * client.getSpace('<space_id>')
1954
+ * .then((space) => space.getEnvironment('<environment_id>'))
1955
+ * .then((environment) => environment.getAgentRuns({
1956
+ * agentIn: ['agent1', 'agent2'],
1957
+ * statusIn: ['COMPLETED', 'IN_PROGRESS']
1958
+ * }))
1959
+ * .then((response) => console.log(response.items))
1960
+ * .catch(console.error)
1961
+ * ```
1962
+ */
1963
+ getAgentRuns(query?: AgentRunQueryOptions): Promise<import("./common-types").Collection<import("./entities/agent-run").AgentRun, import("./entities/agent-run").AgentRunProps>>;
1852
1964
  };
@@ -0,0 +1,47 @@
1
+ import type { DefaultElements, Link, MakeRequest, MetaSysProps } from '../common-types';
2
+ export type AgentRunStatus = 'IN_PROGRESS' | 'FAILED' | 'COMPLETED' | 'PENDING_REVIEW' | 'DRAFT';
3
+ export type AgentRunMessageRole = 'system' | 'user' | 'assistant' | 'tool';
4
+ export type AgentRunMessageTextPart = {
5
+ type: 'text';
6
+ text: string;
7
+ };
8
+ export type AgentRunMessageToolCallPart = {
9
+ type: 'tool-call';
10
+ toolCallId: string;
11
+ toolName: string;
12
+ args: unknown;
13
+ };
14
+ export type AgentRunMessagePart = AgentRunMessageTextPart | AgentRunMessageToolCallPart;
15
+ export type AgentRunMessage = {
16
+ id: string;
17
+ createdAt: string;
18
+ role: AgentRunMessageRole;
19
+ content: {
20
+ parts: Array<AgentRunMessagePart>;
21
+ };
22
+ };
23
+ export type AgentRunProps = {
24
+ sys: MetaSysProps & {
25
+ type: 'AgentRun';
26
+ createdAt: string;
27
+ updatedAt?: string;
28
+ status: AgentRunStatus;
29
+ id: string;
30
+ };
31
+ agent: {
32
+ sys: Link<'Agent'>;
33
+ };
34
+ space: {
35
+ sys: Link<'Space'>;
36
+ };
37
+ title: string;
38
+ messages: Array<AgentRunMessage>;
39
+ };
40
+ export type AgentRunQueryOptions = {
41
+ agentIn?: string[];
42
+ statusIn?: AgentRunStatus[];
43
+ };
44
+ export interface AgentRun extends AgentRunProps, DefaultElements<AgentRunProps> {
45
+ }
46
+ export declare function wrapAgentRun(_makeRequest: MakeRequest, data: AgentRunProps): AgentRun;
47
+ export declare const wrapAgentRunCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<AgentRunProps>) => import("../common-types").Collection<AgentRun, AgentRunProps>;
@@ -0,0 +1,49 @@
1
+ import type { DefaultElements, MakeRequest, MetaSysProps } from '../common-types';
2
+ import { type AgentRun } from './agent-run';
3
+ export type AgentToolLink = {
4
+ sys: {
5
+ type: 'Link';
6
+ linkType: 'AgentTool';
7
+ id: string;
8
+ };
9
+ };
10
+ export type AgentProps = {
11
+ sys: MetaSysProps & {
12
+ type: 'Agent';
13
+ space: {
14
+ sys: {
15
+ id: string;
16
+ };
17
+ };
18
+ environment: {
19
+ sys: {
20
+ id: string;
21
+ };
22
+ };
23
+ createdAt: string;
24
+ id: string;
25
+ };
26
+ name: string;
27
+ description: string;
28
+ tools?: Array<AgentToolLink>;
29
+ provider?: string;
30
+ modelId?: string;
31
+ };
32
+ type AgentMessageRole = 'system' | 'user' | 'assistant' | 'tool';
33
+ export type AgentGeneratePayload = {
34
+ messages: Array<{
35
+ parts: Array<{
36
+ type: 'text';
37
+ text: string;
38
+ }>;
39
+ id?: string;
40
+ role: AgentMessageRole;
41
+ }>;
42
+ threadId?: string;
43
+ };
44
+ export interface Agent extends AgentProps, DefaultElements<AgentProps> {
45
+ generate(payload: AgentGeneratePayload): Promise<AgentRun>;
46
+ }
47
+ export declare function wrapAgent(makeRequest: MakeRequest, data: AgentProps): Agent;
48
+ export declare const wrapAgentCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<AgentProps>) => import("../common-types").Collection<Agent, AgentProps>;
49
+ export {};
@@ -1,5 +1,7 @@
1
1
  import * as aiAction from './ai-action';
2
2
  import * as aiActionInvocation from './ai-action-invocation';
3
+ import * as agent from './agent';
4
+ import * as agentRun from './agent-run';
3
5
  import * as apiKey from './api-key';
4
6
  import * as appAction from './app-action';
5
7
  import * as appActionCall from './app-action-call';
@@ -68,6 +70,8 @@ import * as resource from './resource';
68
70
  declare const _default: {
69
71
  aiAction: typeof aiAction;
70
72
  aiActionInvocation: typeof aiActionInvocation;
73
+ agent: typeof agent;
74
+ agentRun: typeof agentRun;
71
75
  accessToken: typeof accessToken;
72
76
  appAction: typeof appAction;
73
77
  appActionCall: typeof appActionCall;