@link-assistant/agent 0.0.9 → 0.0.12

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.
Files changed (104) hide show
  1. package/EXAMPLES.md +36 -0
  2. package/MODELS.md +72 -24
  3. package/README.md +59 -2
  4. package/TOOLS.md +20 -0
  5. package/package.json +35 -2
  6. package/src/agent/agent.ts +68 -54
  7. package/src/auth/claude-oauth.ts +426 -0
  8. package/src/auth/index.ts +28 -26
  9. package/src/auth/plugins.ts +876 -0
  10. package/src/bun/index.ts +53 -43
  11. package/src/bus/global.ts +5 -5
  12. package/src/bus/index.ts +59 -53
  13. package/src/cli/bootstrap.js +12 -12
  14. package/src/cli/bootstrap.ts +6 -6
  15. package/src/cli/cmd/agent.ts +97 -92
  16. package/src/cli/cmd/auth.ts +469 -0
  17. package/src/cli/cmd/cmd.ts +2 -2
  18. package/src/cli/cmd/export.ts +41 -41
  19. package/src/cli/cmd/mcp.ts +144 -119
  20. package/src/cli/cmd/models.ts +30 -29
  21. package/src/cli/cmd/run.ts +269 -213
  22. package/src/cli/cmd/stats.ts +185 -146
  23. package/src/cli/error.ts +17 -13
  24. package/src/cli/ui.ts +39 -24
  25. package/src/command/index.ts +26 -26
  26. package/src/config/config.ts +528 -288
  27. package/src/config/markdown.ts +15 -15
  28. package/src/file/ripgrep.ts +201 -169
  29. package/src/file/time.ts +21 -18
  30. package/src/file/watcher.ts +51 -42
  31. package/src/file.ts +1 -1
  32. package/src/flag/flag.ts +26 -11
  33. package/src/format/formatter.ts +206 -162
  34. package/src/format/index.ts +61 -61
  35. package/src/global/index.ts +21 -21
  36. package/src/id/id.ts +47 -33
  37. package/src/index.js +346 -199
  38. package/src/json-standard/index.ts +67 -51
  39. package/src/mcp/index.ts +135 -128
  40. package/src/patch/index.ts +336 -267
  41. package/src/project/bootstrap.ts +15 -15
  42. package/src/project/instance.ts +43 -36
  43. package/src/project/project.ts +47 -47
  44. package/src/project/state.ts +37 -33
  45. package/src/provider/models-macro.ts +5 -5
  46. package/src/provider/models.ts +32 -32
  47. package/src/provider/opencode.js +19 -19
  48. package/src/provider/provider.ts +518 -277
  49. package/src/provider/transform.ts +143 -102
  50. package/src/server/project.ts +21 -21
  51. package/src/server/server.ts +111 -105
  52. package/src/session/agent.js +66 -60
  53. package/src/session/compaction.ts +136 -111
  54. package/src/session/index.ts +189 -156
  55. package/src/session/message-v2.ts +312 -268
  56. package/src/session/message.ts +73 -57
  57. package/src/session/processor.ts +180 -166
  58. package/src/session/prompt.ts +678 -533
  59. package/src/session/retry.ts +26 -23
  60. package/src/session/revert.ts +76 -62
  61. package/src/session/status.ts +26 -26
  62. package/src/session/summary.ts +97 -76
  63. package/src/session/system.ts +77 -63
  64. package/src/session/todo.ts +22 -16
  65. package/src/snapshot/index.ts +92 -76
  66. package/src/storage/storage.ts +157 -120
  67. package/src/tool/bash.ts +116 -106
  68. package/src/tool/batch.ts +73 -59
  69. package/src/tool/codesearch.ts +60 -53
  70. package/src/tool/edit.ts +319 -263
  71. package/src/tool/glob.ts +32 -28
  72. package/src/tool/grep.ts +72 -53
  73. package/src/tool/invalid.ts +7 -7
  74. package/src/tool/ls.ts +77 -64
  75. package/src/tool/multiedit.ts +30 -21
  76. package/src/tool/patch.ts +121 -94
  77. package/src/tool/read.ts +140 -122
  78. package/src/tool/registry.ts +38 -38
  79. package/src/tool/task.ts +93 -60
  80. package/src/tool/todo.ts +16 -16
  81. package/src/tool/tool.ts +45 -36
  82. package/src/tool/webfetch.ts +97 -74
  83. package/src/tool/websearch.ts +78 -64
  84. package/src/tool/write.ts +21 -15
  85. package/src/util/binary.ts +27 -19
  86. package/src/util/context.ts +8 -8
  87. package/src/util/defer.ts +7 -5
  88. package/src/util/error.ts +24 -19
  89. package/src/util/eventloop.ts +16 -10
  90. package/src/util/filesystem.ts +37 -33
  91. package/src/util/fn.ts +11 -8
  92. package/src/util/iife.ts +1 -1
  93. package/src/util/keybind.ts +44 -44
  94. package/src/util/lazy.ts +7 -7
  95. package/src/util/locale.ts +20 -16
  96. package/src/util/lock.ts +43 -38
  97. package/src/util/log.ts +95 -85
  98. package/src/util/queue.ts +8 -8
  99. package/src/util/rpc.ts +35 -23
  100. package/src/util/scrap.ts +4 -4
  101. package/src/util/signal.ts +5 -5
  102. package/src/util/timeout.ts +6 -6
  103. package/src/util/token.ts +2 -2
  104. package/src/util/wildcard.ts +38 -27
