Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 96 additions & 0 deletions packages/cli/THIRD_PARTY_NOTICES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,60 @@ SOFTWARE.

================================================================================

Package: @formatjs/fast-memoize@3.1.7
Declared license: MIT
Selected license: MIT
Repository: formatjs/formatjs.git

--- LICENSE.md ---
MIT License

Copyright (c) 2023 FormatJS

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

================================================================================

Package: @formatjs/icu-messageformat-parser@3.5.15
Declared license: MIT
Selected license: MIT
Repository: https://github.com/formatjs/formatjs.git#packages/icu-messageformat-parser

--- LICENSE.md ---
MIT License

Copyright (c) 2023 FormatJS

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

================================================================================

Package: @formatjs/icu-skeleton-parser@2.1.11
Declared license: MIT
Selected license: MIT
Repository: https://github.com/formatjs/formatjs.git#packages/icu-skeleton-parser

--- LICENSE.md ---
MIT License

Copyright (c) 2023 FormatJS

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

================================================================================

Package: @larksuiteoapi/node-sdk@1.73.0
Declared license: MIT
Selected license: MIT
Expand Down Expand Up @@ -4751,6 +4805,48 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

================================================================================

Package: intl-messageformat@11.2.12
Declared license: BSD-3-Clause
Selected license: BSD-3-Clause
Repository: git@github.com:formatjs/formatjs.git

--- LICENSE.md ---
Copyright (c) 2023, Oath Inc.

Licensed under the terms of the New BSD license. See below for terms.

Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:

- Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.

- Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.

- Neither the name of Oath Inc. nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of Oath Inc.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

================================================================================

Package: ip-address@10.4.0
Declared license: MIT
Selected license: MIT
Expand Down
129 changes: 110 additions & 19 deletions packages/cli/src/__tests__/pi-tui-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ function historicalGraphSnapshot(graphId: string): AgentGraphClientSnapshot {
}

