@link-assistant/agent 0.8.16 → 0.8.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/agent",
3
- "version": "0.8.16",
3
+ "version": "0.8.18",
4
4
  "description": "A minimal, public domain AI CLI agent compatible with OpenCode's JSON interface. Bun-only runtime.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -70,7 +70,7 @@ export function createBusEventSubscription({
70
70
  });
71
71
 
72
72
  // If tool failed, also output an error event
73
- if (part.state?.status === 'failed') {
73
+ if (part.state?.status === 'error') {
74
74
  eventHandler.output({
75
75
  type: 'error',
76
76
  timestamp: Date.now(),
package/src/index.js CHANGED
@@ -68,11 +68,16 @@ process.on('uncaughtException', (error) => {
68
68
 
69
69
  process.on('unhandledRejection', (reason, _promise) => {
70
70
  hasError = true;
71
- outputError({
71
+ const errorOutput = {
72
72
  errorType: 'UnhandledRejection',
73
73
  message: reason?.message || String(reason),
74
74
  stack: reason?.stack,
75
- });
75
+ };
76
+ // If the error has a data property with a suggestion (e.g., ProviderModelNotFoundError), add it as a hint
77
+ if (reason?.data?.suggestion) {
78
+ errorOutput.hint = reason.data.suggestion;
79
+ }
80
+ outputError(errorOutput);
76
81
  process.exit(1);
77
82
  });
78
83
 
@@ -909,7 +909,23 @@ export namespace Provider {
909
909
  log.info(() => ({ message: 'getModel', providerID, modelID }));
910
910
 
911
911
  const provider = s.providers[providerID];
912
- if (!provider) throw new ModelNotFoundError({ providerID, modelID });
912
+ if (!provider) {
913
+ // Check if this model ID might exist in another provider (e.g., OpenRouter)
914
+ // This helps users who use formats like "z-ai/glm-4.7" instead of "openrouter/z-ai/glm-4.7"
915
+ const fullModelKey = `${providerID}/${modelID}`;
916
+ let suggestion: string | undefined;
917
+
918
+ for (const [knownProviderID, knownProvider] of Object.entries(
919
+ s.providers
920
+ )) {
921
+ if (knownProvider.info.models[fullModelKey]) {
922
+ suggestion = `Did you mean: ${knownProviderID}/${fullModelKey}?`;
923
+ break;
924
+ }
925
+ }
926
+
927
+ throw new ModelNotFoundError({ providerID, modelID, suggestion });
928
+ }
913
929
 
914
930
  // For synthetic providers (like link-assistant/echo and link-assistant/cache), skip SDK loading
915
931
  // These providers have a custom getModel function that creates the model directly
@@ -1077,6 +1093,7 @@ export namespace Provider {
1077
1093
  z.object({
1078
1094
  providerID: z.string(),
1079
1095
  modelID: z.string(),
1096
+ suggestion: z.string().optional(),
1080
1097
  })
1081
1098
  );
1082
1099
 
@@ -188,7 +188,7 @@ export namespace SessionProcessor {
188
188
  await Session.updatePart({
189
189
  ...match,
190
190
  state: {
191
- status: 'failed',
191
+ status: 'error',
192
192
  input: value.input,
193
193
  error: (value.error as any).toString(),
194
194
  metadata: undefined,
@@ -377,13 +377,13 @@ export namespace SessionProcessor {
377
377
  if (
378
378
  part.type === 'tool' &&
379
379
  part.state.status !== 'completed' &&
380
- part.state.status !== 'failed'
380
+ part.state.status !== 'error'
381
381
  ) {
382
382
  await Session.updatePart({
383
383
  ...part,
384
384
  state: {
385
385
  ...part.state,
386
- status: 'failed',
386
+ status: 'error',
387
387
  error: 'Tool execution aborted',
388
388
  time: {
389
389
  start: Date.now(),