@commonlyai/cli 0.1.165 → 0.1.166

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonlyai/cli",
3
- "version": "0.1.165",
3
+ "version": "0.1.166",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -667,12 +667,29 @@ export const updateAgentConfiguration = async ({
667
667
  model = null,
668
668
  effort = null,
669
669
  envPath = null,
670
+ runtimeKey = false,
670
671
  parseEnv = parseEnvironmentFile,
671
672
  adapterRegistry = { getAdapter, listAdapterNames },
672
673
  }) => {
673
674
  if (!record?.agentName) {
674
675
  throw new Error('token record is missing agentName — re-attach the agent');
675
676
  }
677
+ if (runtimeKey) {
678
+ if (adapter || envPath) throw new Error('--adapter and --env require an owner login; run commonly login');
679
+ const controls = Object.fromEntries(Object.entries({ model, effort })
680
+ .filter(([, value]) => value !== null && value !== undefined));
681
+ if (!Object.keys(controls).length) throw new Error('provide --model or --effort');
682
+ const environment = { ...record.environment, ...controls };
683
+ const validation = validateEnvironmentSpec(environment);
684
+ if (!validation.ok) throw new Error(validation.errors.join('; '));
685
+ const result = await client.patch('/api/agents/runtime/configuration', {
686
+ agentName: record.agentName, instanceId: record.instanceId || 'default', ...controls,
687
+ });
688
+ return {
689
+ agentName: record.agentName, instanceId: record.instanceId || 'default', podId: result.podId,
690
+ changed: Object.keys(controls), environment,
691
+ };
692
+ }
676
693
  const instanceId = record.instanceId || 'default';
677
694
  const runtime = {};
678
695
  const environmentRuntime = {};
@@ -3774,13 +3791,21 @@ Use --local to find the name you'd pass to 'agent run' or 'agent detach'.
3774
3791
  process.exit(1);
3775
3792
  }
3776
3793
  const instance = opts.instance || record.instanceUrl;
3777
- const token = getToken(instance);
3794
+ const ownerToken = getToken(instance);
3795
+ const runtimeKey = !opts.adapter && !opts.env && !ownerToken && Boolean(record.runtimeToken);
3796
+ const token = runtimeKey ? record.runtimeToken : ownerToken;
3778
3797
  if (!token) { console.error('Not logged in. Run: commonly login'); process.exit(1); }
3779
- const client = createClient({ instance: resolveInstanceUrl(instance), token });
3780
3798
  try {
3799
+ const instanceUrl = resolveInstanceUrl(instance);
3800
+ if (runtimeKey && (!record.instanceUrl
3801
+ || new URL(instanceUrl).href.replace(/\/$/, '') !== new URL(record.instanceUrl).href.replace(/\/$/, ''))) {
3802
+ throw new Error('Changing --instance requires an owner login for that instance; run commonly login');
3803
+ }
3804
+ const client = createClient({ instance: instanceUrl, token });
3781
3805
  const result = await updateAgentConfiguration({
3782
3806
  client,
3783
3807
  record,
3808
+ runtimeKey,
3784
3809
  adapter: opts.adapter,
3785
3810
  model: opts.model,
3786
3811
  effort: opts.effort,