agent-afk 5.296.1 → 5.296.3
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/cli.mjs +328 -328
- package/dist/index.mjs +150 -150
- package/dist/skills/audit-fit/handler.d.ts +4 -0
- package/dist/skills/audit-fit/index.d.ts +3 -98
- package/dist/skills/audit-fit/schemas.d.ts +98 -0
- package/dist/telegram/handlers/farm-callbacks.open-pr.d.ts +7 -0
- package/dist/telegram/handlers/farm-callbacks.respawn.d.ts +6 -0
- package/dist/telegram/handlers/message.compact-handler.d.ts +14 -0
- package/dist/telegram/handlers/message.media-helpers.d.ts +13 -0
- package/dist/telegram/handlers/message.photo-handler.d.ts +22 -0
- package/dist/telegram/session-manager.d.ts +0 -1
- package/dist/telegram/session-manager.disk-io.d.ts +5 -0
- package/dist/telegram/session-manager.session-builder.d.ts +20 -0
- package/dist/telegram/session-manager.switcher.d.ts +21 -0
- package/dist/telegram.mjs +180 -180
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SkillExecutionContext } from '../index.js';
|
|
2
|
+
import type { IAgentSession } from '../../agent/types.js';
|
|
3
|
+
import { type AuditFitResult } from './schemas.js';
|
|
4
|
+
export declare function handler(input: unknown, parentSession?: IAgentSession, ctx?: SkillExecutionContext): Promise<AuditFitResult>;
|
|
@@ -1,100 +1,5 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { type SkillMetadata } from '../index.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
path: z.ZodString;
|
|
7
|
-
type: z.ZodEnum<{
|
|
8
|
-
agent: "agent";
|
|
9
|
-
command: "command";
|
|
10
|
-
skill: "skill";
|
|
11
|
-
hook: "hook";
|
|
12
|
-
}>;
|
|
13
|
-
source: z.ZodEnum<{
|
|
14
|
-
user: "user";
|
|
15
|
-
plugin: "plugin";
|
|
16
|
-
}>;
|
|
17
|
-
plugin_key: z.ZodOptional<z.ZodString>;
|
|
18
|
-
verdict: z.ZodEnum<{
|
|
19
|
-
correct: "correct";
|
|
20
|
-
misfit: "misfit";
|
|
21
|
-
outlier: "outlier";
|
|
22
|
-
}>;
|
|
23
|
-
recommended_type: z.ZodString;
|
|
24
|
-
rationale: z.ZodString;
|
|
25
|
-
confidence: z.ZodEnum<{
|
|
26
|
-
low: "low";
|
|
27
|
-
high: "high";
|
|
28
|
-
med: "med";
|
|
29
|
-
}>;
|
|
30
|
-
}, z.core.$strip>;
|
|
31
|
-
export type Verdict = z.infer<typeof VerdictSchema>;
|
|
32
|
-
export declare const InventoryMatrixSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
33
|
-
export type InventoryMatrix = z.infer<typeof InventoryMatrixSchema>;
|
|
34
|
-
export declare const AuditFitResultSchema: z.ZodObject<{
|
|
35
|
-
inventory: z.ZodObject<{
|
|
36
|
-
user: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
37
|
-
plugin: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
38
|
-
}, z.core.$strip>;
|
|
39
|
-
misfits: z.ZodArray<z.ZodObject<{
|
|
40
|
-
path: z.ZodString;
|
|
41
|
-
type: z.ZodEnum<{
|
|
42
|
-
agent: "agent";
|
|
43
|
-
command: "command";
|
|
44
|
-
skill: "skill";
|
|
45
|
-
hook: "hook";
|
|
46
|
-
}>;
|
|
47
|
-
source: z.ZodEnum<{
|
|
48
|
-
user: "user";
|
|
49
|
-
plugin: "plugin";
|
|
50
|
-
}>;
|
|
51
|
-
plugin_key: z.ZodOptional<z.ZodString>;
|
|
52
|
-
verdict: z.ZodEnum<{
|
|
53
|
-
correct: "correct";
|
|
54
|
-
misfit: "misfit";
|
|
55
|
-
outlier: "outlier";
|
|
56
|
-
}>;
|
|
57
|
-
recommended_type: z.ZodString;
|
|
58
|
-
rationale: z.ZodString;
|
|
59
|
-
confidence: z.ZodEnum<{
|
|
60
|
-
low: "low";
|
|
61
|
-
high: "high";
|
|
62
|
-
med: "med";
|
|
63
|
-
}>;
|
|
64
|
-
}, z.core.$strip>>;
|
|
65
|
-
briefs_written: z.ZodNumber;
|
|
66
|
-
total_artifacts: z.ZodNumber;
|
|
67
|
-
}, z.core.$strip>;
|
|
68
|
-
export type AuditFitResult = z.infer<typeof AuditFitResultSchema>;
|
|
69
|
-
export declare const AuditFitInputSchema: z.ZodObject<{
|
|
70
|
-
writeBriefs: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
-
scope: z.ZodOptional<z.ZodEnum<{
|
|
72
|
-
user: "user";
|
|
73
|
-
plugin: "plugin";
|
|
74
|
-
all: "all";
|
|
75
|
-
}>>;
|
|
76
|
-
}, z.core.$strip>;
|
|
77
|
-
export type AuditFitInput = z.infer<typeof AuditFitInputSchema>;
|
|
78
|
-
type Scope = 'user' | 'plugin' | 'all';
|
|
79
|
-
type FullArtifactType = 'skill' | 'command' | 'agent' | 'hook';
|
|
80
|
-
export declare function planAuditScope(scope: Scope): {
|
|
81
|
-
runUserDiscovery: boolean;
|
|
82
|
-
runPluginDiscovery: boolean;
|
|
83
|
-
runHookInspector: boolean;
|
|
84
|
-
};
|
|
85
|
-
export declare function aggregateVerdicts(verdicts: ReadonlyArray<Verdict>): {
|
|
86
|
-
inventory: AuditFitResult['inventory'];
|
|
87
|
-
misfits: Verdict[];
|
|
88
|
-
};
|
|
89
|
-
export declare function shouldWriteBriefForMisfit(m: Verdict): boolean;
|
|
90
|
-
export declare function renderHookList(settingsPath: string, hooks: ReadonlyArray<DiscoveredHook>): string;
|
|
91
|
-
export type InspectorOutcome = {
|
|
92
|
-
kind: 'failure';
|
|
93
|
-
message: string;
|
|
94
|
-
} | {
|
|
95
|
-
kind: 'success';
|
|
96
|
-
output: ReadonlyArray<Verdict>;
|
|
97
|
-
};
|
|
98
|
-
export declare function classifyInspectorResult(type: FullArtifactType, result: SubagentResult<ReadonlyArray<Verdict>> | undefined): InspectorOutcome;
|
|
2
|
+
export { VerdictSchema, InventoryMatrixSchema, AuditFitResultSchema, AuditFitInputSchema, planAuditScope, aggregateVerdicts, shouldWriteBriefForMisfit, renderHookList, classifyInspectorResult, ALL_TYPES, } from './schemas.js';
|
|
3
|
+
export type { Verdict, InventoryMatrix, AuditFitResult, AuditFitInput, Scope, FullArtifactType, InspectorOutcome, } from './schemas.js';
|
|
4
|
+
export type { SkillExecutionContext } from '../index.js';
|
|
99
5
|
export declare const auditFitSkill: SkillMetadata;
|
|
100
|
-
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { SubagentResult } from '../../agent/subagent/result.js';
|
|
3
|
+
import type { DiscoveredHook } from './discover.js';
|
|
4
|
+
export declare const VerdictSchema: z.ZodObject<{
|
|
5
|
+
path: z.ZodString;
|
|
6
|
+
type: z.ZodEnum<{
|
|
7
|
+
agent: "agent";
|
|
8
|
+
command: "command";
|
|
9
|
+
skill: "skill";
|
|
10
|
+
hook: "hook";
|
|
11
|
+
}>;
|
|
12
|
+
source: z.ZodEnum<{
|
|
13
|
+
user: "user";
|
|
14
|
+
plugin: "plugin";
|
|
15
|
+
}>;
|
|
16
|
+
plugin_key: z.ZodOptional<z.ZodString>;
|
|
17
|
+
verdict: z.ZodEnum<{
|
|
18
|
+
correct: "correct";
|
|
19
|
+
misfit: "misfit";
|
|
20
|
+
outlier: "outlier";
|
|
21
|
+
}>;
|
|
22
|
+
recommended_type: z.ZodString;
|
|
23
|
+
rationale: z.ZodString;
|
|
24
|
+
confidence: z.ZodEnum<{
|
|
25
|
+
low: "low";
|
|
26
|
+
high: "high";
|
|
27
|
+
med: "med";
|
|
28
|
+
}>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export type Verdict = z.infer<typeof VerdictSchema>;
|
|
31
|
+
export declare const InventoryMatrixSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
32
|
+
export type InventoryMatrix = z.infer<typeof InventoryMatrixSchema>;
|
|
33
|
+
export declare const AuditFitResultSchema: z.ZodObject<{
|
|
34
|
+
inventory: z.ZodObject<{
|
|
35
|
+
user: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
36
|
+
plugin: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
misfits: z.ZodArray<z.ZodObject<{
|
|
39
|
+
path: z.ZodString;
|
|
40
|
+
type: z.ZodEnum<{
|
|
41
|
+
agent: "agent";
|
|
42
|
+
command: "command";
|
|
43
|
+
skill: "skill";
|
|
44
|
+
hook: "hook";
|
|
45
|
+
}>;
|
|
46
|
+
source: z.ZodEnum<{
|
|
47
|
+
user: "user";
|
|
48
|
+
plugin: "plugin";
|
|
49
|
+
}>;
|
|
50
|
+
plugin_key: z.ZodOptional<z.ZodString>;
|
|
51
|
+
verdict: z.ZodEnum<{
|
|
52
|
+
correct: "correct";
|
|
53
|
+
misfit: "misfit";
|
|
54
|
+
outlier: "outlier";
|
|
55
|
+
}>;
|
|
56
|
+
recommended_type: z.ZodString;
|
|
57
|
+
rationale: z.ZodString;
|
|
58
|
+
confidence: z.ZodEnum<{
|
|
59
|
+
low: "low";
|
|
60
|
+
high: "high";
|
|
61
|
+
med: "med";
|
|
62
|
+
}>;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
briefs_written: z.ZodNumber;
|
|
65
|
+
total_artifacts: z.ZodNumber;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type AuditFitResult = z.infer<typeof AuditFitResultSchema>;
|
|
68
|
+
export declare const AuditFitInputSchema: z.ZodObject<{
|
|
69
|
+
writeBriefs: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
71
|
+
user: "user";
|
|
72
|
+
plugin: "plugin";
|
|
73
|
+
all: "all";
|
|
74
|
+
}>>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
export type AuditFitInput = z.infer<typeof AuditFitInputSchema>;
|
|
77
|
+
export type Scope = 'user' | 'plugin' | 'all';
|
|
78
|
+
export type FullArtifactType = 'skill' | 'command' | 'agent' | 'hook';
|
|
79
|
+
export declare const ALL_TYPES: ReadonlyArray<FullArtifactType>;
|
|
80
|
+
export declare function planAuditScope(scope: Scope): {
|
|
81
|
+
runUserDiscovery: boolean;
|
|
82
|
+
runPluginDiscovery: boolean;
|
|
83
|
+
runHookInspector: boolean;
|
|
84
|
+
};
|
|
85
|
+
export declare function aggregateVerdicts(verdicts: ReadonlyArray<Verdict>): {
|
|
86
|
+
inventory: AuditFitResult['inventory'];
|
|
87
|
+
misfits: Verdict[];
|
|
88
|
+
};
|
|
89
|
+
export declare function shouldWriteBriefForMisfit(m: Verdict): boolean;
|
|
90
|
+
export declare function renderHookList(settingsPath: string, hooks: ReadonlyArray<DiscoveredHook>): string;
|
|
91
|
+
export type InspectorOutcome = {
|
|
92
|
+
kind: 'failure';
|
|
93
|
+
message: string;
|
|
94
|
+
} | {
|
|
95
|
+
kind: 'success';
|
|
96
|
+
output: ReadonlyArray<Verdict>;
|
|
97
|
+
};
|
|
98
|
+
export declare function classifyInspectorResult(type: FullArtifactType, result: SubagentResult<ReadonlyArray<Verdict>> | undefined): InspectorOutcome;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context } from 'telegraf';
|
|
2
|
+
import { type CreatePrOpts, type ExecFn } from '../../agent/gh.js';
|
|
3
|
+
import { type FarmManifest } from '../../agent/worktree.js';
|
|
4
|
+
import type { FarmCallbackDeps } from './farm-callbacks.js';
|
|
5
|
+
type LogFn = (...args: unknown[]) => void;
|
|
6
|
+
export declare function handleOpenPr(ctx: Context, manifest: FarmManifest, deps: FarmCallbackDeps, log: LogFn): Promise<void>;
|
|
7
|
+
export type { CreatePrOpts, ExecFn };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context } from 'telegraf';
|
|
2
|
+
import { type FarmManifest } from '../../agent/worktree.js';
|
|
3
|
+
import type { FarmCallbackDeps } from './farm-callbacks.js';
|
|
4
|
+
type LogFn = (...args: unknown[]) => void;
|
|
5
|
+
export declare function handleRespawn(ctx: Context, manifest: FarmManifest, deps: FarmCallbackDeps, log: LogFn): Promise<void>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Context } from 'telegraf';
|
|
2
|
+
import { type TelegramRoute } from '../route.js';
|
|
3
|
+
import type { SessionManager } from '../session-manager.js';
|
|
4
|
+
type LogFn = (...args: unknown[]) => void;
|
|
5
|
+
export interface CompactHandlerContext {
|
|
6
|
+
sessionManager: SessionManager;
|
|
7
|
+
log: LogFn;
|
|
8
|
+
reserveClaim(key: string): void;
|
|
9
|
+
releaseClaim(key: string): void;
|
|
10
|
+
enqueueCompact(route: TelegramRoute, ctx: Context): void;
|
|
11
|
+
drainQueue(route: TelegramRoute): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare function processCompactDirectImpl(route: TelegramRoute, ctx: Context, hc: CompactHandlerContext): Promise<void>;
|
|
14
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Context } from 'telegraf';
|
|
1
2
|
export declare function sniffMimeType(bytes: Buffer): 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | null;
|
|
2
3
|
export type LimitedReadResult = {
|
|
3
4
|
status: 'ok';
|
|
@@ -9,3 +10,15 @@ export type LimitedReadResult = {
|
|
|
9
10
|
status: 'missing-body';
|
|
10
11
|
};
|
|
11
12
|
export declare function readResponseBytesWithLimit(response: Response, maxBytes: number): Promise<LimitedReadResult>;
|
|
13
|
+
export declare const ALLOWED_PHOTO_MIME: readonly ["image/jpeg", "image/png", "image/gif", "image/webp"];
|
|
14
|
+
export type AllowedPhotoMime = typeof ALLOWED_PHOTO_MIME[number];
|
|
15
|
+
export type FetchPhotoResult = {
|
|
16
|
+
ok: true;
|
|
17
|
+
bytes: Buffer;
|
|
18
|
+
media_type: AllowedPhotoMime;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
};
|
|
22
|
+
type LogFn = (...args: unknown[]) => void;
|
|
23
|
+
export declare function fetchAndClassifyPhoto(ctx: Context, fileId: string, chatId: number, log: LogFn): Promise<FetchPhotoResult>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Context } from 'telegraf';
|
|
2
|
+
import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
|
|
3
|
+
import { type TelegramRoute } from '../route.js';
|
|
4
|
+
import type { SessionManager } from '../session-manager.js';
|
|
5
|
+
import type { Telegraf } from 'telegraf';
|
|
6
|
+
type LogFn = (...args: unknown[]) => void;
|
|
7
|
+
export interface PhotoHandlerContext {
|
|
8
|
+
bot: Telegraf;
|
|
9
|
+
sessionManager: SessionManager;
|
|
10
|
+
registeredCommandChats: Set<number>;
|
|
11
|
+
tagOnlyChats: Set<number>;
|
|
12
|
+
log: LogFn;
|
|
13
|
+
isClaimed(key: string): boolean;
|
|
14
|
+
reserveClaim(key: string): void;
|
|
15
|
+
releaseClaim(key: string): void;
|
|
16
|
+
enqueuePhoto(route: TelegramRoute, ctx: Context, content: ContentBlockParam[]): number | false;
|
|
17
|
+
processOne(route: TelegramRoute, ctx: Context, content: ContentBlockParam[]): Promise<void>;
|
|
18
|
+
MAX_QUEUE_DEPTH: number;
|
|
19
|
+
messageQueues: Map<string, unknown[]>;
|
|
20
|
+
}
|
|
21
|
+
export declare function handlePhotoImpl(ctx: Context, hc: PhotoHandlerContext): Promise<void>;
|
|
22
|
+
export {};
|
|
@@ -70,7 +70,6 @@ export declare class SessionManager {
|
|
|
70
70
|
reason: 'not-found' | 'already-active';
|
|
71
71
|
}>;
|
|
72
72
|
newSession(target: RouteTarget): Promise<void>;
|
|
73
|
-
private sidecarFileName;
|
|
74
73
|
loadSessions(): Promise<void>;
|
|
75
74
|
saveSessions(): Promise<void>;
|
|
76
75
|
private _evictStaleSessionData;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type TelegramRoute } from './route.js';
|
|
2
|
+
import type { SessionData } from './session-manager.js';
|
|
3
|
+
export declare function sidecarFileName(data: SessionData): string;
|
|
4
|
+
export declare function loadSessionsFromDisk(dataDir: string, sessionData: Map<string, SessionData>, onEachRoute: (route: TelegramRoute, data: SessionData) => void): Promise<void>;
|
|
5
|
+
export declare function saveSessionsToDisk(dataDir: string, sessionData: Map<string, SessionData>): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IAgentSession, AgentConfig, AgentModelInput, ThinkingConfig, EffortLevel } from '../agent/types.js';
|
|
2
|
+
import { type TelegramRoute } from './route.js';
|
|
3
|
+
import type { SessionData } from './session-manager.js';
|
|
4
|
+
export interface SessionBuilderOptions {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
settingSources?: ('user' | 'project')[];
|
|
7
|
+
thinking?: ThinkingConfig;
|
|
8
|
+
effort?: EffortLevel;
|
|
9
|
+
botCwd?: string;
|
|
10
|
+
createSession: (config: AgentConfig) => Promise<IAgentSession>;
|
|
11
|
+
onResumptionOffer?: (route: TelegramRoute, text: string) => void | Promise<boolean>;
|
|
12
|
+
defaultModel: AgentModelInput;
|
|
13
|
+
}
|
|
14
|
+
export interface SessionBuilderContext {
|
|
15
|
+
sessions: Map<string, IAgentSession>;
|
|
16
|
+
sessionData: Map<string, SessionData>;
|
|
17
|
+
pendingResume: Map<string, string>;
|
|
18
|
+
ensureRegistryHandle(route: TelegramRoute, data: SessionData): void;
|
|
19
|
+
}
|
|
20
|
+
export declare function buildAndRegisterSession(route: TelegramRoute, key: string, data: SessionData, opts: SessionBuilderOptions, sc: SessionBuilderContext): Promise<IAgentSession>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IAgentSession } from '../agent/types.js';
|
|
2
|
+
import { type TelegramRoute } from './route.js';
|
|
3
|
+
import type { SessionData, ChatSessionInfo, RouteTarget } from './session-manager.js';
|
|
4
|
+
import type { SessionStats } from '../cli/slash/types.js';
|
|
5
|
+
export declare function listChatSessionsImpl(target: RouteTarget, sessionData: Map<string, SessionData>): ChatSessionInfo[];
|
|
6
|
+
export interface SwitcherContext {
|
|
7
|
+
sessions: Map<string, IAgentSession>;
|
|
8
|
+
pendingSessions: Map<string, Promise<IAgentSession>>;
|
|
9
|
+
sessionData: Map<string, SessionData>;
|
|
10
|
+
sessionStats: Map<string, SessionStats>;
|
|
11
|
+
autosaveFailureLogged: Set<string>;
|
|
12
|
+
pendingResume: Map<string, string>;
|
|
13
|
+
newData(route: TelegramRoute): SessionData;
|
|
14
|
+
}
|
|
15
|
+
export declare function switchToSessionImpl(target: RouteTarget, targetSessionId: string, sc: SwitcherContext): Promise<{
|
|
16
|
+
ok: true;
|
|
17
|
+
name?: string;
|
|
18
|
+
} | {
|
|
19
|
+
ok: false;
|
|
20
|
+
reason: 'not-found' | 'already-active';
|
|
21
|
+
}>;
|