@elevasis/sdk 1.34.0 → 1.34.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.
package/dist/cli.cjs CHANGED
@@ -23629,18 +23629,18 @@ var init_config = __esm({
23629
23629
  // src/cli/commands/om/project-layout.ts
23630
23630
  function assertSplitLayout(projectDir) {
23631
23631
  const omDir = (0, import_node_path9.join)(projectDir, "core", "config", "organization-model");
23632
- const missing = REQUIRED_FILES.filter((f) => !(0, import_node_fs10.existsSync)((0, import_node_path9.join)(omDir, f)));
23632
+ const missing = REQUIRED_FILES.filter((f) => !(0, import_node_fs11.existsSync)((0, import_node_path9.join)(omDir, f)));
23633
23633
  if (missing.length > 0) {
23634
23634
  throw new Error(
23635
23635
  "Legacy single-file OM layout detected. Split into `core/config/organization-model/{profile.ts, systems.ts, navigation.ts}` before scaffolding."
23636
23636
  );
23637
23637
  }
23638
23638
  }
23639
- var import_node_fs10, import_node_path9, REQUIRED_FILES;
23639
+ var import_node_fs11, import_node_path9, REQUIRED_FILES;
23640
23640
  var init_project_layout = __esm({
23641
23641
  "src/cli/commands/om/project-layout.ts"() {
23642
23642
  "use strict";
23643
- import_node_fs10 = require("node:fs");
23643
+ import_node_fs11 = require("node:fs");
23644
23644
  import_node_path9 = require("node:path");
23645
23645
  REQUIRED_FILES = ["profile.ts", "systems.ts", "navigation.ts"];
23646
23646
  }
@@ -23741,7 +23741,7 @@ async function withSnapshotRollback(filePaths, op) {
23741
23741
  const snapshots = /* @__PURE__ */ new Map();
23742
23742
  for (const filePath of filePaths) {
23743
23743
  try {
23744
- snapshots.set(filePath, (0, import_node_fs11.readFileSync)(filePath, "utf8"));
23744
+ snapshots.set(filePath, (0, import_node_fs12.readFileSync)(filePath, "utf8"));
23745
23745
  } catch {
23746
23746
  snapshots.set(filePath, null);
23747
23747
  }
@@ -23752,7 +23752,7 @@ async function withSnapshotRollback(filePaths, op) {
23752
23752
  for (const [filePath, snapshot] of snapshots) {
23753
23753
  if (snapshot !== null) {
23754
23754
  try {
23755
- (0, import_node_fs11.writeFileSync)(filePath, snapshot, "utf8");
23755
+ (0, import_node_fs12.writeFileSync)(filePath, snapshot, "utf8");
23756
23756
  } catch {
23757
23757
  }
23758
23758
  }
@@ -23773,14 +23773,14 @@ function insertBeforeAnchorInContent(content, code, anchor) {
23773
23773
  return lines.join("\n");
23774
23774
  }
23775
23775
  async function appendBeforeAnchor(filePath, code, anchor) {
23776
- const content = (0, import_node_fs11.readFileSync)(filePath, "utf8");
23776
+ const content = (0, import_node_fs12.readFileSync)(filePath, "utf8");
23777
23777
  const updated = insertBeforeAnchorInContent(content, code, anchor);
23778
- (0, import_node_fs11.writeFileSync)(filePath, updated, "utf8");
23778
+ (0, import_node_fs12.writeFileSync)(filePath, updated, "utf8");
23779
23779
  }
23780
23780
  async function applyConstImport(systemsFilePath, importLine, fieldLine, importAnchor, fieldAnchor, newConstFilePath, newConstFileCode) {
23781
- (0, import_node_fs11.mkdirSync)((0, import_node_path10.dirname)(newConstFilePath), { recursive: true });
23782
- (0, import_node_fs11.writeFileSync)(newConstFilePath, newConstFileCode, "utf8");
23783
- const systemsContent = (0, import_node_fs11.readFileSync)(systemsFilePath, "utf8");
23781
+ (0, import_node_fs12.mkdirSync)((0, import_node_path10.dirname)(newConstFilePath), { recursive: true });
23782
+ (0, import_node_fs12.writeFileSync)(newConstFilePath, newConstFileCode, "utf8");
23783
+ const systemsContent = (0, import_node_fs12.readFileSync)(systemsFilePath, "utf8");
23784
23784
  const afterImport = insertBeforeAnchorInContent(systemsContent, importLine + "\n", importAnchor);
23785
23785
  const lines = afterImport.split("\n");
23786
23786
  const fieldAnchorIndex = lines.findIndex((line) => fieldAnchor.test(line));
@@ -23790,13 +23790,13 @@ async function applyConstImport(systemsFilePath, importLine, fieldLine, importAn
23790
23790
  );
23791
23791
  }
23792
23792
  lines.splice(fieldAnchorIndex + 1, 0, fieldLine);
23793
- (0, import_node_fs11.writeFileSync)(systemsFilePath, lines.join("\n"), "utf8");
23793
+ (0, import_node_fs12.writeFileSync)(systemsFilePath, lines.join("\n"), "utf8");
23794
23794
  }
23795
- var import_node_fs11, import_node_path10;
23795
+ var import_node_fs12, import_node_path10;
23796
23796
  var init_splice = __esm({
23797
23797
  "src/cli/commands/om/splice.ts"() {
23798
23798
  "use strict";
23799
- import_node_fs11 = require("node:fs");
23799
+ import_node_fs12 = require("node:fs");
23800
23800
  import_node_path10 = require("node:path");
23801
23801
  }
23802
23802
  });
@@ -24168,24 +24168,24 @@ async function scaffoldKnowledge(opts) {
24168
24168
  return;
24169
24169
  }
24170
24170
  const absoluteFilePath = (0, import_node_path14.join)(projectDir, relativeFilePath);
24171
- if ((0, import_node_fs12.existsSync)(absoluteFilePath)) {
24171
+ if ((0, import_node_fs13.existsSync)(absoluteFilePath)) {
24172
24172
  process.stderr.write(
24173
24173
  source_default.red(`Knowledge node file already exists at \`${relativeFilePath}\`. Choose a different id.
24174
24174
  `)
24175
24175
  );
24176
24176
  process.exit(1);
24177
24177
  }
24178
- (0, import_node_fs12.mkdirSync)((0, import_node_path14.join)(projectDir, "core", "config", "knowledge", "nodes"), { recursive: true });
24179
- (0, import_node_fs12.writeFileSync)(absoluteFilePath, content, "utf8");
24178
+ (0, import_node_fs13.mkdirSync)((0, import_node_path14.join)(projectDir, "core", "config", "knowledge", "nodes"), { recursive: true });
24179
+ (0, import_node_fs13.writeFileSync)(absoluteFilePath, content, "utf8");
24180
24180
  console.log(source_default.green(`Knowledge node \`${id}\` written to \`${relativeFilePath}\``));
24181
24181
  console.log(source_default.yellow("Run `elevasis-sdk om:generate` to register this node."));
24182
24182
  }
24183
- var import_node_path14, import_node_fs12, VALID_KINDS;
24183
+ var import_node_path14, import_node_fs13, VALID_KINDS;
24184
24184
  var init_scaffold_knowledge = __esm({
24185
24185
  "src/cli/commands/om/scaffold-knowledge.ts"() {
24186
24186
  "use strict";
24187
24187
  import_node_path14 = require("node:path");
24188
- import_node_fs12 = require("node:fs");
24188
+ import_node_fs13 = require("node:fs");
24189
24189
  init_source();
24190
24190
  init_config();
24191
24191
  init_project_layout();
@@ -24261,7 +24261,7 @@ async function scaffoldFill(opts) {
24261
24261
  process.stderr.write(source_default.red("Missing gaps file. Pass --gaps <path> pointing to a conformance gap JSON file.\n"));
24262
24262
  process.exit(1);
24263
24263
  }
24264
- if (!(0, import_node_fs13.existsSync)(options.gaps)) {
24264
+ if (!(0, import_node_fs14.existsSync)(options.gaps)) {
24265
24265
  process.stderr.write(
24266
24266
  source_default.red(
24267
24267
  `Missing gaps file. Pass --gaps <path> pointing to a conformance gap JSON file.
@@ -24273,7 +24273,7 @@ async function scaffoldFill(opts) {
24273
24273
  }
24274
24274
  let payload;
24275
24275
  try {
24276
- const raw = (0, import_node_fs13.readFileSync)(options.gaps, "utf8");
24276
+ const raw = (0, import_node_fs14.readFileSync)(options.gaps, "utf8");
24277
24277
  payload = JSON.parse(raw);
24278
24278
  } catch {
24279
24279
  process.stderr.write(
@@ -24394,7 +24394,7 @@ async function scaffoldFill(opts) {
24394
24394
  }
24395
24395
  if (skippedGaps.length > 0) {
24396
24396
  const skippedPath = options.skipped ?? (0, import_node_path15.join)(os2.tmpdir(), `elevasis-fill-skipped-${systemPath}-${Date.now()}.json`);
24397
- (0, import_node_fs13.writeFileSync)(skippedPath, JSON.stringify({ systemPath, skipped: skippedGaps }, null, 2), "utf8");
24397
+ (0, import_node_fs14.writeFileSync)(skippedPath, JSON.stringify({ systemPath, skipped: skippedGaps }, null, 2), "utf8");
24398
24398
  console.log(
24399
24399
  source_default.yellow(
24400
24400
  `Partial fill: ${appliedGaps.length} gap(s) applied, ${skippedGaps.length} skipped \u2014 see \`${skippedPath}\` for fields requiring manual input.`
@@ -24408,13 +24408,13 @@ async function scaffoldFill(opts) {
24408
24408
  )
24409
24409
  );
24410
24410
  }
24411
- var import_node_path15, os2, import_node_fs13, import_node_child_process5;
24411
+ var import_node_path15, os2, import_node_fs14, import_node_child_process5;
24412
24412
  var init_scaffold_fill = __esm({
24413
24413
  "src/cli/commands/om/scaffold-fill.ts"() {
24414
24414
  "use strict";
24415
24415
  import_node_path15 = require("node:path");
24416
24416
  os2 = __toESM(require("node:os"), 1);
24417
- import_node_fs13 = require("node:fs");
24417
+ import_node_fs14 = require("node:fs");
24418
24418
  import_node_child_process5 = require("node:child_process");
24419
24419
  init_source();
24420
24420
  init_config();
@@ -41177,17 +41177,38 @@ var GoogleConfigSchema = external_exports.object({
41177
41177
  topP: external_exports.number().min(0).max(1).optional(),
41178
41178
  modelOptions: GoogleOptionsSchema.optional()
41179
41179
  });
41180
- var AnthropicOptionsSchema = external_exports.object({});
41181
- var AnthropicConfigSchema = external_exports.object({
41182
- model: external_exports.enum(["claude-sonnet-4-5"]),
41180
+ var AnthropicOptionsSchema = external_exports.object({}).strict();
41181
+ var AnthropicStandardConfigSchema = external_exports.object({
41182
+ model: external_exports.enum([
41183
+ "claude-sonnet-4-6",
41184
+ "claude-haiku-4-5-20251001",
41185
+ "claude-haiku-4-5",
41186
+ "claude-sonnet-4-5"
41187
+ ]),
41183
41188
  provider: external_exports.literal("anthropic"),
41184
41189
  apiKey: external_exports.string(),
41185
41190
  temperature: external_exports.number().min(0).max(1).optional(),
41186
- maxOutputTokens: external_exports.number().min(1e3).optional(),
41191
+ maxOutputTokens: external_exports.number().min(1e3).max(64e3).optional(),
41187
41192
  // Anthropic requires max_tokens
41188
41193
  topP: external_exports.number().min(0).max(1).optional(),
41189
41194
  modelOptions: AnthropicOptionsSchema.optional()
41190
41195
  });
41196
+ var AnthropicOpus48ConfigSchema = external_exports.object({
41197
+ model: external_exports.literal("claude-opus-4-8"),
41198
+ provider: external_exports.literal("anthropic"),
41199
+ apiKey: external_exports.string(),
41200
+ temperature: external_exports.literal(1).optional(),
41201
+ maxOutputTokens: external_exports.number().min(1e3).max(128e3).optional(),
41202
+ // Anthropic requires max_tokens
41203
+ topP: external_exports.literal(1).optional(),
41204
+ topK: external_exports.undefined().optional(),
41205
+ top_k: external_exports.undefined().optional(),
41206
+ modelOptions: AnthropicOptionsSchema.optional()
41207
+ });
41208
+ var AnthropicConfigSchema = external_exports.discriminatedUnion("model", [
41209
+ AnthropicOpus48ConfigSchema,
41210
+ AnthropicStandardConfigSchema
41211
+ ]);
41191
41212
  var MODEL_INFO = {
41192
41213
  // OpenAI GPT-5 (Reasoning Models)
41193
41214
  "gpt-5": {
@@ -41280,6 +41301,58 @@ var MODEL_INFO = {
41280
41301
  configSchema: GoogleConfigSchema
41281
41302
  },
41282
41303
  // Anthropic Claude Models (direct SDK access via @anthropic-ai/sdk)
41304
+ "claude-opus-4-8": {
41305
+ inputCostPer1M: 500,
41306
+ // $5.00 per 1M tokens
41307
+ outputCostPer1M: 2500,
41308
+ // $25.00 per 1M tokens
41309
+ minTokens: 4e3,
41310
+ recommendedTokens: 8e3,
41311
+ maxTokens: 1e6,
41312
+ // 1M context window
41313
+ maxOutputTokens: 128e3,
41314
+ category: "reasoning",
41315
+ configSchema: AnthropicConfigSchema
41316
+ },
41317
+ "claude-sonnet-4-6": {
41318
+ inputCostPer1M: 300,
41319
+ // $3.00 per 1M tokens
41320
+ outputCostPer1M: 1500,
41321
+ // $15.00 per 1M tokens
41322
+ minTokens: 4e3,
41323
+ recommendedTokens: 8e3,
41324
+ maxTokens: 1e6,
41325
+ // 1M context window
41326
+ maxOutputTokens: 64e3,
41327
+ category: "standard",
41328
+ configSchema: AnthropicConfigSchema
41329
+ },
41330
+ "claude-haiku-4-5-20251001": {
41331
+ inputCostPer1M: 100,
41332
+ // $1.00 per 1M tokens
41333
+ outputCostPer1M: 500,
41334
+ // $5.00 per 1M tokens
41335
+ minTokens: 4e3,
41336
+ recommendedTokens: 8e3,
41337
+ maxTokens: 2e5,
41338
+ // 200k context window
41339
+ maxOutputTokens: 64e3,
41340
+ category: "standard",
41341
+ configSchema: AnthropicConfigSchema
41342
+ },
41343
+ "claude-haiku-4-5": {
41344
+ inputCostPer1M: 100,
41345
+ // $1.00 per 1M tokens
41346
+ outputCostPer1M: 500,
41347
+ // $5.00 per 1M tokens
41348
+ minTokens: 4e3,
41349
+ recommendedTokens: 8e3,
41350
+ maxTokens: 2e5,
41351
+ // 200k context window
41352
+ maxOutputTokens: 64e3,
41353
+ category: "standard",
41354
+ configSchema: AnthropicConfigSchema
41355
+ },
41283
41356
  "claude-sonnet-4-5": {
41284
41357
  inputCostPer1M: 300,
41285
41358
  // $3.00 per 1M tokens
@@ -41289,6 +41362,7 @@ var MODEL_INFO = {
41289
41362
  recommendedTokens: 8e3,
41290
41363
  maxTokens: 2e5,
41291
41364
  // 200k context window
41365
+ maxOutputTokens: 64e3,
41292
41366
  category: "standard",
41293
41367
  configSchema: AnthropicConfigSchema
41294
41368
  }
@@ -45731,7 +45805,7 @@ function wrapAction(commandName, fn) {
45731
45805
  // package.json
45732
45806
  var package_default = {
45733
45807
  name: "@elevasis/sdk",
45734
- version: "1.34.0",
45808
+ version: "1.34.1",
45735
45809
  description: "SDK for building Elevasis organization resources",
45736
45810
  type: "module",
45737
45811
  bin: {
@@ -45774,8 +45848,10 @@ var package_default = {
45774
45848
  build: `node -e "require('fs').rmSync('dist',{recursive:true,force:true})" && tsc -p tsconfig.core-dts.json && tsc -p tsconfig.build.json && tsup && rollup -c rollup.dts.config.mjs && esbuild src/cli/index.ts --bundle --platform=node --outfile=dist/cli.cjs --format=cjs --external:esbuild --banner:js="#!/usr/bin/env node" && node scripts/verify-skill-coverage.mjs && node scripts/copy-reference-docs.mjs && node ../../scripts/monorepo/generate-reference-artifacts.js`,
45775
45849
  "type-check": "tsc --noEmit",
45776
45850
  "check-types": "pnpm type-check",
45777
- test: "pnpm build && node ../../scripts/monorepo/validate-reference-artifacts.js && vitest run --config vitest.bundle.config.ts",
45778
- "test:bundle": "pnpm test"
45851
+ test: "pnpm test:bundle",
45852
+ "test:source": "vitest run --config vitest.config.ts",
45853
+ "test:dist": "pnpm build && node ../../scripts/monorepo/validate-reference-artifacts.js && vitest run --config vitest.bundle.config.ts",
45854
+ "test:bundle": "pnpm test:source && pnpm test:dist"
45779
45855
  },
45780
45856
  dependencies: {
45781
45857
  "@mdx-js/mdx": "^3.1.1",
@@ -45908,7 +45984,8 @@ function extractResourceMetadata(resource, schemaWarnings) {
45908
45984
  version: resource.config.version,
45909
45985
  status: resource.config.status,
45910
45986
  description: resource.config.description,
45911
- category: resource.config.category
45987
+ category: resource.config.category,
45988
+ sessionCapable: resource.config.sessionCapable
45912
45989
  };
45913
45990
  if (resource.contract.inputSchema) {
45914
45991
  try {
@@ -46708,6 +46785,9 @@ function registerExecCommand(program3) {
46708
46785
  // src/cli/commands/resources.ts
46709
46786
  init_source();
46710
46787
  init_config();
46788
+ function getResourceType(resource) {
46789
+ return resource.type ?? resource.resourceType;
46790
+ }
46711
46791
  function registerResourcesCommand(program3) {
46712
46792
  program3.command("resources").description("List deployed resources for your organization").option("--api-url <url>", "API URL").option("--json", "Output as JSON").action(wrapAction("resources", async (options) => {
46713
46793
  const apiUrl = resolveApiUrl(options.apiUrl);
@@ -46726,8 +46806,8 @@ function registerResourcesCommand(program3) {
46726
46806
  console.log(source_default.gray("Deploy with: elevasis-sdk deploy"));
46727
46807
  return;
46728
46808
  }
46729
- const workflows = data.resources.filter((r) => r.resourceType === "workflow");
46730
- const agents = data.resources.filter((r) => r.resourceType === "agent");
46809
+ const workflows = data.resources.filter((r) => getResourceType(r) === "workflow");
46810
+ const agents = data.resources.filter((r) => getResourceType(r) === "agent");
46731
46811
  if (workflows.length > 0) {
46732
46812
  console.log(source_default.yellow("Workflows:"));
46733
46813
  for (const w of workflows) {
@@ -46744,6 +46824,7 @@ function registerResourcesCommand(program3) {
46744
46824
  console.log(source_default.white(` ${source_default.bold(a.resourceId)}`));
46745
46825
  if (a.name) console.log(source_default.gray(` Name: ${a.name}`));
46746
46826
  if (a.description) console.log(source_default.gray(` Description: ${a.description}`));
46827
+ console.log(source_default.gray(` Session capable: ${a.sessionCapable ? "yes" : "no"}`));
46747
46828
  console.log(source_default.gray(` Status: ${a.status}`));
46748
46829
  console.log();
46749
46830
  }
@@ -49731,53 +49812,29 @@ init_config();
49731
49812
  // src/cli/commands/knowledge/load-org-model.ts
49732
49813
  var import_path3 = require("path");
49733
49814
  var import_fs3 = require("fs");
49734
- var import_module2 = require("module");
49735
49815
  var ORG_MODEL_REL_PATH = "core/config/organization-model.ts";
49736
- function getEsbuild2(startDir) {
49737
- const consumerRequire = (0, import_module2.createRequire)((0, import_path3.resolve)(startDir, "package.json"));
49738
- return consumerRequire("esbuild");
49739
- }
49740
49816
  async function loadOrgModel(projectRoot) {
49741
49817
  const orgModelPath = (0, import_path3.resolve)(projectRoot, ORG_MODEL_REL_PATH);
49742
49818
  if (!(0, import_fs3.existsSync)(orgModelPath)) {
49743
49819
  return DEFAULT_ORGANIZATION_MODEL;
49744
49820
  }
49745
- let pkgDir = projectRoot;
49746
- while (!(0, import_fs3.existsSync)((0, import_path3.resolve)(pkgDir, "package.json"))) {
49747
- const parent = (0, import_path3.resolve)(pkgDir, "..");
49748
- if (parent === pkgDir) break;
49749
- pkgDir = parent;
49750
- }
49751
- let esbuild;
49752
- try {
49753
- esbuild = getEsbuild2(pkgDir);
49754
- } catch {
49755
- return DEFAULT_ORGANIZATION_MODEL;
49756
- }
49757
- const tmpOut = (0, import_path3.resolve)(projectRoot, `.elevasis-knowledge-tmp-${Date.now()}.mjs`);
49758
49821
  try {
49759
- await esbuild.build({
49760
- entryPoints: [orgModelPath],
49761
- bundle: true,
49762
- platform: "node",
49763
- format: "esm",
49764
- outfile: tmpOut,
49765
- packages: "external",
49766
- logLevel: "silent"
49767
- });
49768
- const fileUrl = `file:///${tmpOut.replace(/\\/g, "/")}`;
49769
- const mod = await import(fileUrl);
49822
+ const mod = await loadTsModule(orgModelPath);
49770
49823
  const model = mod["organizationModel"] ?? mod["canonicalOrganizationModel"] ?? mod["default"];
49771
49824
  if (model && typeof model === "object" && "systems" in model) {
49772
49825
  return model;
49773
49826
  }
49774
- } catch {
49775
- } finally {
49776
- try {
49777
- const { unlinkSync: unlinkSync3 } = await import("fs");
49778
- unlinkSync3(tmpOut);
49779
- } catch {
49780
- }
49827
+ process.stderr.write(
49828
+ `[elevasis-sdk] loaded ${ORG_MODEL_REL_PATH} but found no organizationModel export; using empty default.
49829
+ `
49830
+ );
49831
+ } catch (error46) {
49832
+ const message = error46 instanceof Error ? error46.message : String(error46);
49833
+ process.stderr.write(
49834
+ `[elevasis-sdk] failed to load ${ORG_MODEL_REL_PATH}: ${message}
49835
+ Falling back to empty default model.
49836
+ `
49837
+ );
49781
49838
  }
49782
49839
  return DEFAULT_ORGANIZATION_MODEL;
49783
49840
  }
@@ -50084,6 +50141,9 @@ function parseScalar(value) {
50084
50141
  const quoted = trimmed.match(/^['"]([\s\S]*)['"]$/);
50085
50142
  return quoted ? quoted[1] : trimmed;
50086
50143
  }
50144
+ function normalizeLineEndings(value) {
50145
+ return value.replace(/\r\n/g, "\n");
50146
+ }
50087
50147
  function parseFrontmatter(raw, filePath) {
50088
50148
  const match = raw.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
50089
50149
  if (!match) throw new Error(`[knowledge-node-codegen] Missing frontmatter in ${filePath}`);
@@ -50107,7 +50167,7 @@ function parseFrontmatter(raw, filePath) {
50107
50167
  }
50108
50168
  frontmatter[key] = values;
50109
50169
  }
50110
- return { frontmatter, body: match[2].trim() };
50170
+ return { frontmatter, body: normalizeLineEndings(match[2]).trim() };
50111
50171
  }
50112
50172
  function assertString(frontmatter, key, filePath) {
50113
50173
  const value = frontmatter[key];
@@ -51837,6 +51897,9 @@ function registerNoteCommands(program3) {
51837
51897
  // src/cli/commands/agent/agent.ts
51838
51898
  init_source();
51839
51899
  init_config();
51900
+ function getResourceType2(resource) {
51901
+ return resource.type ?? resource.resourceType;
51902
+ }
51840
51903
  function printJson6(value) {
51841
51904
  console.log(JSON.stringify(value, null, 2));
51842
51905
  }
@@ -51845,7 +51908,7 @@ function registerAgentList(program3) {
51845
51908
  wrapAction("agent:list", async (options) => {
51846
51909
  const apiUrl = resolveApiUrl(options.apiUrl);
51847
51910
  const result = await apiGet("/api/external/resources", apiUrl);
51848
- const agents = result.resources.filter((resource) => resource.resourceType === "agent");
51911
+ const agents = result.resources.filter((resource) => getResourceType2(resource) === "agent");
51849
51912
  if (options.json) {
51850
51913
  printJson6({ agents, total: agents.length });
51851
51914
  return;
@@ -51898,6 +51961,7 @@ function registerAgentCommands(program3) {
51898
51961
  }
51899
51962
 
51900
51963
  // src/cli/commands/session/session.ts
51964
+ var import_node_fs10 = require("node:fs");
51901
51965
  init_source();
51902
51966
  init_config();
51903
51967
  function printJson7(value) {
@@ -51911,8 +51975,108 @@ function endpointWithQuery6(endpoint, params) {
51911
51975
  const query = params.toString();
51912
51976
  return query ? `${endpoint}?${query}` : endpoint;
51913
51977
  }
51978
+ function parseJson(value, label) {
51979
+ try {
51980
+ return JSON.parse(value);
51981
+ } catch (error46) {
51982
+ const message = error46 instanceof Error ? error46.message : String(error46);
51983
+ throw new Error(`Invalid JSON for ${label}: ${message}`);
51984
+ }
51985
+ }
51986
+ function readJsonFile(path3, label) {
51987
+ const resolved = resolveProjectRelative(path3);
51988
+ return parseJson((0, import_node_fs10.readFileSync)(resolved, "utf8"), label);
51989
+ }
51990
+ function resolveTurnInput(options) {
51991
+ if (options.input && options.inputFile) {
51992
+ throw new Error("Use either --input or --input-file, not both.");
51993
+ }
51994
+ if (options.inputFile) {
51995
+ return readJsonFile(options.inputFile, "--input-file");
51996
+ }
51997
+ if (options.input) {
51998
+ return parseJson(options.input, "--input");
51999
+ }
52000
+ throw new Error("Provide turn input with --input <json> or --input-file <path>.");
52001
+ }
52002
+ function messagesEndpoint(sessionId, limit, cursor) {
52003
+ const params = new URLSearchParams();
52004
+ appendQuery6(params, "limit", limit);
52005
+ appendQuery6(params, "cursor", cursor);
52006
+ return endpointWithQuery6(`/api/external/sessions/${sessionId}/messages`, params);
52007
+ }
52008
+ async function fetchSessionMessages(sessionId, apiUrl, options) {
52009
+ const fetchAll = options.all === true || options.page !== true;
52010
+ let cursor = options.cursor;
52011
+ let firstCursor;
52012
+ let lastPage;
52013
+ let pagesFetched = 0;
52014
+ const messages = [];
52015
+ while (true) {
52016
+ const page = await apiGet(messagesEndpoint(sessionId, options.limit, cursor), apiUrl);
52017
+ pagesFetched += 1;
52018
+ if (!fetchAll) {
52019
+ return { ...page, pagesFetched };
52020
+ }
52021
+ if (pagesFetched === 1) {
52022
+ firstCursor = page.cursor;
52023
+ }
52024
+ messages.push(...page.messages);
52025
+ lastPage = page;
52026
+ if (!page.hasMore) {
52027
+ return {
52028
+ sessionId: page.sessionId,
52029
+ messages,
52030
+ limit: page.limit,
52031
+ cursor: firstCursor,
52032
+ nextCursor: void 0,
52033
+ total: page.total ?? messages.length,
52034
+ hasMore: false,
52035
+ pagesFetched
52036
+ };
52037
+ }
52038
+ if (page.nextCursor === void 0 || page.nextCursor === null) {
52039
+ throw new Error("Messages response had hasMore=true but no nextCursor.");
52040
+ }
52041
+ cursor = String(page.nextCursor);
52042
+ }
52043
+ }
52044
+ function messageText(message) {
52045
+ const value = message.text ?? message.content;
52046
+ if (value !== void 0) return String(value);
52047
+ return JSON.stringify(message, null, 2);
52048
+ }
52049
+ function printMessage(message) {
52050
+ const index = message.messageIndex === void 0 ? "" : `#${message.messageIndex}`;
52051
+ const role = message.role ?? message.messageType ?? "message";
52052
+ const turn = message.turnNumber === void 0 ? "" : ` turn ${message.turnNumber}`;
52053
+ const heading = [index, role + turn].filter(Boolean).join(" ");
52054
+ console.log(source_default.white(` ${heading}`));
52055
+ for (const line of messageText(message).split(/\r?\n/)) {
52056
+ console.log(source_default.gray(` ${line}`));
52057
+ }
52058
+ }
52059
+ function registerSessionCreate(program3) {
52060
+ program3.command("session:create <resourceId>").description("Create a multi-turn agent session").option("--user-id <id>", "User ID for the session").option("--metadata <json>", "Session metadata as JSON").option("--api-url <url>", "API base URL").option("--json", "Output as JSON").action(
52061
+ wrapAction("session:create", async (resourceId, options) => {
52062
+ const apiUrl = resolveApiUrl(options.apiUrl);
52063
+ const body = { resourceId };
52064
+ if (options.userId) body.userId = options.userId;
52065
+ if (options.metadata) body.metadata = parseJson(options.metadata, "--metadata");
52066
+ const session = await apiPost("/api/external/sessions", body, apiUrl);
52067
+ if (options.json) {
52068
+ printJson7(session);
52069
+ return;
52070
+ }
52071
+ console.log(source_default.green(`Created session ${session.sessionId}.`));
52072
+ console.log(source_default.gray(` Agent: ${session.resourceId}`));
52073
+ console.log(source_default.gray(` Turns: ${session.turnCount}`));
52074
+ console.log(source_default.gray(` Created: ${new Date(session.createdAt).toLocaleString()}`));
52075
+ })
52076
+ );
52077
+ }
51914
52078
  function registerSessionList(program3) {
51915
- program3.command("session:list").description("List active multi-turn agent sessions").option("--resource-id <id>", "Filter by agent resource ID").option("--user-id <id>", "Filter by user ID").option("--limit <limit>", "Maximum number of sessions to return").option("--api-url <url>", "API base URL").option("--json", "Output as JSON").action(
52079
+ program3.command("session:list").description("List multi-turn agent sessions").option("--resource-id <id>", "Filter by agent resource ID").option("--user-id <id>", "Filter by user ID").option("--limit <limit>", "Maximum number of sessions to return").option("--api-url <url>", "API base URL").option("--json", "Output as JSON").action(
51916
52080
  wrapAction("session:list", async (options) => {
51917
52081
  const apiUrl = resolveApiUrl(options.apiUrl);
51918
52082
  const params = new URLSearchParams();
@@ -51924,16 +52088,16 @@ function registerSessionList(program3) {
51924
52088
  printJson7(result);
51925
52089
  return;
51926
52090
  }
51927
- const activeSessions = result.sessions.filter((session) => !session.isEnded);
51928
- if (activeSessions.length === 0) {
51929
- console.log(source_default.yellow("No active sessions found."));
52091
+ if (result.sessions.length === 0) {
52092
+ console.log(source_default.yellow("No sessions found."));
51930
52093
  return;
51931
52094
  }
51932
- console.log(source_default.cyan(`Sessions (${activeSessions.length} active of ${result.total}):`));
51933
- for (const session of activeSessions) {
52095
+ console.log(source_default.cyan(`Sessions (${result.sessions.length} of ${result.total}):`));
52096
+ for (const session of result.sessions) {
51934
52097
  console.log(source_default.white(` ${source_default.bold(session.sessionId)}`));
51935
52098
  if (session.title) console.log(source_default.gray(` Title: ${session.title}`));
51936
52099
  console.log(source_default.gray(` Agent: ${session.resourceId}`));
52100
+ console.log(source_default.gray(` Status: ${session.isEnded ? "ended" : "active"}`));
51937
52101
  console.log(source_default.gray(` Turns: ${session.turnCount}`));
51938
52102
  console.log(source_default.gray(` Updated: ${new Date(session.updatedAt).toLocaleString()}`));
51939
52103
  console.log();
@@ -51942,7 +52106,7 @@ function registerSessionList(program3) {
51942
52106
  );
51943
52107
  }
51944
52108
  function registerSessionGet(program3) {
51945
- program3.command("session:get <id>").description("Get session details and transcript").option("--api-url <url>", "API base URL").option("--json", "Output as JSON").action(
52109
+ program3.command("session:get <id>").description("Get session details").option("--api-url <url>", "API base URL").option("--json", "Output as JSON").action(
51946
52110
  wrapAction("session:get", async (id, options) => {
51947
52111
  const apiUrl = resolveApiUrl(options.apiUrl);
51948
52112
  const session = await apiGet(`/api/external/sessions/${id}`, apiUrl);
@@ -51962,11 +52126,57 @@ function registerSessionGet(program3) {
51962
52126
  })
51963
52127
  );
51964
52128
  }
52129
+ function registerSessionTurn(program3) {
52130
+ program3.command("session:turn <id>").description("Execute a turn in an active agent session").option("-i, --input <json>", "Turn input as JSON").option("-f, --input-file <path>", "Read turn input from a JSON file").option("--api-url <url>", "API base URL").option("--json", "Output as JSON").action(
52131
+ wrapAction("session:turn", async (id, options) => {
52132
+ const apiUrl = resolveApiUrl(options.apiUrl);
52133
+ const input = resolveTurnInput(options);
52134
+ const result = await apiPost(`/api/external/sessions/${id}/turns`, { input }, apiUrl);
52135
+ if (options.json) {
52136
+ printJson7(result);
52137
+ return;
52138
+ }
52139
+ console.log(source_default.green(`Turn ${result.turnNumber} complete.`));
52140
+ console.log(source_default.gray(` Session ID: ${result.sessionId}`));
52141
+ console.log(source_default.gray(` Execution ID: ${result.executionId}`));
52142
+ if (result.duration !== void 0) console.log(source_default.gray(` Duration: ${result.duration}ms`));
52143
+ console.log();
52144
+ console.log(source_default.green("Output:"));
52145
+ console.log(JSON.stringify(result.output, null, 2));
52146
+ })
52147
+ );
52148
+ }
52149
+ function registerSessionMessages(program3) {
52150
+ program3.command("session:messages <id>").description("Export session transcript messages").option("--limit <limit>", "Messages per API page").option("--cursor <cursor>", "Message_index cursor to start after").option("--page", "Fetch one API page instead of the full transcript").option("--all", "Fetch all pages (default)").option("--api-url <url>", "API base URL").option("--json", "Output as JSON").action(
52151
+ wrapAction("session:messages", async (id, options) => {
52152
+ const apiUrl = resolveApiUrl(options.apiUrl);
52153
+ const result = await fetchSessionMessages(id, apiUrl, options);
52154
+ if (options.json) {
52155
+ printJson7(result);
52156
+ return;
52157
+ }
52158
+ const total = result.total === void 0 ? result.messages.length : result.total;
52159
+ console.log(source_default.cyan(`Messages (${result.messages.length} of ${total}, ${result.pagesFetched} page(s)):`));
52160
+ if (result.messages.length === 0) {
52161
+ console.log(source_default.yellow("No messages found."));
52162
+ return;
52163
+ }
52164
+ for (const message of result.messages) {
52165
+ printMessage(message);
52166
+ console.log();
52167
+ }
52168
+ })
52169
+ );
52170
+ }
51965
52171
  function registerSessionEnd(program3) {
51966
- program3.command("session:end <id>").description("Terminate an active agent session").option("--api-url <url>", "API base URL").option("--json", "Output as JSON").action(
52172
+ program3.command("session:end <id>").description("End an active agent session").option("--api-url <url>", "API base URL").option("--json", "Output as JSON").action(
51967
52173
  wrapAction("session:end", async (id, options) => {
51968
52174
  const apiUrl = resolveApiUrl(options.apiUrl);
51969
- const result = await apiDelete(`/api/external/sessions/${id}`, apiUrl);
52175
+ const result = await apiPost(
52176
+ `/api/external/sessions/${id}/end`,
52177
+ {},
52178
+ apiUrl
52179
+ );
51970
52180
  if (options.json) {
51971
52181
  printJson7(result);
51972
52182
  return;
@@ -51978,8 +52188,11 @@ function registerSessionEnd(program3) {
51978
52188
 
51979
52189
  // src/cli/commands/session/index.ts
51980
52190
  function registerSessionCommands(program3) {
52191
+ registerSessionCreate(program3);
51981
52192
  registerSessionList(program3);
51982
52193
  registerSessionGet(program3);
52194
+ registerSessionTurn(program3);
52195
+ registerSessionMessages(program3);
51983
52196
  registerSessionEnd(program3);
51984
52197
  }
51985
52198
 
@@ -52091,7 +52304,7 @@ function registerSkillScaffoldCommand(program3) {
52091
52304
  }
52092
52305
 
52093
52306
  // src/cli/json-file-argv.ts
52094
- var import_node_fs14 = require("node:fs");
52307
+ var import_node_fs15 = require("node:fs");
52095
52308
  var import_node_path16 = require("node:path");
52096
52309
  init_config();
52097
52310
  var JSON_FILE_PREFIX = "@json:";
@@ -52114,7 +52327,7 @@ function resolveJsonFilePath(path3, options) {
52114
52327
  function readJsonFileReference(ref, options) {
52115
52328
  const relativeOrAbsolutePath = ref.slice(JSON_FILE_PREFIX.length);
52116
52329
  const resolvedPath = resolveJsonFilePath(relativeOrAbsolutePath, options);
52117
- const raw = (options.readFile ?? ((path3) => (0, import_node_fs14.readFileSync)(path3, "utf8")))(resolvedPath);
52330
+ const raw = (options.readFile ?? ((path3) => (0, import_node_fs15.readFileSync)(path3, "utf8")))(resolvedPath);
52118
52331
  try {
52119
52332
  JSON.parse(raw);
52120
52333
  } catch {
@@ -52221,9 +52434,12 @@ Commands:
52221
52434
  elevasis-sdk schedule:create --name <name> ... Create a task schedule
52222
52435
  elevasis-sdk agent:list List deployed agents
52223
52436
  elevasis-sdk agent:get <id> Get agent metadata and OM linkage
52224
- elevasis-sdk session:list List active agent sessions
52225
- elevasis-sdk session:get <id> Get session details and transcript
52226
- elevasis-sdk session:end <id> Terminate an active agent session
52437
+ elevasis-sdk session:create <resourceId> Create an agent session
52438
+ elevasis-sdk session:turn <id> -f tmp/turn.json Execute a session turn
52439
+ elevasis-sdk session:messages <id> Export session transcript messages
52440
+ elevasis-sdk session:list List agent sessions
52441
+ elevasis-sdk session:get <id> Get session details
52442
+ elevasis-sdk session:end <id> End an active agent session
52227
52443
  elevasis-sdk acquisition:list:list List acquisition lists
52228
52444
  elevasis-sdk acquisition:deal:list List acquisition deals
52229
52445
  elevasis-sdk knowledge:generate Generate knowledge nodes from MDX files