zam-core 0.4.3 → 0.4.4

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/index.d.ts CHANGED
@@ -120,6 +120,14 @@ interface ADOCredentials {
120
120
  interface Credentials {
121
121
  turso?: Partial<TursoCredentials>;
122
122
  ado?: Partial<ADOCredentials>;
123
+ /**
124
+ * API keys for named LLM providers, keyed by the provider's reference name
125
+ * (the `apiKeyRef` in the `llm.providers` setting). Kept here — not in the
126
+ * database — so workspace exports / DB snapshots never carry provider keys.
127
+ */
128
+ llmProviders?: Record<string, {
129
+ apiKey: string;
130
+ }>;
123
131
  }
124
132
  /** Load credentials from ~/.zam/credentials.json. Returns empty object if missing. */
125
133
  declare function loadCredentials(path?: string): Credentials;
@@ -137,6 +145,14 @@ declare function getADOCredentials(path?: string): ADOCredentials | null;
137
145
  declare function setADOCredentials(orgUrl: string, project: string, pat: string, path?: string): void;
138
146
  /** Clear ADO credentials. */
139
147
  declare function clearADOCredentials(path?: string): void;
148
+ /** Get a named LLM provider's API key (by `apiKeyRef`), or null if unset. */
149
+ declare function getProviderApiKey(name: string, path?: string): string | null;
150
+ /** Store a named LLM provider's API key (referenced by `apiKeyRef`). */
151
+ declare function setProviderApiKey(name: string, apiKey: string, path?: string): void;
152
+ /** Remove a named LLM provider's stored API key. No-op if it was unset. */
153
+ declare function clearProviderApiKey(name: string, path?: string): void;
154
+ /** List the reference names (`apiKeyRef`) that currently have a stored key. */
155
+ declare function listProviderApiKeyRefs(path?: string): string[];
140
156
 
141
157
  /**
142
158
  * - `local`: better-sqlite3 file database (default without cloud credentials)
@@ -1892,4 +1908,4 @@ declare function resolveAllBeliefPaths(db: Database): Promise<string[]>;
1892
1908
  */
1893
1909
  declare function resolveAllGoalPaths(db: Database): Promise<string[]>;
1894
1910
 
1895
- export { type ADOConfig, type ADOCredentials, type AgentSkill, type AnalysisResult, type ApplySessionSynthesisInput, type ApplySessionSynthesisResult, BUILT_IN_SENSITIVE_MATCHERS, type BloomLevel$1 as BloomLevel, type CaptureDecision, type CaptureDenialReason, type CaptureRequest, type Card, type CardDeletionImpact, type CardState$1 as CardState, type CascadeBlockResult, type CommandRecord, type CommandSequence, type ConnectionOptions, type CreateAgentSkillInput, type CreateGoalInput, type CreateReviewInput, type CreateSessionInput, type CreateTokenInput, type Credentials, DEFAULT_OBSERVER_POLICY, DEFAULT_REVIEW_CONTEXT_MAX_CHARS, type Database, type DatabaseProvider, type DatabaseTargetInfo, type DatabaseValue, type DeleteCardResult, type DeleteTokenResult, type DiscoveryOptions, type DomainCompetence, type EvaluateInput, type EvaluateResult, type ExecuteReviewActionInput, type ExecutionContext, type FSRSParameters, type Goal, type GoalFrontmatter, type GoalStatus, type GoalSummary, HOMEBREW_CASK, type ImportResult, type InstallChannel, type InstallConfig, type InstallMode, type InstallPlan, type InstallResult, type LocalLLMRunner, type LogStepInput, type MonitorEvent, type Neighborhood, type NeighborhoodToken, OBSERVER_POLICY_UNSET_HINT, OBSERVER_POLICY_VERSION, type ObservationRating, type ObserverConsent, type ObserverPolicy, type ObserverRetention, type ObserverScope, type ObserverSettingKey, type PrepareSessionSynthesisInput, type Prerequisite, type PrerequisiteWithToken, type PromptInput, type Rating, type RecallPrompt, type RemoteDatabaseOptions, type RepoPaths, type ResolvedCaptureTarget, type ResolvedReference, type ReviewActionResult, type ReviewActionType, type ReviewContext, type ReviewLog, type ReviewQueue, type ReviewQueueItem, type ReviewQueueOptions, type RunResult, SIDECAR_POLICY_FILE, SNAPSHOT_VERSION, type SchedulingCard, type Session, type SessionStep, type SessionSummary, type SessionSynthesisCandidate, type SessionSynthesisEvidence, type SessionSynthesisPreview, type SessionSynthesisRecord, type SidecarPrivacyPolicy, type SkillProposal, type SkillSource, type SnapshotManifest, type Statement, type SupportedLocale, type SymbiosisMode, type SynthesisConfidence, type SystemProfile, type Token, type TokenDeleteImpact, type TokenPattern, type TranslationKey, type TursoCredentials, UI_OBSERVATION_PROTOCOL_VERSION, type UiActionType, type UiApplicationContext, type UiCandidateToken, type UiEvidenceRef, type UiEvidenceType, type UiObservationKind, type UiObservationReport, type UiObservedAction, type UnblockResult, type UpdateActionKind, type UpdateCardInput, type UpdateDecision, type UpdateStep, type UpdateStepKind, type UpdateTokenInput, type UserSetting, type UserStats, WINGET_PACKAGE_ID, type WorkItem, addPrerequisite, analyzeObservation, appendUiObservationReport, applySessionSynthesis, buildReviewQueue, buildUiSynthesisCandidates, cascadeBlock, clearADOCredentials, clearTursoCredentials, compareVersions, createAgentSkill, createFSRS, createGoal, createToken, decidePostCapture, decidePreCapture, decideUpdate, deleteCardForUser, deleteSetting, deleteToken, deprecateToken, detectSyncProvider, detectSystemLocale, discoverSkills, distributeGlobalSkills, endSession, ensureCard, ensureMonitorDir, ensureUiObserverDir, evaluateRating, executeReviewAction, exportSnapshot, extractTasks, extractTokenRefs, fetchActiveWorkItems, findTokens, generateBashHooks, generateBashUnhooks, generateConceptFreeCue, generatePowerShellHooks, generatePowerShellUnhooks, generatePrompt, generateZshHooks, generateZshUnhooks, getADOCredentials, getAgentSkill, getAllSettings, getAllSettingsDetailed, getBlockedCards, getCard, getCardById, getCardDeletionImpact, getDatabaseTargetInfo, getDefaultDbPath, getDependents, getDomainCompetence, getDueCards, getGoal, getGoalTree, getInstallChannel, getInstallMode, getMonitorDir, getMonitorLogStats, getMonitorPath, getPackageSkillPath, getPrerequisites, getRepoPaths, getReviewsForCard, getReviewsForUser, getSessionSummary, getSessionSynthesisRecords, getSetting, getSystemProfile, getTokenById, getTokenBySlug, getTokenDeleteImpact, getTokenNeighborhood, getTursoCredentials, getUiObservationPath, getUiObserverDir, getUserStats, hasCommand, importSnapshot, injectShellHooks, installFastFlowLM, installOllama, installOpenCode, interleave, isObserverPolicyConfigured, isUiObservationReport, listAgentSkills, listGoals, listTokens, loadADOConfig, loadCredentials, loadInstallConfig, logReview, logStep, matchBuiltInSensitive, matchDenylist, matchesFilePath, monitorLogExists, normalizeLocale, normalizePath, openDatabase, openDatabaseWithSync, openRemoteDatabase, pairCommands, parseGoalFile, parseMonitorLog, parseObserverList, parseObserverPolicy, parseSnapshot, parseUiObservationLog, planOpenCodeInstall, planUpdate, prepareLocalModel, prepareSessionSynthesis, readMonitorLog, readUiObservationLog, resolveAllBeliefPaths, resolveAllGoalPaths, resolveObserverPolicy, resolveReference, resolveRepoPath, resolveReviewContext, saveCredentials, saveInstallConfig, serializeGoal, setADOCredentials, setInstallChannel, setInstallMode, setSetting, setTursoCredentials, startSession, syncObserverSidecarPolicy, t, toSidecarPrivacyPolicy, uiObservationLogExists, uiObservationTimeSpan, unblockReady, updateCard, updateGoalStatus, updateToken, verifySnapshot, wouldCreateCycle, writeMonitorEvent };
1911
+ export { type ADOConfig, type ADOCredentials, type AgentSkill, type AnalysisResult, type ApplySessionSynthesisInput, type ApplySessionSynthesisResult, BUILT_IN_SENSITIVE_MATCHERS, type BloomLevel$1 as BloomLevel, type CaptureDecision, type CaptureDenialReason, type CaptureRequest, type Card, type CardDeletionImpact, type CardState$1 as CardState, type CascadeBlockResult, type CommandRecord, type CommandSequence, type ConnectionOptions, type CreateAgentSkillInput, type CreateGoalInput, type CreateReviewInput, type CreateSessionInput, type CreateTokenInput, type Credentials, DEFAULT_OBSERVER_POLICY, DEFAULT_REVIEW_CONTEXT_MAX_CHARS, type Database, type DatabaseProvider, type DatabaseTargetInfo, type DatabaseValue, type DeleteCardResult, type DeleteTokenResult, type DiscoveryOptions, type DomainCompetence, type EvaluateInput, type EvaluateResult, type ExecuteReviewActionInput, type ExecutionContext, type FSRSParameters, type Goal, type GoalFrontmatter, type GoalStatus, type GoalSummary, HOMEBREW_CASK, type ImportResult, type InstallChannel, type InstallConfig, type InstallMode, type InstallPlan, type InstallResult, type LocalLLMRunner, type LogStepInput, type MonitorEvent, type Neighborhood, type NeighborhoodToken, OBSERVER_POLICY_UNSET_HINT, OBSERVER_POLICY_VERSION, type ObservationRating, type ObserverConsent, type ObserverPolicy, type ObserverRetention, type ObserverScope, type ObserverSettingKey, type PrepareSessionSynthesisInput, type Prerequisite, type PrerequisiteWithToken, type PromptInput, type Rating, type RecallPrompt, type RemoteDatabaseOptions, type RepoPaths, type ResolvedCaptureTarget, type ResolvedReference, type ReviewActionResult, type ReviewActionType, type ReviewContext, type ReviewLog, type ReviewQueue, type ReviewQueueItem, type ReviewQueueOptions, type RunResult, SIDECAR_POLICY_FILE, SNAPSHOT_VERSION, type SchedulingCard, type Session, type SessionStep, type SessionSummary, type SessionSynthesisCandidate, type SessionSynthesisEvidence, type SessionSynthesisPreview, type SessionSynthesisRecord, type SidecarPrivacyPolicy, type SkillProposal, type SkillSource, type SnapshotManifest, type Statement, type SupportedLocale, type SymbiosisMode, type SynthesisConfidence, type SystemProfile, type Token, type TokenDeleteImpact, type TokenPattern, type TranslationKey, type TursoCredentials, UI_OBSERVATION_PROTOCOL_VERSION, type UiActionType, type UiApplicationContext, type UiCandidateToken, type UiEvidenceRef, type UiEvidenceType, type UiObservationKind, type UiObservationReport, type UiObservedAction, type UnblockResult, type UpdateActionKind, type UpdateCardInput, type UpdateDecision, type UpdateStep, type UpdateStepKind, type UpdateTokenInput, type UserSetting, type UserStats, WINGET_PACKAGE_ID, type WorkItem, addPrerequisite, analyzeObservation, appendUiObservationReport, applySessionSynthesis, buildReviewQueue, buildUiSynthesisCandidates, cascadeBlock, clearADOCredentials, clearProviderApiKey, clearTursoCredentials, compareVersions, createAgentSkill, createFSRS, createGoal, createToken, decidePostCapture, decidePreCapture, decideUpdate, deleteCardForUser, deleteSetting, deleteToken, deprecateToken, detectSyncProvider, detectSystemLocale, discoverSkills, distributeGlobalSkills, endSession, ensureCard, ensureMonitorDir, ensureUiObserverDir, evaluateRating, executeReviewAction, exportSnapshot, extractTasks, extractTokenRefs, fetchActiveWorkItems, findTokens, generateBashHooks, generateBashUnhooks, generateConceptFreeCue, generatePowerShellHooks, generatePowerShellUnhooks, generatePrompt, generateZshHooks, generateZshUnhooks, getADOCredentials, getAgentSkill, getAllSettings, getAllSettingsDetailed, getBlockedCards, getCard, getCardById, getCardDeletionImpact, getDatabaseTargetInfo, getDefaultDbPath, getDependents, getDomainCompetence, getDueCards, getGoal, getGoalTree, getInstallChannel, getInstallMode, getMonitorDir, getMonitorLogStats, getMonitorPath, getPackageSkillPath, getPrerequisites, getProviderApiKey, getRepoPaths, getReviewsForCard, getReviewsForUser, getSessionSummary, getSessionSynthesisRecords, getSetting, getSystemProfile, getTokenById, getTokenBySlug, getTokenDeleteImpact, getTokenNeighborhood, getTursoCredentials, getUiObservationPath, getUiObserverDir, getUserStats, hasCommand, importSnapshot, injectShellHooks, installFastFlowLM, installOllama, installOpenCode, interleave, isObserverPolicyConfigured, isUiObservationReport, listAgentSkills, listGoals, listProviderApiKeyRefs, listTokens, loadADOConfig, loadCredentials, loadInstallConfig, logReview, logStep, matchBuiltInSensitive, matchDenylist, matchesFilePath, monitorLogExists, normalizeLocale, normalizePath, openDatabase, openDatabaseWithSync, openRemoteDatabase, pairCommands, parseGoalFile, parseMonitorLog, parseObserverList, parseObserverPolicy, parseSnapshot, parseUiObservationLog, planOpenCodeInstall, planUpdate, prepareLocalModel, prepareSessionSynthesis, readMonitorLog, readUiObservationLog, resolveAllBeliefPaths, resolveAllGoalPaths, resolveObserverPolicy, resolveReference, resolveRepoPath, resolveReviewContext, saveCredentials, saveInstallConfig, serializeGoal, setADOCredentials, setInstallChannel, setInstallMode, setProviderApiKey, setSetting, setTursoCredentials, startSession, syncObserverSidecarPolicy, t, toSidecarPrivacyPolicy, uiObservationLogExists, uiObservationTimeSpan, unblockReady, updateCard, updateGoalStatus, updateToken, verifySnapshot, wouldCreateCycle, writeMonitorEvent };
package/dist/index.js CHANGED
@@ -190,6 +190,25 @@ function clearADOCredentials(path) {
190
190
  delete creds.ado;
191
191
  saveCredentials(creds, path);
192
192
  }
193
+ function getProviderApiKey(name, path) {
194
+ const key = loadCredentials(path).llmProviders?.[name]?.apiKey;
195
+ return key && key.length > 0 ? key : null;
196
+ }
197
+ function setProviderApiKey(name, apiKey, path) {
198
+ const creds = loadCredentials(path);
199
+ creds.llmProviders = { ...creds.llmProviders, [name]: { apiKey } };
200
+ saveCredentials(creds, path);
201
+ }
202
+ function clearProviderApiKey(name, path) {
203
+ const creds = loadCredentials(path);
204
+ if (creds.llmProviders && name in creds.llmProviders) {
205
+ delete creds.llmProviders[name];
206
+ saveCredentials(creds, path);
207
+ }
208
+ }
209
+ function listProviderApiKeyRefs(path) {
210
+ return Object.keys(loadCredentials(path).llmProviders ?? {});
211
+ }
193
212
 
194
213
  // src/kernel/connectors/azure-devops.ts
195
214
  function loadADOConfig() {
@@ -4756,13 +4775,11 @@ function runCommand(cmd) {
4756
4775
  return "";
4757
4776
  }
4758
4777
  }
4759
- function detectWindowsAMDIPU() {
4778
+ function detectWindowsNPU() {
4760
4779
  if (process.platform !== "win32") return false;
4761
- const cmd = `powershell -NoProfile -Command "Get-CimInstance Win32_PnPEntity | Where-Object { $_.Name -like '*AMD IPU*' -or $_.Name -like '*AMD NPU*' -or $_.Name -like '*NPU Compute*' -or $_.Name -like '*Ryzen AI*' -or $_.HardwareID -like '*VEN_1022&DEV_1502*' -or $_.HardwareID -like '*VEN_1022&DEV_17F0*' } | Select-Object -First 1 -ExpandProperty Name"`;
4780
+ const cmd = `powershell -NoProfile -Command "Get-CimInstance Win32_PnPEntity | Where-Object { $_.PNPClass -eq 'ComputeAccelerator' -or $_.Name -like '*AMD IPU*' -or $_.Name -like '*AMD NPU*' -or $_.Name -like '*Qualcomm*NPU*' -or $_.Name -like '*Hexagon*NPU*' -or $_.Name -like '*Intel*AI Boost*' -or $_.Name -like '*NPU Compute*' -or $_.Name -like '*Ryzen AI*' } | Select-Object -First 1 -ExpandProperty Name"`;
4762
4781
  const output = runCommand(cmd);
4763
- return Boolean(
4764
- output && (output.toLowerCase().includes("amd") || output.toLowerCase().includes("ipu") || output.toLowerCase().includes("npu") || output.toLowerCase().includes("ryzen"))
4765
- );
4782
+ return Boolean(output && output.length > 0);
4766
4783
  }
4767
4784
  function getSystemProfile() {
4768
4785
  const platform = process.platform;
@@ -4774,13 +4791,21 @@ function getSystemProfile() {
4774
4791
  let arch = "unknown";
4775
4792
  if (archStr === "x64") arch = "x64";
4776
4793
  else if (archStr === "arm64") arch = "arm64";
4777
- const hasRyzenNPU = os === "windows" && detectWindowsAMDIPU();
4794
+ const hasNpu = os === "windows" && detectWindowsNPU();
4778
4795
  const hasAppleSilicon = os === "macos" && arch === "arm64";
4779
4796
  let recommendedRunner = "generic";
4780
4797
  let recommendedModel = "qwen3.5:4b";
4781
- if (hasRyzenNPU) {
4782
- recommendedRunner = "fastflowlm";
4783
- recommendedModel = "qwen3.5:4b";
4798
+ if (hasNpu) {
4799
+ const isQualcomm = runCommand(
4800
+ `powershell -NoProfile -Command "Get-CimInstance Win32_PnPEntity | Where-Object { $_.Name -like '*Qualcomm*' } | Select-Object -First 1"`
4801
+ ).length > 0;
4802
+ if (isQualcomm) {
4803
+ recommendedRunner = "generic";
4804
+ recommendedModel = "qwen3.5-4b";
4805
+ } else {
4806
+ recommendedRunner = "fastflowlm";
4807
+ recommendedModel = "qwen3.5:4b";
4808
+ }
4784
4809
  } else if (hasAppleSilicon) {
4785
4810
  recommendedRunner = "ollama";
4786
4811
  recommendedModel = "llama3.2:3b";
@@ -4791,7 +4816,8 @@ function getSystemProfile() {
4791
4816
  return {
4792
4817
  os,
4793
4818
  arch,
4794
- hasRyzenNPU,
4819
+ hasRyzenNPU: hasNpu && !archStr.includes("arm64"),
4820
+ // backwards compatibility flag
4795
4821
  hasAppleSilicon,
4796
4822
  recommendedRunner,
4797
4823
  recommendedModel
@@ -4984,6 +5010,7 @@ export {
4984
5010
  buildUiSynthesisCandidates,
4985
5011
  cascadeBlock,
4986
5012
  clearADOCredentials,
5013
+ clearProviderApiKey,
4987
5014
  clearTursoCredentials,
4988
5015
  compareVersions,
4989
5016
  createAgentSkill,
@@ -5042,6 +5069,7 @@ export {
5042
5069
  getMonitorPath,
5043
5070
  getPackageSkillPath,
5044
5071
  getPrerequisites,
5072
+ getProviderApiKey,
5045
5073
  getRepoPaths,
5046
5074
  getReviewsForCard,
5047
5075
  getReviewsForUser,
@@ -5068,6 +5096,7 @@ export {
5068
5096
  isUiObservationReport,
5069
5097
  listAgentSkills,
5070
5098
  listGoals,
5099
+ listProviderApiKeyRefs,
5071
5100
  listTokens,
5072
5101
  loadADOConfig,
5073
5102
  loadCredentials,
@@ -5108,6 +5137,7 @@ export {
5108
5137
  setADOCredentials,
5109
5138
  setInstallChannel,
5110
5139
  setInstallMode,
5140
+ setProviderApiKey,
5111
5141
  setSetting,
5112
5142
  setTursoCredentials,
5113
5143
  startSession,