@codemieai/cdk 0.1.448 → 0.1.450

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/cli/index.js CHANGED
@@ -938,7 +938,7 @@ var init_backupTransformers = __esm({
938
938
 
939
939
  // package.json
940
940
  var package_default = {
941
- version: "0.1.448"};
941
+ version: "0.1.450"};
942
942
  var appConfigSchema = z.object({
943
943
  rootDir: z.string(),
944
944
  codemieConfig: z.string(),
@@ -2275,7 +2275,7 @@ async function main(options) {
2275
2275
 
2276
2276
  // src/lib/paginationUtils.ts
2277
2277
  init_logger();
2278
- async function findResourceByName(listFn, name, resourceType) {
2278
+ async function findResourceByName(listFn, name, resourceType, options) {
2279
2279
  let page = 0;
2280
2280
  const perPage = 100;
2281
2281
  let totalChecked = 0;
@@ -2287,14 +2287,18 @@ async function findResourceByName(listFn, name, resourceType) {
2287
2287
  return found;
2288
2288
  }
2289
2289
  if (resources.length < perPage) {
2290
- logger.warn(
2291
- ` \u26A0\uFE0F ${resourceType} "${name}" not found after checking ${totalChecked} resources across ${page + 1} page(s)`
2292
- );
2290
+ if (!options?.silent) {
2291
+ logger.warn(
2292
+ ` \u26A0\uFE0F ${resourceType} "${name}" not found after checking ${totalChecked} resources across ${page + 1} page(s)`
2293
+ );
2294
+ }
2293
2295
  return null;
2294
2296
  }
2295
2297
  page++;
2296
2298
  if (page > 1e3) {
2297
- logger.warn(` \u26A0\uFE0F Stopped pagination after 1000 pages (${totalChecked} resources checked)`);
2299
+ if (!options?.silent) {
2300
+ logger.warn(` \u26A0\uFE0F Stopped pagination after 1000 pages (${totalChecked} resources checked)`);
2301
+ }
2298
2302
  return null;
2299
2303
  }
2300
2304
  }
@@ -2303,9 +2307,25 @@ async function findDatasourceByName(client, name) {
2303
2307
  const datasource = await findResourceByName((params) => client.datasources.list(params), name, "datasource");
2304
2308
  return datasource?.id || null;
2305
2309
  }
2306
- async function findAssistantByName(client, name) {
2307
- const assistant = await findResourceByName((params) => client.assistants.list(params), name, "assistant");
2308
- return assistant?.id || null;
2310
+ async function findAssistantByName(client, name, options) {
2311
+ const assistant = await findResourceByName(
2312
+ (params) => client.assistants.list(params),
2313
+ name,
2314
+ "assistant",
2315
+ options?.isGlobal ? { silent: true } : void 0
2316
+ );
2317
+ if (assistant?.id) {
2318
+ return assistant.id;
2319
+ }
2320
+ if (options?.isGlobal) {
2321
+ const marketplaceAssistant = await findResourceByName(
2322
+ (params) => client.assistants.list({ ...params, scope: "marketplace" }),
2323
+ name,
2324
+ "assistant"
2325
+ );
2326
+ return marketplaceAssistant?.id || null;
2327
+ }
2328
+ return null;
2309
2329
  }
2310
2330
  async function findSkillByName(client, name) {
2311
2331
  const skill = await findResourceByName((params) => client.skills.list(params), name, "skill");
@@ -2322,7 +2342,9 @@ async function createAssistantAndGetId(client, params, slug) {
2322
2342
  }
2323
2343
  return created.id;
2324
2344
  }
2325
- const assistantId = await findAssistantByName(client, params.name);
2345
+ const assistantId = await findAssistantByName(client, params.name, {
2346
+ isGlobal: params.is_global === true
2347
+ });
2326
2348
  if (!assistantId) {
2327
2349
  throw new Error(`Assistant created but not found by name: ${params.name}`);
2328
2350
  }
@@ -2982,7 +3004,9 @@ async function deployAssistants(config, client, loader, stateManager) {
2982
3004
  }
2983
3005
  }
2984
3006
  if (!existingId) {
2985
- existingId = await findAssistantByName(client, assistant.name);
3007
+ existingId = await findAssistantByName(client, assistant.name, {
3008
+ isGlobal: assistant.is_global === true
3009
+ });
2986
3010
  }
2987
3011
  if (!existingId) {
2988
3012
  throw createError;
@@ -3018,7 +3042,9 @@ async function deployAssistants(config, client, loader, stateManager) {
3018
3042
  }
3019
3043
  }
3020
3044
  if (!existingId) {
3021
- existingId = await findAssistantByName(client, assistant.name);
3045
+ existingId = await findAssistantByName(client, assistant.name, {
3046
+ isGlobal: assistant.is_global === true
3047
+ });
3022
3048
  }
3023
3049
  if (!existingId) {
3024
3050
  throw createError;
package/dist/index.js CHANGED
@@ -1766,7 +1766,7 @@ init_logger();
1766
1766
 
1767
1767
  // src/lib/paginationUtils.ts
1768
1768
  init_logger();
1769
- async function findResourceByName(listFn, name, resourceType) {
1769
+ async function findResourceByName(listFn, name, resourceType, options) {
1770
1770
  let page = 0;
1771
1771
  const perPage = 100;
1772
1772
  let totalChecked = 0;
@@ -1778,14 +1778,18 @@ async function findResourceByName(listFn, name, resourceType) {
1778
1778
  return found;
1779
1779
  }
1780
1780
  if (resources.length < perPage) {
1781
- logger.warn(
1782
- ` \u26A0\uFE0F ${resourceType} "${name}" not found after checking ${totalChecked} resources across ${page + 1} page(s)`
1783
- );
1781
+ if (!options?.silent) {
1782
+ logger.warn(
1783
+ ` \u26A0\uFE0F ${resourceType} "${name}" not found after checking ${totalChecked} resources across ${page + 1} page(s)`
1784
+ );
1785
+ }
1784
1786
  return null;
1785
1787
  }
1786
1788
  page++;
1787
1789
  if (page > 1e3) {
1788
- logger.warn(` \u26A0\uFE0F Stopped pagination after 1000 pages (${totalChecked} resources checked)`);
1790
+ if (!options?.silent) {
1791
+ logger.warn(` \u26A0\uFE0F Stopped pagination after 1000 pages (${totalChecked} resources checked)`);
1792
+ }
1789
1793
  return null;
1790
1794
  }
1791
1795
  }
@@ -1794,9 +1798,25 @@ async function findDatasourceByName(client, name) {
1794
1798
  const datasource = await findResourceByName((params) => client.datasources.list(params), name, "datasource");
1795
1799
  return datasource?.id || null;
1796
1800
  }
1797
- async function findAssistantByName(client, name) {
1798
- const assistant = await findResourceByName((params) => client.assistants.list(params), name, "assistant");
1799
- return assistant?.id || null;
1801
+ async function findAssistantByName(client, name, options) {
1802
+ const assistant = await findResourceByName(
1803
+ (params) => client.assistants.list(params),
1804
+ name,
1805
+ "assistant",
1806
+ options?.isGlobal ? { silent: true } : void 0
1807
+ );
1808
+ if (assistant?.id) {
1809
+ return assistant.id;
1810
+ }
1811
+ if (options?.isGlobal) {
1812
+ const marketplaceAssistant = await findResourceByName(
1813
+ (params) => client.assistants.list({ ...params, scope: "marketplace" }),
1814
+ name,
1815
+ "assistant"
1816
+ );
1817
+ return marketplaceAssistant?.id || null;
1818
+ }
1819
+ return null;
1800
1820
  }
1801
1821
  async function findSkillByName(client, name) {
1802
1822
  const skill = await findResourceByName((params) => client.skills.list(params), name, "skill");
@@ -1813,7 +1833,9 @@ async function createAssistantAndGetId(client, params, slug) {
1813
1833
  }
1814
1834
  return created.id;
1815
1835
  }
1816
- const assistantId = await findAssistantByName(client, params.name);
1836
+ const assistantId = await findAssistantByName(client, params.name, {
1837
+ isGlobal: params.is_global === true
1838
+ });
1817
1839
  if (!assistantId) {
1818
1840
  throw new Error(`Assistant created but not found by name: ${params.name}`);
1819
1841
  }
@@ -2021,7 +2043,9 @@ async function deployAssistants(config, client, loader, stateManager) {
2021
2043
  }
2022
2044
  }
2023
2045
  if (!existingId) {
2024
- existingId = await findAssistantByName(client, assistant.name);
2046
+ existingId = await findAssistantByName(client, assistant.name, {
2047
+ isGlobal: assistant.is_global === true
2048
+ });
2025
2049
  }
2026
2050
  if (!existingId) {
2027
2051
  throw createError;
@@ -2057,7 +2081,9 @@ async function deployAssistants(config, client, loader, stateManager) {
2057
2081
  }
2058
2082
  }
2059
2083
  if (!existingId) {
2060
- existingId = await findAssistantByName(client, assistant.name);
2084
+ existingId = await findAssistantByName(client, assistant.name, {
2085
+ isGlobal: assistant.is_global === true
2086
+ });
2061
2087
  }
2062
2088
  if (!existingId) {
2063
2089
  throw createError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemieai/cdk",
3
- "version": "0.1.448",
3
+ "version": "0.1.450",
4
4
  "type": "module",
5
5
  "description": "Infrastructure as Code solution for managing Codemie AI assistants, datasources, and workflows through declarative YAML configuration",
6
6
  "main": "./dist/index.js",