/** Catalog API-key providers as wizard entries with no existing connection —
* the default `/setup` provider list for tests that don't need 已设置 state. */
* the default `/setup` provider list for tests that don't need configured state. */
function defaultOnboardingProviders(): OnboardingProviderEntry[] {
return listApiKeyOnboardableProviders().map((provider) => ({
...provider,
target: { kind: 'create', providerType: provider.providerType },
label: `${provider.label} · 添加账号`,
label: provider.label,
enabledModelIds: [],
}));
}
Expand Down Expand Up @@ -238,7 +238,7 @@ function savedOnboardingRefreshFailed(connectionId = 'saved-connection-id'): Onb
},
refresh: {
kind: 'failed',
warning: '账号已保存,但模型列表暂未刷新。重启 Maka 后会重新载入。',
reason: 'catalog_unavailable',
},
};
}
Expand Down Expand Up @@ -795,12 +795,13 @@ describe('Maka Pi TUI runner', () => {
model: 'claude-sonnet-4-5',
connectionSlug: 'claude-subscription',
permissionMode: 'bypass',
locale: 'zh',
terminal,
onboarding: fakeOnboardingSurface({
verify: async (input) => {
verifyCalls.push(input.apiKey ?? '');
return verifyCalls.length === 1
? { kind: 'error', text: 'HTTP 401 Unauthorized' }
? { kind: 'rejected', reason: 'connection_not_found' }
: { kind: 'ok', models: [{ id: 'gpt-5.5' }] };
},
}),
Expand All @@ -811,7 +812,7 @@ describe('Maka Pi TUI runner', () => {
terminal.input('\r');
await waitFor(() => {
try {
return latestPlainLineContaining(terminal.writes.join(''), 'Set Up Provider') !== null;
return latestPlainLineContaining(terminal.writes.join(''), '配置模型提供商') !== null;
} catch {
return false;
}
Expand All @@ -829,7 +830,7 @@ describe('Maka Pi TUI runner', () => {
await waitFor(() => verifyCalls.length === 1);
await waitFor(() => {
try {
return latestPlainLineContaining(terminal.writes.join(''), '验证失败') !== null;
return latestPlainLineContaining(terminal.writes.join(''), '该连接已不存在') !== null;
} catch {
return false;
}
Expand All @@ -850,6 +851,51 @@ describe('Maka Pi TUI runner', () => {
]);
});

test('localizes a save rejection without displaying Host text', async () => {
const terminal = new FakeTerminal();
const driver = new SlashCommandDriver();
let saveCalls = 0;
const run = runMakaPiTui({
title: 'Maka',
driver,
cwd: '/repo',
model: 'claude-sonnet-4-5',
connectionSlug: 'claude-subscription',
permissionMode: 'bypass',
locale: 'zh',
terminal,
onboarding: fakeOnboardingSurface({
save: async () => {
saveCalls += 1;
return { kind: 'rejected', reason: 'superseded' };
},
}),
});

await waitForTuiPaint(terminal);
terminal.input('/setup');
terminal.input('\r');
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('配置模型提供商'));
terminal.input('\r');
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('API key'));
terminal.input('sk-test');
terminal.input('\r');
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('3/3'));
terminal.input(' ');
terminal.input('\r');
await waitFor(() => saveCalls === 1);
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('该连接已发生变化'));
assert.doesNotMatch(plainTerminalOutput(terminal.screenOutput()), /This connection changed/);

process.emit('SIGTERM');
await Promise.race([
run,
delay(CLOSE_BUDGET_MS).then(() => {
throw new Error('TUI did not close after SIGTERM');
}),
]);
});

test('threads the selected same-provider account identity through verify and save', async () => {
const terminal = new FakeTerminal();
const driver = new SlashCommandDriver();
Expand Down Expand Up @@ -1024,7 +1070,9 @@ describe('Maka Pi TUI runner', () => {
terminal.input('\r');
await waitFor(() => {
try {
return latestPlainLineContaining(terminal.writes.join(''), 'Onboarding 不可用') !== null;
return (
latestPlainLineContaining(terminal.writes.join(''), 'Onboarding is unavailable') !== null
);
} catch {
return false;
}
Expand Down Expand Up @@ -1063,11 +1111,14 @@ describe('Maka Pi TUI runner', () => {
terminal.input('/setup');
terminal.input('\r');
await waitFor(() =>
plainTerminalOutput(terminal.screenOutput()).includes('storage read failed'),
plainTerminalOutput(terminal.screenOutput()).includes(
'Could not read configured connections',
),
);
assert.doesNotMatch(plainTerminalOutput(terminal.screenOutput()), /storage read failed/);
assert.doesNotMatch(
plainTerminalOutput(terminal.screenOutput()),
/没有可配置的 API key 类供应商/,
/No configurable API key providers are available/,
);

process.emit('SIGTERM');
Expand Down Expand Up @@ -1127,7 +1178,7 @@ describe('Maka Pi TUI runner', () => {
await waitFor(() => verifyCalls.length === 1);
await waitFor(() => {
try {
return latestPlainLineContaining(terminal.writes.join(''), '验证') !== null;
return latestPlainLineContaining(terminal.writes.join(''), 'Verifying') !== null;
} catch {
return false;
}
Expand Down Expand Up @@ -1155,7 +1206,7 @@ describe('Maka Pi TUI runner', () => {
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('sk-b'));
// A's verify now resolves with a failure. It must not clobber attempt B:
// no failure status line, and the key being typed for B survives.
resolveFirst({ kind: 'error', text: 'HTTP 401 Unauthorized' });
resolveFirst({ kind: 'failed', errorClass: 'auth' });
// Sentinel render: one more typed key char forces a full repaint that lands
// after A's settled continuation, so a wrongly-applied failure line would be
// in this exact frame.
Expand Down Expand Up @@ -1224,7 +1275,7 @@ describe('Maka Pi TUI runner', () => {
await waitFor(() => saveCalls.length === 1);
await waitFor(() => {
try {
return latestPlainLineContaining(terminal.writes.join(''), '保存') !== null;
return latestPlainLineContaining(terminal.writes.join(''), 'Saving') !== null;
} catch {
return false;
}
Expand All @@ -1247,7 +1298,7 @@ describe('Maka Pi TUI runner', () => {
// would be in this exact frame.
terminal.input('sk-z');
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('sk-z'));
assert.doesNotMatch(plainTerminalOutput(terminal.screenOutput()), /已启用/);
assert.doesNotMatch(plainTerminalOutput(terminal.screenOutput()), /Models enabled/u);

terminal.input('\r'); // verify the now-existing Connection
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('3/3'));
Expand Down Expand Up @@ -1373,7 +1424,7 @@ describe('Maka Pi TUI runner', () => {
// A malformed endpoint is rejected in place, before any host call.
terminal.input('not a url');
terminal.input('\r');
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('不是有效的 URL'));
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('not a valid URL'));
for (let i = 0; i < 'not a url'.length; i++) terminal.input('\x7f'); // clear the field
terminal.input('https://relay.example.test/v1');
terminal.input('\r');
Expand All @@ -1393,8 +1444,11 @@ describe('Maka Pi TUI runner', () => {
terminal.input('\r'); // save
await waitFor(() => saveCalls.length === 1);
assert.equal(saveCalls[0]?.baseUrl, 'https://relay.example.test/v1');
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('已启用'));
assert.match(plainTerminalOutput(terminal.screenOutput()), /账号已保存,但模型列表暂未刷新/);
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('Models enabled'));
assert.match(
plainTerminalOutput(terminal.screenOutput()),
/Account saved, but the model list has not refreshed/,
);

process.emit('SIGTERM');
await Promise.race([
Expand Down Expand Up @@ -3595,6 +3649,42 @@ describe('Maka Pi TUI runner', () => {
]);
});

test('localizes generic model and thinking picker hints in Chinese', async () => {
const terminal = new FakeTerminal();
const driver = new SlashCommandDriver();
const run = runMakaPiTui({
title: 'Maka',
driver,
cwd: '/repo',
model: 'gpt-5',
models: ['gpt-5', 'gpt-5-mini'],
connectionSlug: 'openai',
providerType: 'openai',
permissionMode: 'ask',
locale: 'zh',
terminal,
});

terminal.input('/model');
terminal.input('\r');
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('选择模型'));
assert.match(plainTerminalOutput(terminal.screenOutput()), /↑↓ 选择 · Enter 确认 · Esc 关闭/u);
terminal.input('\x1b');

terminal.input('/thinking');
terminal.input('\r');
await waitFor(() => plainTerminalOutput(terminal.screenOutput()).includes('选择思考级别'));
assert.match(plainTerminalOutput(terminal.screenOutput()), /↑↓ 选择 · Enter 确认 · Esc 关闭/u);
assert.doesNotMatch(
plainTerminalOutput(terminal.screenOutput()),
/enter select \/ esc close/iu,
);

terminal.input('\x1b');
exitMaka(terminal);
await run;
});

test('resumes a read-only session as Read only, and never marks Auto as current', async () => {
// #1611 in the TUI: the resumed boundary is read-only, so the status line
// must name it and the picker must not present Auto as "the option you are
Expand Down Expand Up @@ -3657,6 +3747,7 @@ describe('Maka Pi TUI runner', () => {
connectionId: 'connection-openai',
connectionSlug: 'openai',
providerType: 'openai',
locale: 'en',
modelChoices: [
{
connectionId: 'connection-openai',
Expand Down Expand Up @@ -3691,7 +3782,7 @@ describe('Maka Pi TUI runner', () => {
await waitFor(() => terminal.output().includes('GLM 5.2'));
assert.match(
plainTerminalOutput(terminal.screenOutput()),
/切换模型可能需要重建提示缓存;下一次请求可能更慢或成本更高/,
/Switching models may rebuild the prompt cache; the next request may be slower/,
);
// The picker opens on the current model (gpt-5.5); move down to the choice on
// the other connection and select it.
Expand Down Expand Up @@ -3773,7 +3864,7 @@ describe('Maka Pi TUI runner', () => {
});
assert.doesNotMatch(
plainTerminalOutput(terminal.screenOutput()),
/切换模型可能需要重建提示缓存/,
/Switching models may rebuild the prompt cache/,
);
// Each query isolates exactly one of the five match criteria named by #1098
// (model id, connection name, connection slug, provider type, provider
Expand Down Expand Up @@ -3855,7 +3946,7 @@ describe('Maka Pi TUI runner', () => {
await waitFor(() => terminal.output().includes('gpt-5.6'));
assert.doesNotMatch(
plainTerminalOutput(terminal.screenOutput()),
/切换模型可能需要重建提示缓存/,
/Switching models may rebuild the prompt cache/,
);
terminal.input('\x1b[B');
terminal.input('\r');
Expand Down
Loading
Loading