@atlaswork/atlascode 0.1.134 → 0.1.136

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
@@ -61,7 +61,10 @@ atlascode --help # 别名 `atlas` 同效
61
61
 
62
62
  - **三角色模型池**(`premium` / `fast` / `small`):`modelRoles.<role>` =
63
63
  `{ provider, model?, models?(池,水平回退序), baseURL?, apiKey? }`;
64
- `defaultRole` 选主循环默认角色(缺省 `small`)。
64
+ `defaultRole` 选主循环默认角色(合法值 `premium`/`fast`/`small`;未设或非法时
65
+ headless `-p` 车道缺省 `premium`,TUI 引导面缺省 `small`)。
66
+ `--model` 亦接受角色别名 `small`/`premium`/`fast`(等价该角色池;未知 ref
67
+ 启动即报错退出,0.1.135 起)。
65
68
  - **Provider 表**:`providers.<name>` =
66
69
  `{ baseURL, apiKey, api, models: [{ id, name?, contextWindow?, maxTokens? }],
67
70
  defaultContextWindow?, defaultMaxTokens? }`;模型引用 `"<provider>/<modelId>"`。
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "product": "atlascode",
3
- "version": "0.1.134",
3
+ "version": "0.1.136",
4
4
  "runtimeSha256": "9bbb766ae76e5a73f1155a83bd6eda493644fb228b9308e0f45938fb49f43451",
5
5
  "executionSha256": "b14e2ea5946c9e086d65d2debe0de98b0afec83228d887958bcb16a6e867710d"
6
6
  }