@@ -1,45 +1,48 @@
1
- import z from "zod"
2
- import { NamedError } from "../util/error"
1
+ import z from 'zod';
2
+ import { NamedError } from '../util/error';
3
3
 
4
4
  export namespace Message {
5
- export const OutputLengthError = NamedError.create("MessageOutputLengthError", z.object({}))
5
+ export const OutputLengthError = NamedError.create(
6
+ 'MessageOutputLengthError',
7
+ z.object({})
8
+ );
6
9
  export const AuthError = NamedError.create(
7
- "ProviderAuthError",
10
+ 'ProviderAuthError',
8
11
  z.object({
9
12
  providerID: z.string(),
10
13
  message: z.string(),
11
- }),
12
- )
14
+ })
15
+ );
13
16
 
14
17
  export const ToolCall = z
15
18
  .object({
16
- state: z.literal("call"),
19
+ state: z.literal('call'),
17
20
  step: z.number().optional(),
18
21
  toolCallId: z.string(),
19
22
  toolName: z.string(),
20
23
  args: z.custom<Required<unknown>>(),
21
24
  })
22
25
  .meta({
23
- ref: "ToolCall",
24
- })
25
- export type ToolCall = z.infer<typeof ToolCall>
26
+ ref: 'ToolCall',
27
+ });
28
+ export type ToolCall = z.infer<typeof ToolCall>;
26
29
 
27
30
  export const ToolPartialCall = z
28
31
  .object({
29
- state: z.literal("partial-call"),
32
+ state: z.literal('partial-call'),
30
33
  step: z.number().optional(),
31
34
  toolCallId: z.string(),
32
35
  toolName: z.string(),
33
36
  args: z.custom<Required<unknown>>(),
34
37
  })
35
38
  .meta({
36
- ref: "ToolPartialCall",
37
- })
38
- export type ToolPartialCall = z.infer<typeof ToolPartialCall>
39
+ ref: 'ToolPartialCall',
40
+ });
41
+ export type ToolPartialCall = z.infer<typeof ToolPartialCall>;
39
42
 
40
43
  export const ToolResult = z
41
44
  .object({
42
- state: z.literal("result"),
45
+ state: z.literal('result'),
43
46
  step: z.number().optional(),
44
47
  toolCallId: z.string(),
45
48
  toolName: z.string(),
@@ -47,91 +50,100 @@ export namespace Message {
47
50
  result: z.string(),
48
51
  })
49
52
  .meta({
50
- ref: "ToolResult",
51
- })
52
- export type ToolResult = z.infer<typeof ToolResult>
53
+ ref: 'ToolResult',
54
+ });
55
+ export type ToolResult = z.infer<typeof ToolResult>;
53
56
 
54
- export const ToolInvocation = z.discriminatedUnion("state", [ToolCall, ToolPartialCall, ToolResult]).meta({
55
- ref: "ToolInvocation",
56
- })
57
- export type ToolInvocation = z.infer<typeof ToolInvocation>
57
+ export const ToolInvocation = z
58
+ .discriminatedUnion('state', [ToolCall, ToolPartialCall, ToolResult])
59
+ .meta({
60
+ ref: 'ToolInvocation',
61
+ });
62
+ export type ToolInvocation = z.infer<typeof ToolInvocation>;
58
63
 
59
64
  export const TextPart = z
60
65
  .object({
61
- type: z.literal("text"),
66
+ type: z.literal('text'),
62
67
  text: z.string(),
63
68
  })
64
69
  .meta({
65
- ref: "TextPart",
66
- })
67
- export type TextPart = z.infer<typeof TextPart>
70
+ ref: 'TextPart',
71
+ });
72
+ export type TextPart = z.infer<typeof TextPart>;
68
73
 
69
74
  export const ReasoningPart = z
70
75
  .object({
71
- type: z.literal("reasoning"),
76
+ type: z.literal('reasoning'),
72
77
  text: z.string(),
73
78
  providerMetadata: z.record(z.string(), z.any()).optional(),
74
79
  })
