@seclai/sdk 1.1.5 → 1.2.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/README.md CHANGED
@@ -104,7 +104,7 @@ or set environment variables:
104
104
 
105
105
  Online API documentation (latest):
106
106
 
107
- https://seclai.github.io/seclai-javascript/1.1.5/
107
+ https://seclai.github.io/seclai-javascript/1.2.0/
108
108
 
109
109
  ## Resources
110
110
 
@@ -121,6 +121,25 @@ await client.deleteAgent("agent_id");
121
121
  // Definition (step workflow)
122
122
  const def = await client.getAgentDefinition("agent_id");
123
123
  await client.updateAgentDefinition("agent_id", { steps: [...], change_id: def.change_id });
124
+
125
+ // Export / import an agent
126
+ const exported = await client.exportAgent("agent_id");
127
+
128
+ // Validate the payload first to surface unresolved entity refs in this account
129
+ const preview = await client.previewImportAgent({ agent_definition: exported });
130
+ const unresolved = (preview.unresolved_refs ?? []) as Array<{ ref_id: string }>;
131
+ const entity_remap = Object.fromEntries(
132
+ unresolved.map((ref) => [ref.ref_id, /* picked target uuid */ ""]),
133
+ );
134
+
135
+ // Commit — `entity_remap` substitutes workflow refs before save
136
+ const imported = await client.createAgent({
137
+ name: "Imported",
138
+ trigger_type: "dynamic_input",
139
+ agent_definition: exported,
140
+ entity_remap,
141
+ });
142
+ // `imported.import_warnings` lists any items that couldn't be applied.
124
143
  ```
125
144
 
126
145
  ### Agent runs
package/dist/index.cjs CHANGED
@@ -797,7 +797,7 @@ var Seclai = class {
797
797
  await this.request("DELETE", `/agents/${agentId}`);
798
798
  }
799
799
  // ═══════════════════════════════════════════════════════════════════════════
800
- // Agent Export
800
+ // Agent Export / Import
801
801
  // ═══════════════════════════════════════════════════════════════════════════
802
802
  /**
803
803
  * Export an agent definition as a portable JSON snapshot.
@@ -811,6 +811,27 @@ var Seclai = class {
811
811
  query: { download }
812
812
  });
813
813
  }
814
+ /**
815
+ * Validate an `agent_definition` payload (same shape as {@link exportAgent})
816
+ * without creating or modifying any agent.
817
+ *
818
+ * Use this before {@link createAgent} or {@link updateAgent} with an
819
+ * `agent_definition` to surface `unresolved_refs` — workflow references to
820
+ * knowledge bases, memory banks, source connections, or sub-agents that
821
+ * don't exist in the target account. Pass the returned ids back in
822
+ * `entity_remap` on the commit call to substitute them.
823
+ *
824
+ * @param body - The preview payload (`{ agent_definition: ... }`).
825
+ * @returns Summary of the validated payload (step counts, schedules,
826
+ * alert configs, evaluation criteria, governance policies, and any
827
+ * `unresolved_refs`).
828
+ * @throws {SeclaiAPIValidationError} On HTTP 422 — the body is an
829
+ * {@link AgentDefinitionImportErrorResponse} with 1-indexed
830
+ * line/column-anchored errors against a canonical `source` echo.
831
+ */
832
+ async previewImportAgent(body) {
833
+ return await this.request("POST", "/agents/preview-import", { json: body });
834
+ }
814
835
  // ═══════════════════════════════════════════════════════════════════════════
815
836
  // Agent Definitions
816
837
  // ═══════════════════════════════════════════════════════════════════════════