@link-assistant/agent 0.0.8 → 0.0.11
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/EXAMPLES.md +80 -1
- package/MODELS.md +72 -24
- package/README.md +95 -2
- package/TOOLS.md +20 -0
- package/package.json +36 -2
- package/src/agent/agent.ts +68 -54
- package/src/auth/claude-oauth.ts +426 -0
- package/src/auth/index.ts +28 -26
- package/src/auth/plugins.ts +876 -0
- package/src/bun/index.ts +53 -43
- package/src/bus/global.ts +5 -5
- package/src/bus/index.ts +59 -53
- package/src/cli/bootstrap.js +12 -12
- package/src/cli/bootstrap.ts +6 -6
- package/src/cli/cmd/agent.ts +97 -92
- package/src/cli/cmd/auth.ts +468 -0
- package/src/cli/cmd/cmd.ts +2 -2
- package/src/cli/cmd/export.ts +41 -41
- package/src/cli/cmd/mcp.ts +210 -53
- package/src/cli/cmd/models.ts +30 -29
- package/src/cli/cmd/run.ts +269 -213
- package/src/cli/cmd/stats.ts +185 -146
- package/src/cli/error.ts +17 -13
- package/src/cli/ui.ts +78 -0
- package/src/command/index.ts +26 -26
- package/src/config/config.ts +528 -288
- package/src/config/markdown.ts +15 -15
- package/src/file/ripgrep.ts +201 -169
- package/src/file/time.ts +21 -18
- package/src/file/watcher.ts +51 -42
- package/src/file.ts +1 -1
- package/src/flag/flag.ts +26 -11
- package/src/format/formatter.ts +206 -162
- package/src/format/index.ts +61 -61
- package/src/global/index.ts +21 -21
- package/src/id/id.ts +47 -33
- package/src/index.js +554 -332
- package/src/json-standard/index.ts +173 -0
- package/src/mcp/index.ts +135 -128
- package/src/patch/index.ts +336 -267
- package/src/project/bootstrap.ts +15 -15
- package/src/project/instance.ts +43 -36
- package/src/project/project.ts +47 -47
- package/src/project/state.ts +37 -33
- package/src/provider/models-macro.ts +5 -5
- package/src/provider/models.ts +32 -32
- package/src/provider/opencode.js +19 -19
- package/src/provider/provider.ts +518 -277
- package/src/provider/transform.ts +143 -102
- package/src/server/project.ts +21 -21
- package/src/server/server.ts +111 -105
- package/src/session/agent.js +66 -60
- package/src/session/compaction.ts +136 -111
- package/src/session/index.ts +189 -156
- package/src/session/message-v2.ts +312 -268
- package/src/session/message.ts +73 -57
- package/src/session/processor.ts +180 -166
- package/src/session/prompt.ts +678 -533
- package/src/session/retry.ts +26 -23
- package/src/session/revert.ts +76 -62
- package/src/session/status.ts +26 -26
- package/src/session/summary.ts +97 -76
- package/src/session/system.ts +77 -63
- package/src/session/todo.ts +22 -16
- package/src/snapshot/index.ts +92 -76
- package/src/storage/storage.ts +157 -120
- package/src/tool/bash.ts +116 -106
- package/src/tool/batch.ts +73 -59
- package/src/tool/codesearch.ts +60 -53
- package/src/tool/edit.ts +319 -263
- package/src/tool/glob.ts +32 -28
- package/src/tool/grep.ts +72 -53
- package/src/tool/invalid.ts +7 -7
- package/src/tool/ls.ts +77 -64
- package/src/tool/multiedit.ts +30 -21
- package/src/tool/patch.ts +121 -94
- package/src/tool/read.ts +140 -122
- package/src/tool/registry.ts +38 -38
- package/src/tool/task.ts +93 -60
- package/src/tool/todo.ts +16 -16
- package/src/tool/tool.ts +45 -36
- package/src/tool/webfetch.ts +97 -74
- package/src/tool/websearch.ts +78 -64
- package/src/tool/write.ts +21 -15
- package/src/util/binary.ts +27 -19
- package/src/util/context.ts +8 -8
- package/src/util/defer.ts +7 -5
- package/src/util/error.ts +24 -19
- package/src/util/eventloop.ts +16 -10
- package/src/util/filesystem.ts +37 -33
- package/src/util/fn.ts +11 -8
- package/src/util/iife.ts +1 -1
- package/src/util/keybind.ts +44 -44
- package/src/util/lazy.ts +7 -7
- package/src/util/locale.ts +20 -16
- package/src/util/lock.ts +43 -38
- package/src/util/log.ts +95 -85
- package/src/util/queue.ts +8 -8
- package/src/util/rpc.ts +35 -23
- package/src/util/scrap.ts +4 -4
- package/src/util/signal.ts +5 -5
- package/src/util/timeout.ts +6 -6
- package/src/util/token.ts +2 -2
- package/src/util/wildcard.ts +38 -27
package/src/session/message.ts
CHANGED
|
@@ -1,45 +1,48 @@
|
|
|
1
|
-
import z from
|
|
2
|
-
import { NamedError } from
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { NamedError } from '../util/error';
|
|
3
3
|
|
|
4
4
|
export namespace Message {
|
|
5
|
-
export const OutputLengthError = NamedError.create(
|
|
5
|
+
export const OutputLengthError = NamedError.create(
|
|
6
|
+
'MessageOutputLengthError',
|
|
7
|
+
z.object({})
|
|
8
|
+
);
|
|
6
9
|
export const AuthError = NamedError.create(
|
|
7
|
-
|
|
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(
|
|
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:
|
|
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(
|
|
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:
|
|
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(
|
|
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:
|
|
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
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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(
|
|
66
|
+
type: z.literal('text'),
|
|
62
67
|
text: z.string(),
|
|
63
68
|
})
|
|
64
69
|
.meta({
|
|
65
|
-
ref:
|
|
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(
|
|
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:
|
|
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(
|
|
87
|
+
type: z.literal('tool-invocation'),
|
|
83
88
|
toolInvocation: ToolInvocation,
|
|
84
89
|
})
|
|
85
90
|
.meta({
|
|
86
|
-
ref:
|
|
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(
|
|
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:
|
|
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(
|
|
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:
|
|
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(
|
|
122
|
+
type: z.literal('step-start'),
|
|
118
123
|
})
|
|
119
124
|
.meta({
|
|
120
|
-
ref:
|
|
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(
|
|
130
|
+
.discriminatedUnion('type', [
|
|
131
|
+
TextPart,
|
|
132
|
+
ReasoningPart,
|
|
133
|
+
ToolInvocationPart,
|
|
134
|
+
SourceUrlPart,
|
|
135
|
+
FilePart,
|
|
136
|
+
StepStartPart,
|
|
137
|
+
])
|
|
126
138
|
.meta({
|
|
127
|
-
ref:
|
|
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([
|
|
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(
|
|
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:
|
|
199
|
+
.meta({ ref: 'MessageMetadata' }),
|
|
184
200
|
})
|
|
185
201
|
.meta({
|
|
186
|
-
ref:
|
|
187
|
-
})
|
|
188
|
-
export type Info = z.infer<typeof Info
|
|
202
|
+
ref: 'Message',
|
|
203
|
+
});
|
|
204
|
+
export type Info = z.infer<typeof Info>;
|
|
189
205
|
}
|