package/dist/cli.js CHANGED
@@ -27355,16 +27355,7 @@ function getRoleModels(role, sessionModel, fallbackModel) {
27355
27355
  const envModel = process.env["ATLAS_" + roleKey + "_MODEL"];
27356
27356
  const providers = getEndpointConfigSource().getProviders();
27357
27357
  const roleSetting = getEndpointConfigSource().getRoleSetting(role);
27358
- const normalizeRef = (ref) => {
27359
- if (ref.includes("/"))
27360
- return ref;
27361
- for (const [pName, pCfg] of Object.entries(providers)) {
27362
- const models = pCfg.models || [];
27363
- if (models.some((m) => m?.id === ref))
27364
- return pName + "/" + ref;
27365
- }
27366
- return ref;
27367
- };
27358
+ const normalizeRef = (ref) => normalizeModelRefWithProviders(ref, providers);
27368
27359
  const rolePool = (Array.isArray(roleSetting.models) ? roleSetting.models : []).map((m) => {
27369
27360
  if (typeof m === "string")
27370
27361
  return m;
@@ -27385,6 +27376,30 @@ function getRoleModels(role, sessionModel, fallbackModel) {
27385
27376
  }
27386
27377
  return refs;
27387
27378
  }
27379
+ function normalizeModelRefWithProviders(ref, providers) {
27380
+ if (ref.includes("/"))
27381
+ return ref;
27382
+ for (const [pName, pCfg] of Object.entries(providers)) {
27383
+ const models = pCfg.models || [];
27384
+ if (models.some((m) => m?.id === ref))
27385
+ return pName + "/" + ref;
27386
+ }
27387
+ return ref;
27388
+ }
27389
+ function resolveModelRefStrict(ref) {
27390
+ const providers = getEndpointConfigSource().getProviders();
27391
+ const model = resolveModel(normalizeModelRefWithProviders(ref, providers));
27392
+ if (model)
27393
+ return { kind: "provider", model };
27394
+ if (MODEL_ROLES.includes(ref)) {
27395
+ const role = ref;
27396
+ return getRoleModel(role) !== undefined ? { kind: "role", role } : { kind: "unconfigured-role", role };
27397
+ }
27398
+ return { kind: "unknown" };
27399
+ }
27400
+ function resolveDefaultRole(raw) {
27401
+ return MODEL_ROLES.includes(raw) ? raw : "premium";
27402
+ }
27388
27403
  function resolveModel(ref) {
27389
27404
  const providers = getEndpointConfigSource().getProviders();
27390
27405
  const slash = ref.indexOf("/");
@@ -29238,9 +29253,11 @@ var init_modelprovider = __esm(() => {
29238
29253
  `);
29239
29254
  const hasQuota = failures.some((f) => f.code === "quota_exhausted");
29240
29255
  const fix = hasQuota ? "Top up your provider quota, or switch to another provider/model (settings.json modelRoles/providers, or --model), then retry." : "Check provider credentials/quota, or switch to another provider/model (settings.json modelRoles/providers, or --model), then retry.";
29256
+ const has404 = failures.some((f) => f.code === "api_error_404");
29257
+ const fix404 = has404 ? " api_error_404 often means the URL path is wrong — if the gateway serves an OpenAI-compatible API under /v1, append /v1 to the provider baseURL (settings.json providers.<name>.baseURL)." : "";
29241
29258
  super(`All ${failures.length} model(s) in pool for role '${role}' failed:
29242
29259
  ` + lines + `
29243
- Fix: ${fix}`);
29260
+ Fix: ${fix}${fix404}`);
29244
29261
  this.name = "ModelPoolExhaustedError";
29245
29262
  this.role = role;
29246
29263
  this.failures = failures;
@@ -29373,6 +29390,7 @@ var init_modelprovider2 = __esm(() => {
29373
29390
  init_modelprovider();
29374
29391
  init_params();
29375
29392
  init_roles7();
29393
+ init_roles7();
29376
29394
  init_errorUtils();
29377
29395
  init_effort();
29378
29396
  init_params();
@@ -92450,6 +92468,10 @@ async function getInputPrompt(prompt, inputFormat) {
92450
92468
  if (timedOut) {
92451
92469
  process.stderr.write("Warning: no stdin data received in 3s, proceeding without it. " + `If piping from a slow command, redirect stdin explicitly: < /dev/null to skip, or wait longer.
92452
92470
  `);
92471
+ process.stdin.pause();
92472
+ if (typeof process.stdin.unref === "function") {
92473
+ process.stdin.unref();
92474
+ }
92453
92475
  }
92454
92476
  return [prompt, data].filter(Boolean).join(`
92455
92477
  `);
@@ -93739,12 +93761,72 @@ async function connectMcpStartup(args) {
93739
93761
  const mcpResults = await connectAll();
93740
93762
  const mcpOk = mcpResults.filter((r) => r.status === "fulfilled").length;
93741
93763
  logForDebugging2(mcpConnectLine(mcpOk, mcpResults.length - mcpOk));
93764
+ for (const conn of manager.list()) {
93765
+ if (conn.type !== "failed")
93766
+ continue;
93767
+ if (conn.blockedByPolicy) {
93768
+ const reason = conn.error?.replace(/^MCP server ".*" blocked by enterprise policy: /, "") ?? "enterprise policy";
93769
+ process.stderr.write(`warning: MCP server '${conn.name}' blocked by policy (${reason}) — its tools are unavailable
93770
+ `);
93771
+ } else {
93772
+ process.stderr.write(`warning: MCP server '${conn.name}' failed to start (${conn.error ?? "connection failed"}) — its tools are unavailable
93773
+ `);
93774
+ }
93775
+ }
93742
93776
  }
93743
93777
  const mcpConnections = await buildMcpEngineConnectionsLocal(manager);
93744
93778
  const mcpTools = createMcpTools(mcpConnections);
93745
93779
  syncMcpClientRegistryLocal(manager);
93746
93780
  return { mcpConnections, mcpTools, nonBlocking };
93747
93781
  }
93782
+ function parseHeadlessAgentsJson(agentsJson) {
93783
+ let parsed;
93784
+ try {
93785
+ parsed = JSON.parse(agentsJson);
93786
+ } catch (error) {
93787
+ process.stderr.write(`Error: invalid --agents JSON: ${error instanceof Error ? error.message : String(error)}
93788
+ `);
93789
+ process.exit(1);
93790
+ }
93791
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
93792
+ process.stderr.write(`Error: --agents must be a JSON object mapping agent names to {description, prompt}
93793
+ `);
93794
+ process.exit(1);
93795
+ }
93796
+ const definitions = [];
93797
+ for (const [name, value] of Object.entries(parsed)) {
93798
+ const def = value ?? {};
93799
+ const description = def.description ?? def.whenToUse;
93800
+ if (typeof description !== "string" || typeof def.prompt !== "string" || def.prompt.length === 0) {
93801
+ process.stderr.write(`Error: --agents entry '${name}' must have string 'description' and non-empty 'prompt' fields
93802
+ `);
93803
+ process.exit(1);
93804
+ }
93805
+ const prompt = def.prompt;
93806
+ definitions.push({
93807
+ agentType: name,
93808
+ source: "user",
93809
+ whenToUse: description,
93810
+ getSystemPrompt: () => prompt
93811
+ });
93812
+ }
93813
+ return definitions;
93814
+ }
93815
+ async function resolveHeadlessAgentPrompt(options) {
93816
+ const cliAgents = options.agents !== undefined ? parseHeadlessAgentsJson(options.agents) : [];
93817
+ const agentName = options.agent ?? getInitialSettings().agent;
93818
+ if (!agentName)
93819
+ return;
93820
+ const found = cliAgents.find((a) => a.agentType === agentName) ?? getBuiltInAgents().find((a) => a.agentType === agentName);
93821
+ if (!found) {
93822
+ const available = [...getBuiltInAgents(), ...cliAgents].map((a) => a.agentType).join(", ");
93823
+ process.stderr.write(`Error: agent '${agentName}' not found (available agents: ${available || "(none)"})
93824
+ `);
93825
+ process.exit(1);
93826
+ }
93827
+ const prompt = await found.getSystemPrompt({});
93828
+ return prompt.length > 0 ? prompt : undefined;
93829
+ }
93748
93830
  function validateUuidLocal(value) {
93749
93831
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
93750
93832
  }
@@ -94063,6 +94145,17 @@ async function runHeadless(inputPrompt, options) {
94063
94145
  }
94064
94146
  if (options.outputFormat === "stream-json" && !options.verbose) {
94065
94147
  process.stderr.write(`Error: When using --print, --output-format=stream-json requires --verbose
94148
+ `);
94149
+ process.exit(1);
94150
+ }
94151
+ const strictModelRef = options.model ? resolveModelRefStrict(options.model) : undefined;
94152
+ if (strictModelRef?.kind === "unconfigured-role") {
94153
+ process.stderr.write(`Error: role '${strictModelRef.role}' is not configured (modelRoles.${strictModelRef.role})
94154
+ `);
94155
+ process.exit(1);
94156
+ }
94157
+ if (strictModelRef?.kind === "unknown") {
94158
+ process.stderr.write(`Error: unknown model ref '${options.model}' (no provider entry in settings.json providers table)
94066
94159
  `);
94067
94160
  process.exit(1);
94068
94161
  }
@@ -94090,9 +94183,10 @@ async function runHeadless(inputPrompt, options) {
94090
94183
  strictMcpConfig: options.strictMcpConfig
94091
94184
  });
94092
94185
  const hasPromptRoute = options.permissionPromptToolName === "stdio";
94093
- const role = options.model ? modelToRole(options.model) : "premium";
94186
+ const role = options.model ? strictModelRef?.kind === "role" ? strictModelRef.role : modelToRole(options.model) : resolveDefaultRole(settings.settings.defaultRole);
94094
94187
  const roleModel = getRoleModel(role);
94095
94188
  logForDebugging2(modelLine(role, options.model ?? roleModel));
94189
+ const headlessAgentPrompt = await resolveHeadlessAgentPrompt(options);
94096
94190
  const bundle = await createAgentLoopDeps({
94097
94191
  allowedToolsCli: options.allowedTools ?? [],
94098
94192
  disallowedToolsCli: options.disallowedTools ?? [],
@@ -94107,9 +94201,12 @@ async function runHeadless(inputPrompt, options) {
94107
94201
  baseTools: getBaseToolEntities()
94108
94202
  },
94109
94203
  role,
94110
- sessionModel: options.model,
94204
+ sessionModel: strictModelRef?.kind === "role" ? undefined : options.model,
94111
94205
  disablePersistence: options.disablePersistence,
94112
- systemPrompt: resolveHeadlessSystemPrompt(options),
94206
+ systemPrompt: headlessAgentPrompt ? asSystemPrompt([
94207
+ headlessAgentPrompt,
94208
+ ...options.appendSystemPrompt ? [options.appendSystemPrompt] : []
94209
+ ]) : resolveHeadlessSystemPrompt(options),
94113
94210
  thinkingConfig: options.thinkingConfig,
94114
94211
  responseFormat: options.jsonSchema ? toResponseFormat({ type: "json_schema", schema: options.jsonSchema }) : undefined,
94115
94212
  effortValue: options.effort,
@@ -94595,7 +94692,7 @@ async function loadResumedMessages(options) {
94595
94692
  await processResumedConversation({
94596
94693
  messages: conversation,
94597
94694
  sessionId: resumedId
94598
- }, { forkSession: false, sessionIdOverride: resumedId });
94695
+ }, { forkSession: options.forkSession ?? false, sessionIdOverride: resumedId });
94599
94696
  return conversation;
94600
94697
  }
94601
94698
  var init_print = __esm(() => {
@@ -94609,6 +94706,8 @@ var init_print = __esm(() => {
94609
94706
  init_streamJsonStdoutGuard();
94610
94707
  init_approvalChannel();
94611
94708
  init_headlessPrompt();
94709
+ init_engine();
94710
+ init_shared();
94612
94711
  init_debugSink();
94613
94712
  init_hooksWiring();
94614
94713
  init_headlessSessionEnd();
@@ -95680,6 +95779,8 @@ function buildHeadlessOptions(options) {
95680
95779
  addDirs: options.addDir,
95681
95780
  replayUserMessages: options.replayUserMessages === true ? true : undefined,
95682
95781
  agent: options.agent,
95782
+ forkSession: options.forkSession === true ? true : undefined,
95783
+ agents: options.agents,
95683
95784
  disablePersistence: options.sessionPersistence === false ? true : undefined,
95684
95785
  jsonSchema: parseJsonSchemaOption(options.jsonSchema),
95685
95786
  systemPrompt: readPromptFileInline(options.systemPrompt, options.systemPromptFile, "System prompt"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaswork/atlascode",
3
- "version": "0.1.134",
3
+ "version": "0.1.136",
4
4
  "description": "AtlasCode — Coding Agent for the domestic computing ecosystem (Ascend NPU + domestic LLM backends)",
5
5
  "homepage": "https://www.atlaswork.cn/",
6
6
  "bin": {