heyio 0.1.32 → 0.1.33

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.
@@ -6,13 +6,14 @@ import { homedir } from "os";
6
6
  import { defineTool, approveAll } from "@github/copilot-sdk";
7
7
  import { z } from "zod";
8
8
  import { getClient } from "./client.js";
9
- import { getModelForTask, getModelForTier } from "./model-router.js";
9
+ import { getModelForTask, getModelForTier, classifyComplexity } from "./model-router.js";
10
10
  import { getSquad, updateSquadSession, updateSquadStatus, getDecisionsSummary, logDecision, listSquadAgents, getSquadAgent, updateAgentSession, updateAgentStatus, } from "../store/squads.js";
11
11
  import { createTask, completeTask, failTask, getActiveTasks, } from "../store/tasks.js";
12
12
  import { SESSIONS_DIR } from "../paths.js";
13
13
  import { getUniverse } from "./universes.js";
14
14
  // Key format: "squadSlug:characterName" for per-agent sessions, "squadSlug" for legacy
15
15
  const agentSessions = new Map();
16
+ const agentSessionModels = new Map();
16
17
  function agentSessionKey(squadSlug, characterName) {
17
18
  return characterName ? `${squadSlug}:${characterName}` : squadSlug;
18
19
  }
@@ -121,6 +122,7 @@ export async function shutdownAgents() {
121
122
  // best-effort cleanup
122
123
  }
123
124
  agentSessions.delete(key);
125
+ agentSessionModels.delete(key);
124
126
  }
125
127
  }
126
128
  export function getActiveAgentTasks() {
@@ -136,18 +138,38 @@ export function getActiveAgentTasks() {
136
138
  // ---------------------------------------------------------------------------
137
139
  /**
138
140
  * Create or resume a Copilot session for a specific named agent.
139
- * The system message includes the agent's character personality, role, and charter.
141
+ * Model is selected per-task: uses the higher of the agent's default tier
142
+ * and the task's classified complexity. This means an agent never gets a
143
+ * model worse than their baseline, but can be upgraded for complex tasks.
140
144
  */
141
145
  async function getOrCreateAgentSession(squadSlug, agent, taskDescription) {
142
146
  const key = agentSessionKey(squadSlug, agent.character_name);
147
+ // Determine model based on task complexity vs agent's default tier
148
+ const agentTier = agent.model_tier;
149
+ const taskTier = taskDescription ? classifyComplexity(taskDescription) : agentTier;
150
+ const tierRank = { high: 3, medium: 2, low: 1 };
151
+ const effectiveTier = tierRank[taskTier] >= tierRank[agentTier] ? taskTier : agentTier;
152
+ const model = getModelForTier(effectiveTier);
153
+ // If we have a cached session, check if the model matches; if not, destroy and recreate
143
154
  const existing = agentSessions.get(key);
144
- if (existing)
145
- return existing;
155
+ if (existing) {
156
+ // Sessions don't expose their model, so track it separately
157
+ const cachedModel = agentSessionModels.get(key);
158
+ if (cachedModel === model)
159
+ return existing;
160
+ // Model changed — destroy old session for the upgraded model
161
+ console.error(`[io] Agent ${agent.character_name}: upgrading model ${cachedModel} → ${model} for task complexity`);
162
+ try {
163
+ await existing.destroy();
164
+ }
165
+ catch { /* best-effort */ }
166
+ agentSessions.delete(key);
167
+ agentSessionModels.delete(key);
168
+ }
146
169
  const squad = getSquad(squadSlug);
147
170
  const client = await getClient();
148
171
  const decisions = getDecisionsSummary(squadSlug);
149
- // Resolve model from agent's tier preference
150
- const model = getModelForTier(agent.model_tier);
172
+ console.error(`[io] Agent ${agent.character_name}: using model "${model}" (agent tier: ${agentTier}, task tier: ${taskTier}, effective: ${effectiveTier})`);
151
173
  const universeName = squad.universe
152
174
  ? getUniverse(squad.universe)?.name ?? squad.universe
153
175
  : "Unknown";
@@ -199,6 +221,7 @@ Stay in character — let your personality color your work style and communicati
199
221
  }
200
222
  updateAgentSession(squadSlug, agent.character_name, session.sessionId);
201
223
  agentSessions.set(key, session);
224
+ agentSessionModels.set(key, model);
202
225
  return session;
203
226
  }
204
227
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heyio",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "description": "IO — a personal AI assistant built on the GitHub Copilot SDK",
5
5
  "bin": {
6
6
  "io": "dist/index.js"