75
80
  .meta({
76
- ref: "ReasoningPart",
77
- })
78
- export type ReasoningPart = z.infer<typeof ReasoningPart>
81
+ ref: 'ReasoningPart',
82
+ });
83
+ export type ReasoningPart = z.infer<typeof ReasoningPart>;
79
84
 
80
85
  export const ToolInvocationPart = z
81
86
  .object({
82
- type: z.literal("tool-invocation"),
87
+ type: z.literal('tool-invocation'),
83
88
  toolInvocation: ToolInvocation,
84
89
  })
85
90
  .meta({
86
- ref: "ToolInvocationPart",
87
- })
88
- export type ToolInvocationPart = z.infer<typeof ToolInvocationPart>
91
+ ref: 'ToolInvocationPart',
92
+ });
93
+ export type ToolInvocationPart = z.infer<typeof ToolInvocationPart>;
89
94
 
90
95
  export const SourceUrlPart = z
91
96
  .object({
92
- type: z.literal("source-url"),
97
+ type: z.literal('source-url'),
93
98
  sourceId: z.string(),
94
99
  url: z.string(),
95
100
  title: z.string().optional(),
96
101
  providerMetadata: z.record(z.string(), z.any()).optional(),
97
102
  })
98
103
  .meta({
99
- ref: "SourceUrlPart",
100
- })
101
- export type SourceUrlPart = z.infer<typeof SourceUrlPart>
104
+ ref: 'SourceUrlPart',
105
+ });
106
+ export type SourceUrlPart = z.infer<typeof SourceUrlPart>;
102
107
 
103
108
  export const FilePart = z
104
109
  .object({
105
- type: z.literal("file"),
110
+ type: z.literal('file'),
106
111
  mediaType: z.string(),
107
112
  filename: z.string().optional(),
108
113
  url: z.string(),
109
114
  })
110
115
  .meta({
111
- ref: "FilePart",
112
- })
113
- export type FilePart = z.infer<typeof FilePart>
116
+ ref: 'FilePart',
117
+ });
118
+ export type FilePart = z.infer<typeof FilePart>;
114
119
 
115
120
  export const StepStartPart = z
116
121
  .object({
117
- type: z.literal("step-start"),
122
+ type: z.literal('step-start'),
118
123
  })
119
124
  .meta({
120
- ref: "StepStartPart",
121
- })
122
- export type StepStartPart = z.infer<typeof StepStartPart>
125
+ ref: 'StepStartPart',
126
+ });
127
+ export type StepStartPart = z.infer<typeof StepStartPart>;
123
128
 
124
129
  export const MessagePart = z
125
- .discriminatedUnion("type", [TextPart, ReasoningPart, ToolInvocationPart, SourceUrlPart, FilePart, StepStartPart])
130
+ .discriminatedUnion('type', [
131
+ TextPart,
132
+ ReasoningPart,
133
+ ToolInvocationPart,
134
+ SourceUrlPart,
135
+ FilePart,
136
+ StepStartPart,
137
+ ])
126
138
  .meta({
127
- ref: "MessagePart",
128
- })
129
- export type MessagePart = z.infer<typeof MessagePart>
139
+ ref: 'MessagePart',
140
+ });
141
+ export type MessagePart = z.infer<typeof MessagePart>;
130
142
 
131
143
  export const Info = z
132
144
  .object({
133
145
  id: z.string(),
134
- role: z.enum(["user", "assistant"]),
146
+ role: z.enum(['user', 'assistant']),
135
147
  parts: z.array(MessagePart),
136
148
  metadata: z
137
149
  .object({
@@ -140,7 +152,11 @@ export namespace Message {
140
152
  completed: z.number().optional(),
141
153
  }),
142
154
  error: z
143
- .discriminatedUnion("name", [AuthError.Schema, NamedError.Unknown.Schema, OutputLengthError.Schema])
155
+ .discriminatedUnion('name', [
156
+ AuthError.Schema,
157
+ NamedError.Unknown.Schema,
158
+ OutputLengthError.Schema,
159
+ ])
144
160
  .optional(),
145
161
  sessionID: z.string(),
146
162
  tool: z.record(
@@ -154,7 +170,7 @@ export namespace Message {
154
170
  end: z.number(),
155
171
  }),
156
172
  })
157
- .catchall(z.any()),
173
+ .catchall(z.any())
158
174
  ),
159
175
  assistant: z
160
176
  .object({
@@ -180,10 +196,10 @@ export namespace Message {
180
196
  .optional(),
181
197
  snapshot: z.string().optional(),
182
198
  })
183
- .meta({ ref: "MessageMetadata" }),
199
+ .meta({ ref: 'MessageMetadata' }),
184
200
  })
185
201
  .meta({
186
- ref: "Message",
187
- })
188
- export type Info = z.infer<typeof Info>
202
+ ref: 'Message',
203
+ });
204
+ export type Info = z.infer<typeof Info>;
189
205
  }