@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/auth/index.ts
CHANGED
|
@@ -1,64 +1,66 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import { Global } from
|
|
3
|
-
import fs from
|
|
4
|
-
import z from
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { Global } from '../global';
|
|
3
|
+
import fs from 'fs/promises';
|
|
4
|
+
import z from 'zod';
|
|
5
5
|
|
|
6
6
|
export namespace Auth {
|
|
7
7
|
export const Oauth = z
|
|
8
8
|
.object({
|
|
9
|
-
type: z.literal(
|
|
9
|
+
type: z.literal('oauth'),
|
|
10
10
|
refresh: z.string(),
|
|
11
11
|
access: z.string(),
|
|
12
12
|
expires: z.number(),
|
|
13
13
|
enterpriseUrl: z.string().optional(),
|
|
14
14
|
})
|
|
15
|
-
.meta({ ref:
|
|
15
|
+
.meta({ ref: 'OAuth' });
|
|
16
16
|
|
|
17
17
|
export const Api = z
|
|
18
18
|
.object({
|
|
19
|
-
type: z.literal(
|
|
19
|
+
type: z.literal('api'),
|
|
20
20
|
key: z.string(),
|
|
21
21
|
})
|
|
22
|
-
.meta({ ref:
|
|
22
|
+
.meta({ ref: 'ApiAuth' });
|
|
23
23
|
|
|
24
24
|
export const WellKnown = z
|
|
25
25
|
.object({
|
|
26
|
-
type: z.literal(
|
|
26
|
+
type: z.literal('wellknown'),
|
|
27
27
|
key: z.string(),
|
|
28
28
|
token: z.string(),
|
|
29
29
|
})
|
|
30
|
-
.meta({ ref:
|
|
30
|
+
.meta({ ref: 'WellKnownAuth' });
|
|
31
31
|
|
|
32
|
-
export const Info = z
|
|
33
|
-
|
|
32
|
+
export const Info = z
|
|
33
|
+
.discriminatedUnion('type', [Oauth, Api, WellKnown])
|
|
34
|
+
.meta({ ref: 'Auth' });
|
|
35
|
+
export type Info = z.infer<typeof Info>;
|
|
34
36
|
|
|
35
|
-
const filepath = path.join(Global.Path.data,
|
|
37
|
+
const filepath = path.join(Global.Path.data, 'auth.json');
|
|
36
38
|
|
|
37
39
|
export async function get(providerID: string) {
|
|
38
|
-
const file = Bun.file(filepath)
|
|
40
|
+
const file = Bun.file(filepath);
|
|
39
41
|
return file
|
|
40
42
|
.json()
|
|
41
43
|
.catch(() => ({}))
|
|
42
|
-
.then((x) => x[providerID] as Info | undefined)
|
|
44
|
+
.then((x) => x[providerID] as Info | undefined);
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
export async function all(): Promise<Record<string, Info>> {
|
|
46
|
-
const file = Bun.file(filepath)
|
|
47
|
-
return file.json().catch(() => ({}))
|
|
48
|
+
const file = Bun.file(filepath);
|
|
49
|
+
return file.json().catch(() => ({}));
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
export async function set(key: string, info: Info) {
|
|
51
|
-
const file = Bun.file(filepath)
|
|
52
|
-
const data = await all()
|
|
53
|
-
await Bun.write(file, JSON.stringify({ ...data, [key]: info }, null, 2))
|
|
54
|
-
await fs.chmod(file.name!, 0o600)
|
|
53
|
+
const file = Bun.file(filepath);
|
|
54
|
+
const data = await all();
|
|
55
|
+
await Bun.write(file, JSON.stringify({ ...data, [key]: info }, null, 2));
|
|
56
|
+
await fs.chmod(file.name!, 0o600);
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export async function remove(key: string) {
|
|
58
|
-
const file = Bun.file(filepath)
|
|
59
|
-
const data = await all()
|
|
60
|
-
delete data[key]
|
|
61
|
-
await Bun.write(file, JSON.stringify(data, null, 2))
|
|
62
|
-
await fs.chmod(file.name!, 0o600)
|
|
60
|
+
const file = Bun.file(filepath);
|
|
61
|
+
const data = await all();
|
|
62
|
+
delete data[key];
|
|
63
|
+
await Bun.write(file, JSON.stringify(data, null, 2));
|
|
64
|
+
await fs.chmod(file.name!, 0o600);
|
|
63
65
|
}
|
|
64
66
|
}
|