@atlasharness/atlascode 0.1.69 → 0.1.70

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.
Files changed (2) hide show
  1. package/dist/cli.js +78 -12
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -19926,10 +19926,7 @@ function getRoleConfig(role) {
19926
19926
  const provider = normalizeProvider(envProvider) ?? normalizeProvider(roleSetting.provider) ?? "openai";
19927
19927
  const model = envModel ?? roleSetting.model;
19928
19928
  const baseURL = envBaseUrl ?? roleSetting.baseURL;
19929
- let apiKey = envApiKey ?? roleSetting.apiKey;
19930
- if (apiKey === undefined) {
19931
- apiKey = getEndpointConfigSource().getGlobalApiKey();
19932
- }
19929
+ const apiKey = envApiKey ?? roleSetting.apiKey;
19933
19930
  return { provider, model, baseURL, apiKey };
19934
19931
  }
19935
19932
  function getRoleModel(role) {
@@ -27063,6 +27060,9 @@ class OpenAIProvider {
27063
27060
  return this.timeoutResolver ? this.timeoutResolver() : this.timeoutMs;
27064
27061
  }
27065
27062
  async chat(args) {
27063
+ if (args.onStreamDelta) {
27064
+ return await this.chatWithDelta(args);
27065
+ }
27066
27066
  const refs = getRoleModels(args.role, args.sessionModel, args.fallbackModel);
27067
27067
  if (refs.length === 0) {
27068
27068
  throw new Error(`No models configured for role '${args.role}' (empty pool). ` + `Add modelRoles/providers to ~/.atlas/settings.json, or set ATLAS_${args.role.toUpperCase()}_MODEL, then restart.`);
@@ -27160,6 +27160,66 @@ class OpenAIProvider {
27160
27160
  throw lastErr;
27161
27161
  throw new Error(`No models configured for role '${args.role}'.`);
27162
27162
  }
27163
+ async chatWithDelta(args) {
27164
+ const refs = getRoleModels(args.role, args.sessionModel, args.fallbackModel);
27165
+ if (refs.length === 0) {
27166
+ throw new Error(`No models configured for role '${args.role}' (empty pool). ` + `Add modelRoles/providers to ~/.atlas/settings.json, or set ATLAS_${args.role.toUpperCase()}_MODEL, then restart.`);
27167
+ }
27168
+ const attemptRefs = refs;
27169
+ let lastErr = null;
27170
+ const onDelta = args.onStreamDelta;
27171
+ for (const ref of attemptRefs) {
27172
+ const entry = resolveModel(ref);
27173
+ if (!entry) {
27174
+ lastErr = new Error(`unknown provider/model reference: ${ref}`);
27175
+ continue;
27176
+ }
27177
+ const client = getClientForEntry(entry);
27178
+ let params;
27179
+ if (args.openaiParams) {
27180
+ params = { ...args.openaiParams, model: entry.modelId, stream: true };
27181
+ } else {
27182
+ params = {
27183
+ ...await buildOpenAIParams({
27184
+ messages: args.messages ?? [],
27185
+ systemPrompt: args.systemPrompt ?? asSystemPrompt([]),
27186
+ tools: args.tools,
27187
+ thinkingConfig: args.thinkingConfig,
27188
+ options: args.options
27189
+ }, args.role, entry),
27190
+ ...args.responseFormat ? { response_format: args.responseFormat } : {},
27191
+ stream: true
27192
+ };
27193
+ }
27194
+ for (let attempt = 0;attempt < this.maxRetriesPerModel; attempt++) {
27195
+ if (args.signal?.aborted)
27196
+ throw args.signal.reason ?? new Error("aborted");
27197
+ let assistant = null;
27198
+ try {
27199
+ for await (const ev of this.streamOneAttempt(client, params, entry, args.signal, attempt, this.maxRetriesPerModel)) {
27200
+ const t = ev.type;
27201
+ if (t === "text_delta" || t === "tool_use_start" || t === "tool_use_delta" || t === "tool_use_end") {
27202
+ onDelta(ev);
27203
+ } else if (t === "assistant") {
27204
+ assistant = ev;
27205
+ }
27206
+ }
27207
+ if (assistant)
27208
+ return assistant;
27209
+ } catch (err) {
27210
+ lastErr = err;
27211
+ if (!shouldRetryModelError(err, args.signal))
27212
+ break;
27213
+ if (attempt < this.maxRetriesPerModel - 1) {
27214
+ await this.retryBackoffSleep(modelRetryBackoffMs(attempt, this.retryBackoffBaseMs, this.retryBackoffCapMs), args.signal);
27215
+ }
27216
+ }
27217
+ }
27218
+ }
27219
+ if (lastErr)
27220
+ throw lastErr;
27221
+ throw new Error(`No models configured for role '${args.role}'.`);
27222
+ }
27163
27223
  async* chatStream(args) {
27164
27224
  const refs = getRoleModels(args.role, args.sessionModel);
27165
27225
  if (refs.length === 0) {
@@ -82189,7 +82249,8 @@ async function queryOneRound(deps, tools, messages) {
82189
82249
  thinkingConfig: deps.thinkingConfig,
82190
82250
  responseFormat: deps.responseFormat,
82191
82251
  fallbackModel: deps.fallbackModel,
82192
- options: deps.effortValue !== undefined ? { effortValue: deps.effortValue } : undefined
82252
+ options: deps.effortValue !== undefined ? { effortValue: deps.effortValue } : undefined,
82253
+ onStreamDelta: deps.emit ? (delta) => deps.emit({ type: "stream_delta", delta }) : undefined
82193
82254
  };
82194
82255
  let resp = await withTurnRecovery(() => deps.modelProvider.chat(chatArgs), {
82195
82256
  signal: deps.signal
@@ -256558,6 +256619,8 @@ async function* queryEngineLoopStream(params) {
256558
256619
  pending.push(event.assistantMessage, ...event.toolResultMessages);
256559
256620
  } else if (event.type === "compacted") {
256560
256621
  pending.push(event.messages[0]);
256622
+ } else if (event.type === "stream_delta") {
256623
+ pending.push(event);
256561
256624
  }
256562
256625
  notify();
256563
256626
  }
@@ -336911,7 +336974,7 @@ function getContentText(content) {
336911
336974
  return null;
336912
336975
  }
336913
336976
  function handleMessageFromStream(message, onMessage, onUpdateLength, onSetStreamMode, onStreamingToolUses, onTombstone, onStreamingThinking, onApiMetrics, onStreamingText) {
336914
- if (message.type !== "stream_event" && message.type !== "stream_request_start") {
336977
+ if (message.type !== "stream_event" && message.type !== "stream_request_start" && message.type !== "stream_delta") {
336915
336978
  if (message.type === "tombstone") {
336916
336979
  onTombstone?.(message.message);
336917
336980
  return;
@@ -336937,6 +337000,14 @@ function handleMessageFromStream(message, onMessage, onUpdateLength, onSetStream
336937
337000
  onSetStreamMode("requesting");
336938
337001
  return;
336939
337002
  }
337003
+ if (message.type === "stream_delta") {
337004
+ if (message.delta.type === "text_delta") {
337005
+ onSetStreamMode("responding");
337006
+ onUpdateLength(message.delta.text);
337007
+ onStreamingText?.((text) => (text ?? "") + message.delta.text);
337008
+ }
337009
+ return;
337010
+ }
336940
337011
  if (message.event.type === "message_start") {
336941
337012
  if (message.ttftMs != null) {
336942
337013
  onApiMetrics?.({ ttftMs: message.ttftMs });
@@ -433347,17 +433418,12 @@ function createSettingsAdapter() {
433347
433418
  return settings.providers || {};
433348
433419
  },
433349
433420
  getGlobalApiKey() {
433350
- try {
433351
- return getApiKeyFromConfigOrMacOSKeychain()?.key;
433352
- } catch {
433353
- return;
433354
- }
433421
+ return;
433355
433422
  }
433356
433423
  };
433357
433424
  }
433358
433425
  var init_settings_adapter = __esm(() => {
433359
433426
  init_settings3();
433360
- init_auth4();
433361
433427
  });
433362
433428
 
433363
433429
  // src/tui/factory.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlasharness/atlascode",
3
- "version": "0.1.69",
3
+ "version": "0.1.70",
4
4
  "description": "AtlasCode \u2014 Coding Agent for the domestic computing ecosystem (Ascend NPU + domestic LLM backends)",
5
5
  "bin": {
6
6
  "atlas": "dist/cli.js",