aptly 0.1.7 → 0.1.9
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/dist/bin/aptly.js +109 -92
- package/dist/src/automatic-hook.js +4 -1
- package/dist/src/budget.d.ts +23 -0
- package/dist/src/budget.js +54 -0
- package/dist/src/cli-help.d.ts +11 -0
- package/dist/src/cli-help.js +102 -0
- package/dist/src/context-retry.js +3 -3
- package/dist/src/core.d.ts +29 -3
- package/dist/src/core.js +68 -12
- package/dist/src/ledger-lock.d.ts +3 -1
- package/dist/src/ledger-lock.js +3 -1
- package/dist/src/linux-store-readiness.d.ts +12 -0
- package/dist/src/linux-store-readiness.js +67 -0
- package/dist/src/runtime.d.ts +1 -0
- package/dist/src/runtime.js +5 -3
- package/dist/src/server.js +2 -2
- package/dist/src/setup.d.ts +55 -0
- package/dist/src/setup.js +146 -23
- package/dist/src/types.d.ts +2 -0
- package/dist/src/update-notifier.js +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/docs/guide/en.md +52 -1
- package/docs/guide/ja.md +52 -1
- package/docs/guide/ko.md +52 -1
- package/docs/guide/zh-CN.md +52 -1
- package/package.json +1 -1
package/dist/src/setup.js
CHANGED
|
@@ -6,6 +6,8 @@ import { randomUUID } from 'node:crypto';
|
|
|
6
6
|
import { isDeepStrictEqual } from 'node:util';
|
|
7
7
|
import { parse } from 'smol-toml';
|
|
8
8
|
import { resolveCatalog } from './catalog.js';
|
|
9
|
+
import { budgetEnvironmentDefaults, budgetEnvironmentKeys, parseBudgetValue, resolveBudgetSettings, budgetErrorDetails } from './budget.js';
|
|
10
|
+
import { Router, defaultPolicy } from './core.js';
|
|
9
11
|
import { loadAutomaticHookPolicy, effectiveTransmission } from './automatic-hook.js';
|
|
10
12
|
import { assertPrivateStatePath } from './files.js';
|
|
11
13
|
import { assertWindowsPrivatePath, protectNewWindowsPrivateDirectory, copyWindowsFilePermissions } from './windows-private.js';
|
|
@@ -156,8 +158,8 @@ function removeTomlEnv(text, additions) {
|
|
|
156
158
|
fail('managed_entry_changed');
|
|
157
159
|
return text;
|
|
158
160
|
}
|
|
159
|
-
export const configurableEnvironmentKeys = Object.freeze(['ROUTER_PROVIDER', 'APTLY_CLAUDE_MODELS', 'APTLY_CODEX_MODELS', 'CLAUDE_MODELS', 'CODEX_MODELS', 'APTLY_MODEL_INFO_PATH']);
|
|
160
|
-
const defaultEnvironment = { ROUTER_PROVIDER: 'decisions', APTLY_CLAUDE_MODELS: '["haiku","sonnet","opus"]', APTLY_CODEX_MODELS: '["gpt-6-luna","gpt-6.1-terra","gpt-6.1-sol"]' };
|
|
161
|
+
export const configurableEnvironmentKeys = Object.freeze([...budgetEnvironmentKeys, 'ROUTER_PROVIDER', 'APTLY_CLAUDE_MODELS', 'APTLY_CODEX_MODELS', 'CLAUDE_MODELS', 'CODEX_MODELS', 'APTLY_MODEL_INFO_PATH']);
|
|
162
|
+
const defaultEnvironment = { ...budgetEnvironmentDefaults, ROUTER_PROVIDER: 'decisions', APTLY_CLAUDE_MODELS: '["haiku","sonnet","opus"]', APTLY_CODEX_MODELS: '["gpt-6-luna","gpt-6.1-terra","gpt-6.1-sol"]' };
|
|
161
163
|
function validateEnvironmentValue(key, value) {
|
|
162
164
|
if (!configurableEnvironmentKeys.includes(key))
|
|
163
165
|
fail(/KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL/i.test(key) ? 'environment_secret_key_unsupported' : 'environment_key_unsupported');
|
|
@@ -165,6 +167,14 @@ function validateEnvironmentValue(key, value) {
|
|
|
165
167
|
fail('environment_invalid_value');
|
|
166
168
|
if (/\bsk-[A-Za-z0-9_-]{8,}|\bBearer\s+\S+|https?:\/\/[^/\s]+:[^/\s]+@/i.test(value))
|
|
167
169
|
fail('environment_sensitive_value');
|
|
170
|
+
if (budgetEnvironmentKeys.includes(key)) {
|
|
171
|
+
try {
|
|
172
|
+
parseBudgetValue(key, value);
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
throw Object.assign(new Error('environment_invalid_value'), budgetErrorDetails(error));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
168
178
|
if (key === 'ROUTER_PROVIDER' && !['fixture', 'decisions'].includes(value))
|
|
169
179
|
fail('environment_invalid_value');
|
|
170
180
|
if (key === 'APTLY_MODEL_INFO_PATH') {
|
|
@@ -176,12 +186,28 @@ function validateEnvironmentValue(key, value) {
|
|
|
176
186
|
}
|
|
177
187
|
}
|
|
178
188
|
}
|
|
179
|
-
function
|
|
189
|
+
function budgetInheritance(entry, environment, client) {
|
|
190
|
+
if (client === 'codex' && entry.env_vars !== undefined && (!Array.isArray(entry.env_vars) || entry.env_vars.some((key) => typeof key !== 'string')))
|
|
191
|
+
fail('configuration_shape_conflict');
|
|
192
|
+
const permitted = client === 'codex' ? (entry.env_vars ?? []) : [], keys = new Set(), values = {};
|
|
193
|
+
for (const key of budgetEnvironmentKeys) {
|
|
194
|
+
if (client === 'codex' ? permitted.includes(key) : environment[key] !== undefined) {
|
|
195
|
+
keys.add(key);
|
|
196
|
+
if (environment[key] !== undefined)
|
|
197
|
+
values[key] = environment[key];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
for (const key of Object.keys(environment))
|
|
201
|
+
if ((key.startsWith('APTLY_MAX_') || key.startsWith('APTLY_ESTIMATED_')) && (client === 'claude' || permitted.includes(key)))
|
|
202
|
+
values[key] = environment[key];
|
|
203
|
+
return { keys, values };
|
|
204
|
+
}
|
|
205
|
+
function editEnvironment(current, edit, client, inherited) {
|
|
180
206
|
const updates = {};
|
|
181
207
|
if ('defaults' in edit) {
|
|
182
208
|
for (const [key, value] of Object.entries(defaultEnvironment)) {
|
|
183
209
|
const alias = key === 'APTLY_CLAUDE_MODELS' ? 'CLAUDE_MODELS' : key === 'APTLY_CODEX_MODELS' ? 'CODEX_MODELS' : null;
|
|
184
|
-
if (current[key] === undefined && (!alias || current[alias] === undefined))
|
|
210
|
+
if (current[key] === undefined && (!alias || current[alias] === undefined) && !(budgetEnvironmentKeys.includes(key) && inherited.keys.has(key)))
|
|
185
211
|
updates[key] = value;
|
|
186
212
|
}
|
|
187
213
|
}
|
|
@@ -193,14 +219,15 @@ function editEnvironment(current, edit, client) {
|
|
|
193
219
|
validateEnvironmentValue(edit.key, edit.value);
|
|
194
220
|
updates[edit.key] = edit.value;
|
|
195
221
|
}
|
|
196
|
-
const effective = { ...current, ...updates };
|
|
222
|
+
const effective = { ...inherited.values, ...current, ...updates };
|
|
197
223
|
if (effective.ROUTER_PROVIDER !== undefined && !['fixture', 'decisions'].includes(effective.ROUTER_PROVIDER))
|
|
198
224
|
fail('environment_invalid_value');
|
|
199
225
|
try {
|
|
200
226
|
resolveCatalog(effective);
|
|
227
|
+
resolveBudgetSettings(effective);
|
|
201
228
|
}
|
|
202
|
-
catch {
|
|
203
|
-
|
|
229
|
+
catch (error) {
|
|
230
|
+
throw Object.assign(new Error('environment_invalid_value'), budgetErrorDetails(error));
|
|
204
231
|
}
|
|
205
232
|
return Object.fromEntries(Object.entries(updates).filter(([key, value]) => current[key] !== value));
|
|
206
233
|
}
|
|
@@ -406,11 +433,17 @@ function prepare(options, client, removing, edit) {
|
|
|
406
433
|
else {
|
|
407
434
|
if (!object(servers.aptly))
|
|
408
435
|
fail('mcp_entry_conflict');
|
|
436
|
+
const configuredPolicy = object(servers.aptly.env) ? servers.aptly.env.APTLY_HOOK_POLICY_PATH : undefined;
|
|
437
|
+
const mismatch = configuredPolicy !== undefined && configuredPolicy !== policyPath;
|
|
438
|
+
const detail = mismatch && typeof configuredPolicy === 'string' && configuredPolicy.length > 0 ? {
|
|
439
|
+
policy_location: configuredPolicy === join(resolve(options.home ?? homedir()), client === 'codex' ? '.codex' : '.claude', 'aptly', 'auto-policy.json') ? 'default_home' : 'elsewhere',
|
|
440
|
+
selected_home_source: (client === 'codex' ? env.CODEX_HOME : env.CLAUDE_CONFIG_DIR) ? 'override' : 'default',
|
|
441
|
+
} : undefined;
|
|
409
442
|
if (edit && oldOwner?.mcp_created && !isDeepStrictEqual(servers.aptly, oldOwner.mcp))
|
|
410
|
-
|
|
443
|
+
throw Object.assign(new Error('managed_mcp_changed'), detail ? { policyConflict: detail } : {});
|
|
444
|
+
if (mismatch)
|
|
445
|
+
throw Object.assign(new Error('mcp_environment_conflict'), { policyConflict: detail });
|
|
411
446
|
const currentEnv = map(servers.aptly, 'env');
|
|
412
|
-
if (currentEnv.APTLY_HOOK_POLICY_PATH !== undefined && currentEnv.APTLY_HOOK_POLICY_PATH !== policyPath)
|
|
413
|
-
fail('mcp_environment_conflict');
|
|
414
447
|
const missing = Object.fromEntries(Object.entries(additions).filter(([key]) => currentEnv[key] === undefined));
|
|
415
448
|
Object.assign(currentEnv, missing);
|
|
416
449
|
mcp.after = client === 'codex' ? addTomlEnv(mcp.before ?? '', missing) : stringify(config);
|
|
@@ -422,7 +455,8 @@ function prepare(options, client, removing, edit) {
|
|
|
422
455
|
if (edit && ('credential' in edit || 'migrate' in edit))
|
|
423
456
|
requireCredentialRuntime(servers.aptly, root);
|
|
424
457
|
const currentEnv = map(servers.aptly, 'env');
|
|
425
|
-
const
|
|
458
|
+
const originalEnvKeys = new Set(Object.keys(currentEnv)), inheritedBudget = budgetInheritance(servers.aptly, env, client);
|
|
459
|
+
const updates = edit ? editEnvironment(currentEnv, edit, client, inheritedBudget) : {};
|
|
426
460
|
Object.assign(currentEnv, updates);
|
|
427
461
|
if (created) {
|
|
428
462
|
if (client === 'codex') {
|
|
@@ -514,12 +548,19 @@ function prepare(options, client, removing, edit) {
|
|
|
514
548
|
}
|
|
515
549
|
if (requestedScope !== undefined)
|
|
516
550
|
owner.policy = structuredClone(policyValue);
|
|
551
|
+
if (edit && ('defaults' in edit || ('key' in edit && budgetEnvironmentKeys.includes(edit.key)))) {
|
|
552
|
+
const budget = resolveBudgetSettings({ ...inheritedBudget.values, ...currentEnv });
|
|
553
|
+
result.budget = { limits: { ...budget.limits }, added: budgetEnvironmentKeys.filter(key => Object.hasOwn(updates, key) && !originalEnvKeys.has(key)),
|
|
554
|
+
updated: budgetEnvironmentKeys.filter(key => Object.hasOwn(updates, key) && originalEnvKeys.has(key)),
|
|
555
|
+
preserved: budgetEnvironmentKeys.filter(key => !Object.hasOwn(updates, key) && currentEnv[key] !== undefined),
|
|
556
|
+
inherited: budgetEnvironmentKeys.filter(key => currentEnv[key] === undefined && inheritedBudget.keys.has(key)), restart_required: budgetEnvironmentKeys.some(key => Object.hasOwn(updates, key)) };
|
|
557
|
+
}
|
|
517
558
|
result.transmission = effectiveTransmission(policyValue);
|
|
518
559
|
result.transmission_source = policyValue.schema_version === 1 ? 'legacy' : policyValue.transmission === 'unselected' ? 'unselected' : 'explicit';
|
|
519
560
|
manifest.after = stringify(owner);
|
|
520
561
|
if (client === 'codex')
|
|
521
562
|
result.requires_hook_review = true;
|
|
522
|
-
result.codes = [...(client === 'codex' ? ['requires_hook_review'] : []), ...(result.transmission === 'unselected' ? ['transmission_selection_required'] : result.transmission_source === 'legacy' ? ['legacy_transmission_excerpt'] : []), ...(requestedScope !== undefined ? ['mcp_restart_required'] : [])];
|
|
563
|
+
result.codes = [...(client === 'codex' ? ['requires_hook_review'] : []), ...(result.transmission === 'unselected' ? ['transmission_selection_required'] : result.transmission_source === 'legacy' ? ['legacy_transmission_excerpt'] : []), ...(requestedScope !== undefined || result.budget?.restart_required ? ['mcp_restart_required'] : [])];
|
|
523
564
|
dirs.push(dir, privateDir, stateDir);
|
|
524
565
|
}
|
|
525
566
|
// Validate complete desired data before any host file is changed.
|
|
@@ -581,6 +622,13 @@ function replace(snapshot, forward) {
|
|
|
581
622
|
}
|
|
582
623
|
}
|
|
583
624
|
}
|
|
625
|
+
function policyRecovery(client) {
|
|
626
|
+
return [`aptly setup --check --client ${client}`, 'Review the selected host configuration directory and its existing policy reference locally; intentional sharing cannot be inferred. Preserve the registration and select the intended host directory before retrying. A policy conflict does not authenticate the launcher or other changed settings. Review all changed registration fields locally before reuse; keep custom or modified launchers unchanged and do not execute an unverified launcher. Do not copy keys, ledgers or trust settings.'];
|
|
627
|
+
}
|
|
628
|
+
function errorResult(client, error) {
|
|
629
|
+
const detail = error?.policyConflict;
|
|
630
|
+
return { client, status: 'error', codes: [safeCode(error), ...(detail ? ['hook_policy_path_conflict'] : [])], ...budgetErrorDetails(error), ...(detail ? { ...detail, recovery: policyRecovery(client) } : {}) };
|
|
631
|
+
}
|
|
584
632
|
function execute(options, removing, edit, captured) {
|
|
585
633
|
const clients = [...new Set(options.clients ?? ['codex', 'claude'])];
|
|
586
634
|
if (clients.some(client => client !== 'codex' && client !== 'claude'))
|
|
@@ -595,7 +643,7 @@ function execute(options, removing, edit, captured) {
|
|
|
595
643
|
return prepare(options, client, removing, edit);
|
|
596
644
|
}
|
|
597
645
|
catch (e) {
|
|
598
|
-
return { changes: [], observations: [], dirs: [], result:
|
|
646
|
+
return { changes: [], observations: [], dirs: [], result: errorResult(client, e) };
|
|
599
647
|
}
|
|
600
648
|
});
|
|
601
649
|
const results = prepared.map(plan => plan.result);
|
|
@@ -662,9 +710,25 @@ function execute(options, removing, edit, captured) {
|
|
|
662
710
|
}
|
|
663
711
|
return { status: results.some(result => result.status === 'error') ? 'partial' : results.every(result => result.status === 'skipped') ? 'skipped' : 'complete', clients: results };
|
|
664
712
|
}
|
|
665
|
-
const codes = new Set(['transmission_selection_changed', 'transmission_invalid_scope', 'launcher_migration_not_owned', 'launcher_migration_not_standard', 'credential_launcher_unverified', 'environment_invalid_value', 'environment_sensitive_value', 'environment_key_unsupported', 'environment_secret_key_unsupported', 'unsafe_directory', 'unsafe_symlink', 'unsafe_configuration_file', 'invalid_json', 'invalid_json_object', 'configuration_shape_conflict', 'hook_shape_conflict', 'invalid_toml', 'unsupported_toml_layout', 'relative_configuration_directory', 'invalid_ownership', 'managed_hook_changed', 'managed_mcp_changed', 'managed_entry_changed', 'managed_policy_changed', 'mcp_entry_conflict', 'mcp_environment_conflict', 'existing_routing_hook_conflict', 'policy_conflict', 'existing_hook_not_owned', 'concurrent_configuration_change', 'private_directory_permissions', 'private_file_permissions']);
|
|
713
|
+
const codes = new Set(['unsafe_ledger', 'invalid_ledger', 'budget_ledger_unconfigured', 'invalid_budget_configuration', 'ledger_locked', 'ledger_error', 'transmission_selection_changed', 'transmission_invalid_scope', 'launcher_migration_not_owned', 'launcher_migration_not_standard', 'credential_launcher_unverified', 'environment_invalid_value', 'environment_sensitive_value', 'environment_key_unsupported', 'environment_secret_key_unsupported', 'unsafe_directory', 'unsafe_symlink', 'unsafe_configuration_file', 'invalid_json', 'invalid_json_object', 'configuration_shape_conflict', 'hook_shape_conflict', 'invalid_toml', 'unsupported_toml_layout', 'relative_configuration_directory', 'invalid_ownership', 'managed_hook_changed', 'managed_mcp_changed', 'managed_entry_changed', 'managed_policy_changed', 'mcp_entry_conflict', 'mcp_environment_conflict', 'existing_routing_hook_conflict', 'policy_conflict', 'existing_hook_not_owned', 'concurrent_configuration_change', 'private_directory_permissions', 'private_file_permissions']);
|
|
666
714
|
function safeCode(error) { return error instanceof Error && codes.has(error.message) ? error.message : 'configuration_io_error'; }
|
|
667
715
|
export function setupHosts(options = {}) { return execute(options, false); }
|
|
716
|
+
/** Snapshot the normal setup plan without applying it; it does not verify a running host. */
|
|
717
|
+
export function checkSetup(options = {}) {
|
|
718
|
+
const clients = [...new Set(options.clients ?? ['codex', 'claude'])];
|
|
719
|
+
if (!clients.length || clients.some(client => client !== 'codex' && client !== 'claude') || options.automatic !== undefined || options.mode !== undefined || options.transmission !== undefined || options.selectUnselectedOnly !== undefined)
|
|
720
|
+
return { status: 'partial', clients: [] };
|
|
721
|
+
const results = clients.map(client => {
|
|
722
|
+
try {
|
|
723
|
+
const plan = prepare(options, client, false);
|
|
724
|
+
return { ...plan.result, status: 'unchanged', codes: [plan.changes.length ? 'setup_check_configure_ready' : 'setup_check_ok', ...plan.result.codes] };
|
|
725
|
+
}
|
|
726
|
+
catch (error) {
|
|
727
|
+
return errorResult(client, error);
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
return { status: results.some(result => result.status === 'error') ? 'partial' : 'complete', clients: results };
|
|
731
|
+
}
|
|
668
732
|
export function removeSetup(options = {}) { return execute(options, true); }
|
|
669
733
|
export function setDefaults(options = {}) { return execute(options, false, { defaults: true }); }
|
|
670
734
|
export function setEnvironment(key, value, options = {}) {
|
|
@@ -672,7 +736,7 @@ export function setEnvironment(key, value, options = {}) {
|
|
|
672
736
|
validateEnvironmentValue(key, value);
|
|
673
737
|
}
|
|
674
738
|
catch (error) {
|
|
675
|
-
return { status: 'partial', clients: (options.clients ?? ['codex', 'claude']).map(client => ({ client, status: 'error', codes: [safeCode(error)] })) };
|
|
739
|
+
return { status: 'partial', clients: (options.clients ?? ['codex', 'claude']).map(client => ({ client, status: 'error', codes: [safeCode(error)], ...budgetErrorDetails(error) })) };
|
|
676
740
|
}
|
|
677
741
|
return execute(options, false, { key, value });
|
|
678
742
|
}
|
|
@@ -702,12 +766,17 @@ export function prepareCredentialReference(options, client) {
|
|
|
702
766
|
result = { client, status: 'unchanged', codes: ['credential_preflight_ok'] };
|
|
703
767
|
}
|
|
704
768
|
catch (error) {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
769
|
+
if (error?.policyConflict) {
|
|
770
|
+
result = errorResult(client, error);
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
const reason = error?.reason;
|
|
774
|
+
const reasons = ['credential_node_mismatch', 'credential_server_mismatch', 'credential_runtime_unsupported'];
|
|
775
|
+
const migration = migrateLauncher({ ...options, clients: [client] }, true);
|
|
776
|
+
const canMigrate = migration.status === 'complete';
|
|
777
|
+
result = { client, status: 'error', codes: [safeCode(error), ...(reason && reasons.includes(reason) ? [reason] : []), ...(canMigrate ? ['launcher_migration_available'] : [])],
|
|
778
|
+
recovery: canMigrate ? recovery(client) : [`aptly set env OPENAI_API_KEY --client ${client} --check`, 'Keep custom or modified launchers unchanged. Review the host registration locally; use its secure credential environment or a separately reviewed standard registration.'] };
|
|
779
|
+
}
|
|
711
780
|
}
|
|
712
781
|
const check = () => {
|
|
713
782
|
if (!plan)
|
|
@@ -719,7 +788,18 @@ export function prepareCredentialReference(options, client) {
|
|
|
719
788
|
return result;
|
|
720
789
|
}
|
|
721
790
|
catch (error) {
|
|
722
|
-
|
|
791
|
+
// Preserve the concurrent-change guard, but surface a policy mismatch if one is now visible.
|
|
792
|
+
try {
|
|
793
|
+
prepare({ ...options, clients: [client] }, client, false, { credential: true });
|
|
794
|
+
}
|
|
795
|
+
catch (current) {
|
|
796
|
+
if (current?.policyConflict) {
|
|
797
|
+
const detail = errorResult(client, current);
|
|
798
|
+
return { ...detail, codes: [safeCode(error), 'hook_policy_path_conflict'] };
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
const result = errorResult(client, error);
|
|
802
|
+
return result.recovery ? result : { ...result, recovery: recovery(client) };
|
|
723
803
|
}
|
|
724
804
|
};
|
|
725
805
|
return { result, check, commit: () => {
|
|
@@ -745,7 +825,7 @@ export function migrateLauncher(options, dryRun = false, includeExisting = false
|
|
|
745
825
|
return result;
|
|
746
826
|
}
|
|
747
827
|
catch (error) {
|
|
748
|
-
return { status: 'partial', clients: [
|
|
828
|
+
return { status: 'partial', clients: [errorResult(client, error)] };
|
|
749
829
|
}
|
|
750
830
|
}
|
|
751
831
|
/** Explicit operator change; updates policy and its receipt through normal guarded staging. */
|
|
@@ -771,3 +851,46 @@ export function showTransmission(options = {}) {
|
|
|
771
851
|
}
|
|
772
852
|
}) };
|
|
773
853
|
}
|
|
854
|
+
/** Registration snapshot only. Never loads credentials, starts a server or creates a ledger/gate. */
|
|
855
|
+
export function showBudgetStatus(options = {}) {
|
|
856
|
+
const environment = options.env ?? process.env;
|
|
857
|
+
const clients = (options.clients ?? ['codex', 'claude']).map(client => {
|
|
858
|
+
try {
|
|
859
|
+
const { mcpPath } = resolved(options, client), source = read(mcpPath);
|
|
860
|
+
if (source.text === null)
|
|
861
|
+
return { client, status: 'skipped', codes: ['host_not_configured'] };
|
|
862
|
+
const config = client === 'codex' ? toml(source.text) : json(source.text);
|
|
863
|
+
const entry = config[client === 'codex' ? 'mcp_servers' : 'mcpServers']?.aptly;
|
|
864
|
+
if (entry === undefined)
|
|
865
|
+
return { client, status: 'skipped', codes: ['host_not_configured'] };
|
|
866
|
+
if (!object(entry) || entry.env !== undefined && !object(entry.env))
|
|
867
|
+
fail('configuration_shape_conflict');
|
|
868
|
+
if (client === 'codex' && entry.env_vars !== undefined && (!Array.isArray(entry.env_vars) || entry.env_vars.some((key) => typeof key !== 'string')))
|
|
869
|
+
fail('configuration_shape_conflict');
|
|
870
|
+
const permitted = client === 'codex' ? (entry.env_vars ?? []) : [];
|
|
871
|
+
const settings = {};
|
|
872
|
+
const budgetKeys = [...new Set([...budgetEnvironmentKeys, ...Object.keys(entry.env ?? {}).filter(key => key.startsWith('APTLY_MAX_') || key.startsWith('APTLY_ESTIMATED_')), ...Object.keys(environment).filter(key => (key.startsWith('APTLY_MAX_') || key.startsWith('APTLY_ESTIMATED_')) && (client === 'claude' || permitted.includes(key)))])];
|
|
873
|
+
for (const key of [...budgetKeys, 'ROUTER_LEDGER_PATH']) {
|
|
874
|
+
const value = Object.hasOwn(entry.env ?? {}, key) ? entry.env[key] : (client === 'claude' || permitted.includes(key) ? environment[key] : undefined);
|
|
875
|
+
if (value !== undefined)
|
|
876
|
+
settings[key] = value;
|
|
877
|
+
}
|
|
878
|
+
const budget = resolveBudgetSettings(settings), ledgerPath = settings.ROUTER_LEDGER_PATH;
|
|
879
|
+
if (typeof ledgerPath !== 'string')
|
|
880
|
+
fail('budget_ledger_unconfigured');
|
|
881
|
+
assertPrivateStatePath(ledgerPath);
|
|
882
|
+
const router = new Router({ policy: { ...defaultPolicy, ...budget.limits }, budgetConfigurable: true, ledgerPath,
|
|
883
|
+
provider: async () => { throw new Error('status_provider_forbidden'); } });
|
|
884
|
+
const snapshot = router.budgetStatus();
|
|
885
|
+
return { client, status: 'ok', budget: { ...snapshot, provenance: budget.provenance,
|
|
886
|
+
display_limits: Object.fromEntries(Object.entries(snapshot.limits).map(([key, value]) => [key, key !== 'estimated_call_usd' && value === 0 ? 'Unlimited' : value])),
|
|
887
|
+
next_utc_day: new Date(Date.parse(snapshot.utc_day + 'T00:00:00Z') + 86_400_000).toISOString(),
|
|
888
|
+
cost_guard: 'local_estimate_not_billing_cap', snapshot_source: 'host_registration_and_allowed_process_environment',
|
|
889
|
+
running_host_verified: false, settings_require_mcp_restart: true } };
|
|
890
|
+
}
|
|
891
|
+
catch (error) {
|
|
892
|
+
return { client, status: 'error', codes: [safeCode(error)], ...budgetErrorDetails(error) };
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
return { status: clients.some(client => client.status === 'error') ? 'partial' : 'complete', clients };
|
|
896
|
+
}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -34,7 +34,9 @@ export interface Usage {
|
|
|
34
34
|
total_tokens: number;
|
|
35
35
|
}
|
|
36
36
|
export type RoutingStatus = 'recommended' | 'keep_current' | 'needs_context' | 'unavailable';
|
|
37
|
+
export type BudgetLimit = 'max_daily_calls' | 'max_total_calls' | 'max_estimated_usd';
|
|
37
38
|
export interface RoutingResult {
|
|
39
|
+
budget_limit?: BudgetLimit;
|
|
38
40
|
status: RoutingStatus;
|
|
39
41
|
reason: string;
|
|
40
42
|
application: 'advisory_only';
|
|
@@ -23,7 +23,7 @@ function newer(candidate, current) {
|
|
|
23
23
|
}
|
|
24
24
|
function eligible(o) {
|
|
25
25
|
return o.stdinIsTTY && o.stderrIsTTY && o.stdoutIsTTY !== false && !o.env.CI && o.env.APTLY_NO_UPDATE_NOTIFIER !== '1' && !!version(o.currentVersion) &&
|
|
26
|
-
['
|
|
26
|
+
['--version', 'config', 'setup', 'remove', 'set', 'report'].includes(o.command) && !o.args.some(arg => arg === '--help' || arg === '-h') && !o.args.includes('--automatic') && !o.args.includes('--check') && !(o.command === 'set' && o.args[0] === 'transmission' && o.args.includes('--show'));
|
|
27
27
|
}
|
|
28
28
|
function directory(path) {
|
|
29
29
|
if (!isAbsolute(path))
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.9";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.1.
|
|
1
|
+
export const VERSION = '0.1.9';
|
package/docs/guide/en.md
CHANGED
|
@@ -59,6 +59,23 @@ Existing MCP launchers and user wrappers are not automatically migrated. Follow
|
|
|
59
59
|
|
|
60
60
|
Only public Aptly version metadata is requested from the npm registry; no key, task summary, or host configuration is sent. Network and body reads are limited to 800ms and 16KiB. Results are cached at `~/.cache/aptly/update-check.json` for 24 hours, with a one-hour cooldown after failure. Network/cache errors cannot fail the requested command. Set `APTLY_NO_UPDATE_NOTIFIER=1` in the CLI environment to disable checks; it is not a supported key for `aptly set env`. Notifications never install updates.
|
|
61
61
|
|
|
62
|
+
<a id="command-help"></a>
|
|
63
|
+
|
|
64
|
+
### Command help (0.1.8+)
|
|
65
|
+
|
|
66
|
+
Consistent per-command and nested help is supported from Aptly 0.1.8. Use these forms:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
aptly --help
|
|
70
|
+
aptly setup -h
|
|
71
|
+
aptly set default --help
|
|
72
|
+
aptly set env OPENAI_API_KEY --help
|
|
73
|
+
aptly budget status --help
|
|
74
|
+
aptly help catalog refresh
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`--help`, `-h` and `aptly help <command path>` only show usage. They do not read settings, supplied files, stdin or credential stores; prompt; change settings; call APIs or model metadata endpoints; install/update; or run update notifications. Help can follow valid options, but unknown paths/options, invalid supplied values and contradictory option combinations remain errors. Required positional arguments may be omitted to discover usage. A form such as `--output --help` is a missing option value, not a help request that supplies an output path.
|
|
78
|
+
|
|
62
79
|
### Configure with the CLI
|
|
63
80
|
|
|
64
81
|
The `set` commands require 0.1.1 or later. Commands do not automatically switch existing launch paths. API-key setup accepts only the current package’s standard Node/server registration with a verified OS-source-compatible runtime. Custom wrappers, older versions, and other installation prefixes are rejected with `credential_launcher_unverified`; explicitly switch the registration or upgrade it before trying again.
|
|
@@ -97,7 +114,9 @@ Restart MCP, then inspect `provider`, candidates, and `credential_status` with `
|
|
|
97
114
|
|
|
98
115
|
These options require Aptly 0.1.2 or later and are not in npm 0.1.1. To test from source, run `npm ci --ignore-scripts` and `npm run build`, then replace `aptly` below with `node bin/aptly.ts`.
|
|
99
116
|
|
|
100
|
-
Key setup diagnoses selected hosts before input or storage. If any host fails, it does not prompt or change any host. `--check` does not access keys or the credential store.
|
|
117
|
+
Key setup diagnoses selected hosts before input or storage. If any host fails, it does not prompt or change any host. `--check` does not access keys or the credential store.
|
|
118
|
+
|
|
119
|
+
From Aptly 0.1.9, on Linux, `--check` also checks for an executable `secret-tool` and, when a safe explicit session-bus address and `gdbus` are available, reads bus metadata without activating or accessing the credential service. Confirmed failures report `secure_store_unavailable` with `secure_store_secret_tool_missing`, `secure_store_bus_missing`, or `secure_store_service_missing` before input. `secure_store_bus_unverified`, `secure_store_probe_unavailable`, and service-present or activatable unverified codes mean readiness is unknown; a running or activatable service does not prove it is unlocked or writable. Install `secret-tool` and a Secret Service provider, and run from the intended desktop session when needed. The actual store operation can still fail. For SSH or headless sessions, supply `OPENAI_API_KEY` securely to the host MCP process when `APTLY_SECRET_BACKEND` is absent; preserve an existing authentication wrapper or environment. `credential_node_mismatch`, `credential_server_mismatch`, and `credential_runtime_unsupported` identify incompatible Node paths, server paths, and OS-store support respectively.
|
|
101
120
|
|
|
102
121
|
If only Claude failed, diagnose that host and review migration only when `launcher_migration_available` is returned:
|
|
103
122
|
|
|
@@ -110,6 +129,8 @@ aptly set env OPENAI_API_KEY --client claude
|
|
|
110
129
|
|
|
111
130
|
`--dry-run` makes no changes. Migration replaces the Node/server paths of a receipt-matching, Aptly-owned standard registration with the current build. It preserves environment settings, Hooks, policy and other hosts, accesses no credentials, and never executes the old launcher. Custom wrappers and missing or modified ownership records are rejected. Review such registrations locally; use the wrapper's secure environment or a separately reviewed standard registration. Do not edit or delete ownership records to bypass validation.
|
|
112
131
|
|
|
132
|
+
From Aptly 0.1.9, `aptly setup --check --client codex|claude|all` reads the normal setup plan without writing files or creating directories. It is a snapshot, not a check of the running host. Only `--client` can be combined with `--check`. If `hook_policy_path_conflict` appears, review the selected host configuration directory and existing policy reference locally, then select the intended host directory before retrying. Setup preserves the existing configuration and does not move or copy the policy; launcher migration does not resolve this mismatch.
|
|
133
|
+
|
|
113
134
|
If `launcher_migration_not_owned` refers to a preserved registration (`mcp_created: false`), **Aptly 0.1.3 or later** offers the explicit `--include-existing` opt-in. Install 0.1.3 or later, then run:
|
|
114
135
|
|
|
115
136
|
```sh
|
|
@@ -231,6 +252,36 @@ For genuinely independent work, the caller can intentionally choose a fresh chil
|
|
|
231
252
|
|
|
232
253
|
`confidence` is metadata and has not been validated here as a calibrated probability of correctness. It is not currently used as an automatic-application threshold. Zero and low values are currently allowed when other application conditions hold. A missing value in a live Decisions response is rejected as an error; it remains optional in generic Router and stored results. `keep_current` and `needs_context` are separate outcomes with existing abstention and context-recovery rules. Explicit model, effort, history and permissions are preserved. A small classification pilot does not establish improved child-task quality or total cost.
|
|
233
254
|
|
|
255
|
+
<a id="budget-limits"></a>
|
|
256
|
+
|
|
257
|
+
### Budget limits and usage (0.1.8+)
|
|
258
|
+
|
|
259
|
+
Budget environment settings and usage status are supported from Aptly 0.1.8. `aptly set default` also fills missing budget environment settings for selected hosts. It adds no budget questionnaire, preserves existing values including explicit `0`, and does not reset usage, ledgers or caches. The existing transmission-scope question is separate. Existing registrations without budget variables also use the new runtime defaults after upgrade. The old implicit 20-call/50-call/$0.50 ceilings are not retained; configure any limits you require explicitly.
|
|
260
|
+
|
|
261
|
+
| Environment variable | Default | Meaning |
|
|
262
|
+
|---|---:|---|
|
|
263
|
+
| `APTLY_MAX_DAILY_CALLS` | `200` | Per-ledger UTC daily classification-attempt ceiling |
|
|
264
|
+
| `APTLY_MAX_TOTAL_CALLS` | `0` | Per-ledger cumulative attempt ceiling |
|
|
265
|
+
| `APTLY_MAX_ESTIMATED_USD` | `0` | Cumulative local reservation ceiling |
|
|
266
|
+
| `APTLY_ESTIMATED_CALL_USD` | `0.002` | Estimated dollars reserved for each new classification attempt |
|
|
267
|
+
|
|
268
|
+
Zero means unlimited for the three ceilings. The per-attempt reservation is a rate and must stay positive. Only literal `0` means unlimited; forms such as `0.0` and `0.00` are rejected. Unset uses defaults; empty, negative, malformed or exponent notation values are rejected. Calls use whole integers; money uses fixed decimal notation with at most six fractional digits. Maximum finite settings are 100,000 daily calls, 1,000,000 cumulative calls and 100 for monetary values. A finite cost ceiling must cover one reservation. Existing invalid settings are not silently overwritten.
|
|
269
|
+
|
|
270
|
+
```sh
|
|
271
|
+
aptly set env APTLY_MAX_DAILY_CALLS
|
|
272
|
+
aptly set env APTLY_MAX_TOTAL_CALLS
|
|
273
|
+
aptly set env APTLY_MAX_ESTIMATED_USD
|
|
274
|
+
aptly set env APTLY_ESTIMATED_CALL_USD
|
|
275
|
+
aptly budget status --client codex
|
|
276
|
+
aptly budget status --client claude
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Setting commands support `--client codex|claude|all`, hidden input and explicit `--stdin`. Restart MCP after changes. Defaults also preserve existing Codex budget passthrough bindings in `env_vars` and Claude budget values observed in this CLI process environment, listed as `inherited`. Direct `recommend`/`capabilities` use the CLI process environment and do not automatically read host settings files. Status briefly holds the existing gate, so a concurrent request can receive temporary `ledger_locked`. Status is a snapshot of registration and permitted current environment settings, not verification of custom wrappers or the running host. It reads no keys, API or task text and creates no ledger or gate. Unlimited ceilings display `Unlimited` with `null` remaining. Sessions sharing a ledger share its budget; other ledgers and account-wide OpenAI usage are not aggregated.
|
|
280
|
+
|
|
281
|
+
`budget_exhausted` is local, not an OpenAI authentication or account-credit error. Direct/retry responses identify `budget_limit`; status lists `exhausted_by`. Reservations are not an actual billing cap and do not reset monthly. Changing the rate does not reprice past reservations; replacing a key or applying defaults does not refund them.
|
|
282
|
+
|
|
283
|
+
New pre-HTTP budget denials are not cached. Only verifiable known-unpaid legacy default-policy denials can be reevaluated with the same ID; completed recommendations, abstentions, context outcomes and `unknown` remain protected. Budget recovery does not extend the original five-minute retry reference or process lifetime and does not remove history or permission constraints. Arbitrary historical custom-policy digests are not guessed; do not bypass conflicts/unknowns with new IDs or ledger deletion.
|
|
284
|
+
|
|
234
285
|
<a id="outbound-data-and-disabling-automatic-sharing"></a>
|
|
235
286
|
|
|
236
287
|
### Decisions API transmission scope
|
package/docs/guide/ja.md
CHANGED
|
@@ -59,6 +59,23 @@ aptly --version
|
|
|
59
59
|
|
|
60
60
|
公開 npm レジストリから Aptly のバージョン情報のみを取得し、キー・タスク要約・ホスト設定は送信しません。ネットワークと応答読み取りは 800ms・16KiB に制限し、結果を `~/.cache/aptly/update-check.json` に 24 時間キャッシュします。失敗後は 1 時間待機し、通信・キャッシュエラーで元のコマンドを失敗させません。CLI の環境に `APTLY_NO_UPDATE_NOTIFIER=1` を設定すると確認を停止できます。この変数は `aptly set env` の対象ではありません。通知による自動更新は行いません。
|
|
61
61
|
|
|
62
|
+
<a id="command-help"></a>
|
|
63
|
+
|
|
64
|
+
### コマンドヘルプ(0.1.8 以降)
|
|
65
|
+
|
|
66
|
+
コマンド・サブコマンドごとの統一されたヘルプは Aptly 0.1.8 以降で利用できます。次の形式を使えます。
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
aptly --help
|
|
70
|
+
aptly setup -h
|
|
71
|
+
aptly set default --help
|
|
72
|
+
aptly set env OPENAI_API_KEY --help
|
|
73
|
+
aptly budget status --help
|
|
74
|
+
aptly help catalog refresh
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`--help`・`-h`・`aptly help <コマンド経路>` は使用法だけを表示します。設定・指定ファイル・stdin・資格情報ストアの読み取り、質問、設定変更、API・モデル情報取得、インストール・更新、更新通知は実行しません。有効なオプションの後にもヘルプを付けられますが、不明な経路・オプション、不正な指定値、矛盾する組み合わせはエラーです。必須の位置引数を省略して使用法を調べられます。`--output --help` のようにヘルプをオプション値の位置に置くと、値の欠落として扱います。
|
|
78
|
+
|
|
62
79
|
### CLI による設定
|
|
63
80
|
|
|
64
81
|
`set` コマンドは 0.1.1 以降で利用できます。既存の起動パスは自動で切り替えません。API キー設定は、現在のパッケージの標準 Node/サーバー登録で、OS 資格情報の参照に対応する実行環境だと確認できた場合にのみ使用できます。独自ラッパー、旧バージョン、別のインストール先は `credential_launcher_unverified` で拒否します。登録を明示的に切り替えるかアップグレードしてから、再度実行してください。
|
|
@@ -97,7 +114,9 @@ API キーは macOS Keychain、インストール済みの Linux `secret-tool`
|
|
|
97
114
|
|
|
98
115
|
以下のオプションは Aptly 0.1.2 以降で利用でき、npm 0.1.1 には含まれません。ソースから試す場合は `npm ci --ignore-scripts` と `npm run build` を実行し、以下の `aptly` を `node bin/aptly.ts` に置き換えます。
|
|
99
116
|
|
|
100
|
-
キー設定は入力・保存前に対象ホストを診断します。いずれかが失敗すると入力を求めず、全ホストを変更しません。`--check`
|
|
117
|
+
キー設定は入力・保存前に対象ホストを診断します。いずれかが失敗すると入力を求めず、全ホストを変更しません。`--check` はキーや資格情報ストアにアクセスしません。
|
|
118
|
+
|
|
119
|
+
Aptly 0.1.9 以降、Linux の `--check` は実行可能な `secret-tool` も確認し、安全な明示的セッションバスアドレスと `gdbus` がある場合、資格情報サービスを起動・アクセスせずにバスメタデータを読み取ります。確実な失敗は入力前に `secure_store_unavailable` と `secure_store_secret_tool_missing`、`secure_store_bus_missing`、`secure_store_service_missing` のいずれかで通知します。`secure_store_bus_unverified`、`secure_store_probe_unavailable`、サービスの存在・起動可能を示す未確認コードは準備状態が不明であることを意味します。サービスの存在や起動可能性はロック解除や書き込み可能を保証しません。必要に応じて `secret-tool` と Secret Service プロバイダーをインストールし、使用するデスクトップセッションで実行してください。実際の保存は失敗する場合があります。SSH やヘッドレスセッションでは、`APTLY_SECRET_BACKEND` がない場合に `OPENAI_API_KEY` をホスト MCP プロセスへ安全に渡してください。既存の認証ラッパーや環境は保持してください。`credential_node_mismatch`、`credential_server_mismatch`、`credential_runtime_unsupported` はそれぞれ Node パス、サーバーパス、OS ストア対応の不一致を示します。
|
|
101
120
|
|
|
102
121
|
Claude だけが失敗した場合は次の順序で診断し、`launcher_migration_available` の場合にのみ移行を検討してください。
|
|
103
122
|
|
|
@@ -110,6 +129,8 @@ aptly set env OPENAI_API_KEY --client claude
|
|
|
110
129
|
|
|
111
130
|
`--dry-run` は変更しません。移行は所有記録と一致する Aptly の標準登録に限り、Node・サーバーパスを現在のビルドへ更新します。環境設定・Hook・ポリシー・他のホストを保持し、資格情報へのアクセスや古い起動プログラムの実行は行いません。独自ラッパー、所有記録のない登録、変更済みの登録は拒否します。その場合は登録をローカルで確認し、ラッパーの安全な環境変数受け渡しを使うか、別途確認した標準登録へ切り替えてください。検証を回避するために所有記録を編集・削除しないでください。
|
|
112
131
|
|
|
132
|
+
Aptly 0.1.9 以降、`aptly setup --check --client codex|claude|all` は通常の設定計画を読み取るだけで、ファイルやディレクトリを作成しません。実行中のホストを検証するものではなく、確認時点の状態を示します。`--check` と組み合わせられるのは `--client` のみです。`hook_policy_path_conflict` が表示された場合は、選択したホスト設定ディレクトリと既存のポリシー参照をローカルで確認し、意図したホストディレクトリを選択してから再試行してください。設定は既存の構成を保持し、ポリシーを移動またはコピーしません。ランチャーの移行ではこの不一致を解決できません。
|
|
133
|
+
|
|
113
134
|
`launcher_migration_not_owned` が既存の登録を保持した状態(`mcp_created: false`)を指す場合、**Aptly 0.1.3 以降では** `--include-existing` を明示して移行できます。0.1.3 以降をインストールし、次を実行してください。
|
|
114
135
|
|
|
115
136
|
```sh
|
|
@@ -231,6 +252,36 @@ Codex の本文が不透明な場合、`cleanup_merged_worktrees` のような
|
|
|
231
252
|
|
|
232
253
|
`confidence` はメタデータであり、校正された正解確率としては検証されていません。現在、自動適用の閾値としては使用しません。現在は他の適用条件を満たせば、0 や低い値も許容します。実際の Decisions 応答で値が欠けている場合はエラーとして拒否しますが、汎用 Router と保存結果では任意項目です。`keep_current` と `needs_context` は数値とは別の結果であり、既存の保留・文脈補足規則に従います。明示されたモデル・effort・履歴・権限は保持します。小規模な分類評価だけで、子タスクの品質や総費用の改善を主張しません。
|
|
233
254
|
|
|
255
|
+
<a id="budget-limits"></a>
|
|
256
|
+
|
|
257
|
+
### 予算上限と使用量(0.1.8 以降)
|
|
258
|
+
|
|
259
|
+
予算環境設定と使用量照会は Aptly 0.1.8 以降で利用できます。`aptly set default` は選択したホストの未設定の予算環境変数も補います。予算に関する追加の質問はなく、明示的な `0` を含む既存値を保持し、使用量・台帳・キャッシュをリセットしません。既存の送信範囲の質問は別です。予算変数がない既存登録も、アップグレード後は新しいランタイム既定値を使います。従来の暗黙の 20 回・50 回・$0.50 の上限は維持されないため、必要な上限を明示的に設定してください。
|
|
260
|
+
|
|
261
|
+
| 環境変数 | 既定値 | 意味 |
|
|
262
|
+
|---|---:|---|
|
|
263
|
+
| `APTLY_MAX_DAILY_CALLS` | `200` | 台帳ごとの UTC 日次分類試行上限 |
|
|
264
|
+
| `APTLY_MAX_TOTAL_CALLS` | `0` | 台帳ごとの累積分類試行上限 |
|
|
265
|
+
| `APTLY_MAX_ESTIMATED_USD` | `0` | 累積ローカル予約額の上限 |
|
|
266
|
+
| `APTLY_ESTIMATED_CALL_USD` | `0.002` | 新しい分類試行ごとに予約する推定ドル額 |
|
|
267
|
+
|
|
268
|
+
三つの上限では `0` が無制限を意味します。試行ごとの予約単価は上限ではないため正数が必要です。無制限には厳密な `0` を使い、`0.0` や `0.00` は拒否します。未設定なら既定値を使い、空文字・負数・不正な数値・指数表記は拒否します。呼び出し数は整数、金額は小数点以下最大 6 桁の十進表記です。有限値の上限は日次 100,000 回・累積 1,000,000 回・金額設定 100 です。有限の金額上限は 1 回分の予約額以上である必要があります。既存の不正な値を自動で置き換えません。
|
|
269
|
+
|
|
270
|
+
```sh
|
|
271
|
+
aptly set env APTLY_MAX_DAILY_CALLS
|
|
272
|
+
aptly set env APTLY_MAX_TOTAL_CALLS
|
|
273
|
+
aptly set env APTLY_MAX_ESTIMATED_USD
|
|
274
|
+
aptly set env APTLY_ESTIMATED_CALL_USD
|
|
275
|
+
aptly budget status --client codex
|
|
276
|
+
aptly budget status --client claude
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
設定コマンドは `--client codex|claude|all`、非表示入力と明示的な `--stdin` に対応します。変更後は MCP を再起動してください。既存の Codex `env_vars` による予算変数の転送設定と、この CLI 実行環境で確認できる Claude の継承予算値も既定値で隠さず、`inherited` に表示します。直接の `recommend`・`capabilities` は CLI プロセスの環境を使い、ホスト設定ファイルを自動参照しません。状態照会は既存 gate を短時間占有するため、同時要求では一時的に `ledger_locked` が返る場合があります。状態は登録と許可された現在の環境のスナップショットであり、独自ラッパーや実行中ホストの値を認証しません。キー・API・タスク原文を参照せず、台帳や gate を作成しません。無制限は `Unlimited`、残量は `null` で表示します。同じ台帳を使うセッションは予算を共有しますが、他の台帳や OpenAI アカウント全体の使用量は合算しません。
|
|
280
|
+
|
|
281
|
+
`budget_exhausted` はローカル制限であり、OpenAI 認証や残高のエラーではありません。直接推薦・文脈補足の応答の `budget_limit` と状態の `exhausted_by` で上限を区別します。予約額は実際の請求上限ではなく、月次で自動リセットしません。単価変更で過去の予約を再計算せず、キー再入力や既定値適用で返金しません。
|
|
282
|
+
|
|
283
|
+
HTTP 前の新しい予算拒否はキャッシュしません。検証可能な既存の既定ポリシーによる未課金の拒否だけを同じ ID で再評価し、完了した推薦・保留・文脈不足の結果と `unknown` は保持します。予算回復は元の retry 参照の 5 分やプロセス寿命を延長せず、履歴や権限の制約も解除しません。任意の過去の独自ポリシーの digest を推測せず、新しい ID や台帳削除で競合・不明結果を回避しないでください。
|
|
284
|
+
|
|
234
285
|
<a id="外部送信と自動共有の無効化"></a>
|
|
235
286
|
|
|
236
287
|
### Decisions API への送信範囲
|
package/docs/guide/ko.md
CHANGED
|
@@ -59,6 +59,23 @@ aptly --version
|
|
|
59
59
|
|
|
60
60
|
공개 npm 레지스트리의 Aptly 버전 메타데이터만 조회하며 키·작업 요약·호스트 설정은 보내지 않습니다. 네트워크와 응답 읽기는 최대 800ms·16KiB로 제한하고, 결과는 `~/.cache/aptly/update-check.json`에 24시간 캐시합니다. 실패 후에는 1시간 대기하며, 조회·캐시 오류로 원래 명령을 실패시키지 않습니다. 버전 조회를 끄려면 CLI 실행 환경에 `APTLY_NO_UPDATE_NOTIFIER=1`을 설정하십시오. 이 변수는 MCP 키 설정용 `aptly set env`의 지원 대상이 아닙니다. 알림은 업데이트를 설치하지 않습니다.
|
|
61
61
|
|
|
62
|
+
<a id="command-help"></a>
|
|
63
|
+
|
|
64
|
+
### 명령 도움말 (0.1.8부터)
|
|
65
|
+
|
|
66
|
+
명령·하위 명령별 통일된 도움말은 Aptly 0.1.8부터 지원합니다. 다음 형식을 사용할 수 있습니다.
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
aptly --help
|
|
70
|
+
aptly setup -h
|
|
71
|
+
aptly set default --help
|
|
72
|
+
aptly set env OPENAI_API_KEY --help
|
|
73
|
+
aptly budget status --help
|
|
74
|
+
aptly help catalog refresh
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`--help`·`-h` 또는 `aptly help <명령 경로>`는 사용법만 표시합니다. 설정·지정 파일·stdin·자격 저장소를 읽거나 질문·설정 변경·API/모델 정보 조회·설치/업데이트·업데이트 알림을 실행하지 않습니다. 유효한 옵션 뒤에도 도움말을 붙일 수 있지만 잘못된 경로·옵션·제공된 값과 모순된 옵션 조합은 오류입니다. 필수 위치 인자를 생략해 사용법을 조회할 수 있습니다. `--output --help`처럼 도움말을 옵션 값 자리에 놓으면 값 누락 오류로 처리합니다.
|
|
78
|
+
|
|
62
79
|
### CLI로 설정하기
|
|
63
80
|
|
|
64
81
|
`set` 명령은 0.1.1부터 지원합니다. 명령은 기존 실행 경로를 자동 전환하지 않습니다. API 키 설정은 현재 패키지의 표준 Node/서버 등록과 OS 자격 저장소 참조 지원이 확인된 실행 경로에만 허용됩니다. 사용자 지정 래퍼·구버전·다른 설치 위치는 `credential_launcher_unverified`로 거절하며, 등록을 명시적으로 전환하거나 업그레이드한 뒤 다시 실행해야 합니다.
|
|
@@ -97,7 +114,9 @@ API 키는 macOS Keychain, Linux의 설치된 `secret-tool`, 또는 Windows Cred
|
|
|
97
114
|
|
|
98
115
|
아래 옵션은 Aptly 0.1.2부터 지원하며 npm 0.1.1에는 없습니다. 소스에서 시험하려면 `npm ci --ignore-scripts`와 `npm run build` 후 `aptly` 대신 `node bin/aptly.ts`를 사용합니다.
|
|
99
116
|
|
|
100
|
-
키 설정은 입력·저장 전에 선택한 호스트를 진단합니다. 하나라도 실패하면 입력을 받지 않고 모든 호스트를 그대로 둡니다. `--check`는 키나 자격 저장소에 접근하지 않습니다.
|
|
117
|
+
키 설정은 입력·저장 전에 선택한 호스트를 진단합니다. 하나라도 실패하면 입력을 받지 않고 모든 호스트를 그대로 둡니다. `--check`는 키나 자격 저장소에 접근하지 않습니다.
|
|
118
|
+
|
|
119
|
+
Aptly 0.1.9부터 Linux에서 `--check`는 실행 가능한 `secret-tool`도 확인하고, 안전한 명시적 세션 버스 주소와 `gdbus`가 있으면 자격 증명 서비스를 활성화하거나 접근하지 않고 버스 메타데이터를 읽습니다. 확실한 실패는 입력 전에 `secure_store_unavailable`과 함께 `secure_store_secret_tool_missing`, `secure_store_bus_missing`, `secure_store_service_missing` 중 하나로 알립니다. `secure_store_bus_unverified`, `secure_store_probe_unavailable` 및 서비스 존재·활성화 가능 미확인 코드는 준비 상태를 알 수 없다는 뜻이며, 서비스가 실행 중이거나 활성화 가능해도 잠금 해제 또는 쓰기 가능을 보장하지 않습니다. 필요한 경우 `secret-tool`과 Secret Service 제공자를 설치하고 사용할 데스크톱 세션에서 실행하십시오. 실제 저장은 여전히 실패할 수 있습니다. SSH 또는 헤드리스 세션에서는 `APTLY_SECRET_BACKEND`가 없는 경우 호스트 MCP 프로세스에 `OPENAI_API_KEY`를 안전하게 전달하십시오. 기존 인증 래퍼나 환경은 보존하십시오. `credential_node_mismatch`, `credential_server_mismatch`, `credential_runtime_unsupported`는 각각 Node 경로, 서버 경로, OS 저장소 지원의 불일치입니다.
|
|
101
120
|
|
|
102
121
|
Claude만 실패했다면 다음 순서로 진단하고, `launcher_migration_available`일 때만 이전을 검토하십시오:
|
|
103
122
|
|
|
@@ -110,6 +129,8 @@ aptly set env OPENAI_API_KEY --client claude
|
|
|
110
129
|
|
|
111
130
|
`--dry-run`은 변경하지 않습니다. 이전 명령은 소유 기록과 일치하는 Aptly 표준 등록의 Node·서버 경로를 현재 빌드로 바꿉니다. 기존 환경·Hook·정책·다른 호스트는 보존하며 키를 읽거나 저장하지 않습니다. 오래된 실행 파일을 실행하지 않습니다. 사용자 래퍼, 소유 기록이 없거나 수정된 등록은 거절합니다. 이 경우 로컬에서 등록을 검토하고 래퍼의 안전한 환경 전달을 사용하거나 별도로 검토한 표준 등록으로 전환하십시오. 소유 기록을 삭제하거나 편집해 검증을 우회하지 마십시오.
|
|
112
131
|
|
|
132
|
+
Aptly 0.1.9부터 `aptly setup --check --client codex|claude|all`은 일반 설정 계획을 읽기만 하며 파일이나 디렉터리를 만들지 않습니다. 실행 중인 호스트를 검증하지 않는 시점별 확인입니다. `--check`에는 `--client`만 함께 사용할 수 있습니다. `hook_policy_path_conflict`가 나타나면 선택된 호스트 설정 디렉터리와 기존 정책 참조를 로컬에서 확인하고, 의도한 호스트 디렉터리를 선택한 뒤 다시 시도하십시오. 설정은 기존 구성을 보존하며 정책을 이동하거나 복사하지 않습니다. 실행기 이전으로 이 불일치를 해결할 수는 없습니다.
|
|
133
|
+
|
|
113
134
|
`launcher_migration_not_owned`가 나오고 기존 등록을 보존한 상태(`mcp_created: false`)라면, **Aptly 0.1.3부터** `--include-existing`으로 명시적으로 이전할 수 있습니다. 0.1.3 이상을 설치한 뒤 다음 명령을 실행하십시오:
|
|
114
135
|
|
|
115
136
|
```sh
|
|
@@ -231,6 +252,36 @@ Codex 본문이 불투명할 때 `cleanup_merged_worktrees`처럼 구체적인
|
|
|
231
252
|
|
|
232
253
|
`confidence`는 메타데이터이며 보정된 정답 확률로 검증되지 않았습니다. 현재 자동 적용 임계값으로 사용하지 않습니다. 현재 0과 낮은 값도 다른 적용 조건을 만족하면 허용합니다. 실제 Decisions 응답에서 값이 누락되면 오류로 거절하지만, 일반 Router·저장 결과에서는 선택 항목입니다. `keep_current`·`needs_context`는 숫자와 별개의 결과이며 기존 보류·문맥 보충 규칙을 따릅니다. 명시한 모델·effort·이력·권한은 보존합니다. 소규모 분류 평가만으로 자식 작업의 품질·총비용 개선을 주장하지 않습니다.
|
|
233
254
|
|
|
255
|
+
<a id="budget-limits"></a>
|
|
256
|
+
|
|
257
|
+
### 예산 한도와 사용량 (0.1.8부터)
|
|
258
|
+
|
|
259
|
+
예산 환경변수와 사용량 조회는 Aptly 0.1.8부터 지원합니다. `aptly set default`는 선택한 호스트의 누락된 예산 환경변수도 추가합니다. 추가 예산 질문 없이 기존 값과 명시한 `0`을 보존하며 사용량·원장·캐시를 리셋하지 않습니다. API 전송 범위를 선택하는 기존 질문은 별개입니다. 예산 변수가 없는 기존 등록도 업그레이드 후 새 런타임 기본값을 사용합니다. 이전의 암묵적 20회/50회/$0.50 제한은 유지되지 않으므로 필요한 상한은 명시적으로 설정하십시오.
|
|
260
|
+
|
|
261
|
+
| 환경변수 | 기본값 | 의미 |
|
|
262
|
+
|---|---:|---|
|
|
263
|
+
| `APTLY_MAX_DAILY_CALLS` | `200` | 원장별 UTC 일일 분류 시도 상한 |
|
|
264
|
+
| `APTLY_MAX_TOTAL_CALLS` | `0` | 원장별 누적 분류 시도 상한 |
|
|
265
|
+
| `APTLY_MAX_ESTIMATED_USD` | `0` | 누적 로컬 비용 예약액 상한 |
|
|
266
|
+
| `APTLY_ESTIMATED_CALL_USD` | `0.002` | 새 분류 시도마다 예약할 추정 달러 금액 |
|
|
267
|
+
|
|
268
|
+
세 상한에서 `0`은 무제한입니다. 회당 예약 단가는 상한이 아니므로 양수여야 합니다. 무제한은 정확한 `0`만 사용하고 `0.0`·`0.00` 같은 표기는 거절합니다. 미설정은 기본값을 사용하며 빈 값·음수·비정상 숫자·지수 표기는 거절합니다. 호출 수는 정수, 금액은 소수점 이하 최대 6자리의 십진수입니다. 일일 호출 수의 최대 유한값은 100,000, 누적은 1,000,000이며 금액 설정의 최대 유한값은 100입니다. 유한 금액 상한은 회당 예약액 이상이어야 합니다. 기존에 잘못 설정한 값은 조용히 덮어쓰지 않습니다.
|
|
269
|
+
|
|
270
|
+
```sh
|
|
271
|
+
aptly set env APTLY_MAX_DAILY_CALLS
|
|
272
|
+
aptly set env APTLY_MAX_TOTAL_CALLS
|
|
273
|
+
aptly set env APTLY_MAX_ESTIMATED_USD
|
|
274
|
+
aptly set env APTLY_ESTIMATED_CALL_USD
|
|
275
|
+
aptly budget status --client codex
|
|
276
|
+
aptly budget status --client claude
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
설정 명령은 `--client codex|claude|all`과 기존 숨김 입력·명시적 `--stdin`을 지원합니다. 변경 후 MCP를 재시작하십시오. Codex의 기존 `env_vars` 예산 전달 설정과 이 CLI 실행 환경에서 관찰된 Claude 상속 예산값도 기본값으로 가리지 않습니다. `inherited`에 보존한 항목을 표시합니다. 직접 `recommend`·`capabilities`는 해당 CLI의 환경변수를 사용하고 호스트 설정 파일을 자동으로 읽지 않습니다. 상태 조회는 기존 gate를 잠시 점유하므로 동시에 실행한 요청은 일시적 `ledger_locked`를 받을 수 있습니다. 상태는 등록된 설정과 허용된 현재 환경의 스냅샷이며, 사용자 래퍼나 실제 실행 중 프로세스의 값을 인증하지 않습니다. 키·API·작업 원문을 조회하지 않으며 원장이나 잠금 파일을 만들지 않습니다. 무제한은 `Unlimited`, 잔여 한도는 `null`로 표시합니다. 여러 세션이 같은 원장을 쓰면 예산을 공유하지만 다른 원장이나 OpenAI 계정 전체 사용량은 합산하지 않습니다.
|
|
280
|
+
|
|
281
|
+
`budget_exhausted`는 로컬 제한이며 OpenAI 인증·청구 잔액 오류가 아닙니다. 직접 추천·문맥 보충 응답의 `budget_limit`과 상태의 `exhausted_by`가 소진 항목을 구분합니다. 예약액은 실제 청구 상한이 아니며 월별로 자동 초기화하지 않습니다. 단가 변경은 과거 예약을 다시 계산하지 않고 키 재입력·기본값 적용도 예약을 환불하지 않습니다.
|
|
282
|
+
|
|
283
|
+
새 HTTP 전 예산 거절은 캐시하지 않습니다. 검증 가능한 기존 기본 정책의 미지불 거절만 같은 ID로 다시 평가하며, 성공·보류·문맥 부족의 완료 결과와 `unknown`은 유지합니다. 한도 회복은 원래 retry 참조의 5분 만료나 프로세스 수명을 연장하지 않고 이력·권한 제약도 해제하지 않습니다. 임의의 과거 커스텀 정책 digest를 추측해 재사용하지 않으며 충돌·불명 결과를 새 ID나 원장 삭제로 우회하지 마십시오.
|
|
284
|
+
|
|
234
285
|
<a id="외부-전송과-자동-공유-끄기"></a>
|
|
235
286
|
|
|
236
287
|
### Decisions API 전송 범위
|