@foxden-app/foxclaw 0.2.0
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/.env.example +36 -0
- package/LICENSE +22 -0
- package/README.md +244 -0
- package/README_EN.md +244 -0
- package/dist/channels/bridge_messaging_router.d.ts +27 -0
- package/dist/channels/bridge_messaging_router.js +85 -0
- package/dist/channels/telegram/telegram_channel_adapter.d.ts +12 -0
- package/dist/channels/telegram/telegram_channel_adapter.js +21 -0
- package/dist/channels/telegram/telegram_messaging_port.d.ts +25 -0
- package/dist/channels/telegram/telegram_messaging_port.js +51 -0
- package/dist/channels/weixin/account_store.d.ts +15 -0
- package/dist/channels/weixin/account_store.js +54 -0
- package/dist/channels/weixin/ilink/aes_ecb.d.ts +3 -0
- package/dist/channels/weixin/ilink/aes_ecb.js +12 -0
- package/dist/channels/weixin/ilink/api.d.ts +44 -0
- package/dist/channels/weixin/ilink/api.js +187 -0
- package/dist/channels/weixin/ilink/cdn_upload.d.ts +11 -0
- package/dist/channels/weixin/ilink/cdn_upload.js +60 -0
- package/dist/channels/weixin/ilink/cdn_url.d.ts +7 -0
- package/dist/channels/weixin/ilink/cdn_url.js +7 -0
- package/dist/channels/weixin/ilink/constants.d.ts +7 -0
- package/dist/channels/weixin/ilink/constants.js +27 -0
- package/dist/channels/weixin/ilink/context.d.ts +13 -0
- package/dist/channels/weixin/ilink/context.js +13 -0
- package/dist/channels/weixin/ilink/login_qr.d.ts +34 -0
- package/dist/channels/weixin/ilink/login_qr.js +233 -0
- package/dist/channels/weixin/ilink/media_image.d.ts +11 -0
- package/dist/channels/weixin/ilink/media_image.js +44 -0
- package/dist/channels/weixin/ilink/mime.d.ts +3 -0
- package/dist/channels/weixin/ilink/mime.js +36 -0
- package/dist/channels/weixin/ilink/pic_decrypt.d.ts +2 -0
- package/dist/channels/weixin/ilink/pic_decrypt.js +56 -0
- package/dist/channels/weixin/ilink/random.d.ts +2 -0
- package/dist/channels/weixin/ilink/random.js +7 -0
- package/dist/channels/weixin/ilink/redact.d.ts +4 -0
- package/dist/channels/weixin/ilink/redact.js +34 -0
- package/dist/channels/weixin/ilink/runtime_attach.d.ts +3 -0
- package/dist/channels/weixin/ilink/runtime_attach.js +13 -0
- package/dist/channels/weixin/ilink/send.d.ts +21 -0
- package/dist/channels/weixin/ilink/send.js +108 -0
- package/dist/channels/weixin/ilink/session_guard.d.ts +6 -0
- package/dist/channels/weixin/ilink/session_guard.js +39 -0
- package/dist/channels/weixin/ilink/types.d.ts +155 -0
- package/dist/channels/weixin/ilink/types.js +10 -0
- package/dist/channels/weixin/ilink/upload.d.ts +15 -0
- package/dist/channels/weixin/ilink/upload.js +75 -0
- package/dist/channels/weixin/sync_buf_store.d.ts +3 -0
- package/dist/channels/weixin/sync_buf_store.js +19 -0
- package/dist/channels/weixin/weixin_channel_adapter.d.ts +18 -0
- package/dist/channels/weixin/weixin_channel_adapter.js +273 -0
- package/dist/channels/weixin/weixin_messaging_port.d.ts +29 -0
- package/dist/channels/weixin/weixin_messaging_port.js +113 -0
- package/dist/codex_app/client.d.ts +176 -0
- package/dist/codex_app/client.js +1230 -0
- package/dist/codex_app/deeplink.d.ts +7 -0
- package/dist/codex_app/deeplink.js +29 -0
- package/dist/codex_app/local_usage.d.ts +16 -0
- package/dist/codex_app/local_usage.js +123 -0
- package/dist/config.d.ts +44 -0
- package/dist/config.js +131 -0
- package/dist/controller/access.d.ts +11 -0
- package/dist/controller/access.js +33 -0
- package/dist/controller/activity.d.ts +62 -0
- package/dist/controller/activity.js +330 -0
- package/dist/controller/commands.d.ts +6 -0
- package/dist/controller/commands.js +17 -0
- package/dist/controller/controller.d.ts +326 -0
- package/dist/controller/controller.js +7503 -0
- package/dist/controller/observer.d.ts +16 -0
- package/dist/controller/observer.js +98 -0
- package/dist/controller/presentation.d.ts +80 -0
- package/dist/controller/presentation.js +568 -0
- package/dist/controller/service_tier.d.ts +9 -0
- package/dist/controller/service_tier.js +32 -0
- package/dist/controller/session_observer.d.ts +22 -0
- package/dist/controller/session_observer.js +259 -0
- package/dist/controller/status.d.ts +10 -0
- package/dist/controller/status.js +28 -0
- package/dist/core/bridge_scope.d.ts +18 -0
- package/dist/core/bridge_scope.js +46 -0
- package/dist/core/channel_port.d.ts +15 -0
- package/dist/core/channel_port.js +1 -0
- package/dist/i18n.d.ts +1108 -0
- package/dist/i18n.js +1154 -0
- package/dist/lock.d.ts +7 -0
- package/dist/lock.js +80 -0
- package/dist/logger.d.ts +12 -0
- package/dist/logger.js +57 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +236 -0
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.js +14 -0
- package/dist/store/database.d.ts +79 -0
- package/dist/store/database.js +489 -0
- package/dist/store/migrate_bridge_scope.d.ts +6 -0
- package/dist/store/migrate_bridge_scope.js +59 -0
- package/dist/telegram/addressing.d.ts +33 -0
- package/dist/telegram/addressing.js +57 -0
- package/dist/telegram/api.d.ts +14 -0
- package/dist/telegram/api.js +89 -0
- package/dist/telegram/gateway.d.ts +76 -0
- package/dist/telegram/gateway.js +383 -0
- package/dist/telegram/media.d.ts +34 -0
- package/dist/telegram/media.js +180 -0
- package/dist/telegram/rendering.d.ts +10 -0
- package/dist/telegram/rendering.js +21 -0
- package/dist/telegram/scope.d.ts +6 -0
- package/dist/telegram/scope.js +24 -0
- package/dist/telegram/text.d.ts +7 -0
- package/dist/telegram/text.js +47 -0
- package/dist/types.d.ts +343 -0
- package/dist/types.js +1 -0
- package/docs/agent-assisted-install.md +84 -0
- package/docs/install-for-beginners.md +287 -0
- package/docs/troubleshooting.md +239 -0
- package/package.json +62 -0
- package/scripts/doctor.sh +3 -0
- package/scripts/launchd/install.sh +54 -0
- package/scripts/status.sh +3 -0
- package/scripts/systemd/install.sh +83 -0
- package/scripts/systemd/uninstall.sh +15 -0
- package/skills/foxclaw/SKILL.md +167 -0
- package/skills/foxclaw/agents/openai.yaml +4 -0
- package/skills/foxclaw/references/telegram-setup.md +93 -0
- package/skills/foxclaw/scripts/bootstrap_host.py +350 -0
- package/skills/foxclaw/scripts/bootstrap_remote.py +67 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AppThreadSnapshot, AppTurnSnapshot } from '../types.js';
|
|
2
|
+
import { type TurnActivityEvent } from './activity.js';
|
|
3
|
+
export interface ObservedTurnCursor {
|
|
4
|
+
turnId: string;
|
|
5
|
+
itemTexts: Record<string, string>;
|
|
6
|
+
completedItemIds: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface ObservedTurnDiff {
|
|
9
|
+
nextCursor: ObservedTurnCursor;
|
|
10
|
+
events: TurnActivityEvent[];
|
|
11
|
+
waitingOnApproval: boolean;
|
|
12
|
+
completed: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function findLiveTurn(snapshot: AppThreadSnapshot): AppTurnSnapshot | null;
|
|
15
|
+
export declare function findLatestTurn(snapshot: AppThreadSnapshot): AppTurnSnapshot | null;
|
|
16
|
+
export declare function diffObservedTurn(cursor: ObservedTurnCursor | null, turn: AppTurnSnapshot, waitingOnApproval: boolean): ObservedTurnDiff;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { classifyAgentOutput } from './activity.js';
|
|
2
|
+
export function findLiveTurn(snapshot) {
|
|
3
|
+
for (let index = snapshot.turns.length - 1; index >= 0; index -= 1) {
|
|
4
|
+
const turn = snapshot.turns[index];
|
|
5
|
+
if (turn.status === 'inProgress') {
|
|
6
|
+
return turn;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
export function findLatestTurn(snapshot) {
|
|
12
|
+
return snapshot.turns.at(-1) ?? null;
|
|
13
|
+
}
|
|
14
|
+
export function diffObservedTurn(cursor, turn, waitingOnApproval) {
|
|
15
|
+
const baseCursor = cursor && cursor.turnId === turn.turnId
|
|
16
|
+
? {
|
|
17
|
+
turnId: cursor.turnId,
|
|
18
|
+
itemTexts: { ...cursor.itemTexts },
|
|
19
|
+
completedItemIds: [...cursor.completedItemIds],
|
|
20
|
+
}
|
|
21
|
+
: {
|
|
22
|
+
turnId: turn.turnId,
|
|
23
|
+
itemTexts: {},
|
|
24
|
+
completedItemIds: [],
|
|
25
|
+
};
|
|
26
|
+
const completedIds = new Set(baseCursor.completedItemIds);
|
|
27
|
+
const events = [];
|
|
28
|
+
const agentItems = turn.items.filter(isRelayableAgentItem);
|
|
29
|
+
for (const item of agentItems) {
|
|
30
|
+
const previousText = baseCursor.itemTexts[item.itemId];
|
|
31
|
+
const nextText = item.text || '';
|
|
32
|
+
if (previousText === undefined) {
|
|
33
|
+
events.push({
|
|
34
|
+
kind: 'agent_message_started',
|
|
35
|
+
turnId: turn.turnId,
|
|
36
|
+
itemId: item.itemId,
|
|
37
|
+
phase: item.phase,
|
|
38
|
+
outputKind: classifyObservedOutput(item, false),
|
|
39
|
+
isPlan: item.type.toLowerCase() === 'plan',
|
|
40
|
+
});
|
|
41
|
+
if (nextText) {
|
|
42
|
+
events.push({
|
|
43
|
+
kind: 'agent_message_delta',
|
|
44
|
+
turnId: turn.turnId,
|
|
45
|
+
itemId: item.itemId,
|
|
46
|
+
delta: nextText,
|
|
47
|
+
outputKind: classifyObservedOutput(item, false),
|
|
48
|
+
isPlan: item.type.toLowerCase() === 'plan',
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (nextText.length > previousText.length) {
|
|
53
|
+
events.push({
|
|
54
|
+
kind: 'agent_message_delta',
|
|
55
|
+
turnId: turn.turnId,
|
|
56
|
+
itemId: item.itemId,
|
|
57
|
+
delta: nextText.slice(previousText.length),
|
|
58
|
+
outputKind: classifyObservedOutput(item, false),
|
|
59
|
+
isPlan: item.type.toLowerCase() === 'plan',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
baseCursor.itemTexts[item.itemId] = nextText;
|
|
63
|
+
}
|
|
64
|
+
for (let index = 0; index < agentItems.length; index += 1) {
|
|
65
|
+
const item = agentItems[index];
|
|
66
|
+
const itemIsCompleted = turn.status !== 'inProgress' || index < agentItems.length - 1;
|
|
67
|
+
if (!itemIsCompleted || completedIds.has(item.itemId)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
completedIds.add(item.itemId);
|
|
71
|
+
events.push({
|
|
72
|
+
kind: 'agent_message_completed',
|
|
73
|
+
turnId: turn.turnId,
|
|
74
|
+
itemId: item.itemId,
|
|
75
|
+
phase: item.phase,
|
|
76
|
+
text: baseCursor.itemTexts[item.itemId] ?? item.text ?? null,
|
|
77
|
+
outputKind: classifyObservedOutput(item, true),
|
|
78
|
+
isPlan: item.type.toLowerCase() === 'plan',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
nextCursor: {
|
|
83
|
+
turnId: baseCursor.turnId,
|
|
84
|
+
itemTexts: baseCursor.itemTexts,
|
|
85
|
+
completedItemIds: [...completedIds],
|
|
86
|
+
},
|
|
87
|
+
events,
|
|
88
|
+
waitingOnApproval,
|
|
89
|
+
completed: turn.status !== 'inProgress',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function isRelayableAgentItem(item) {
|
|
93
|
+
const normalizedType = item.type.toLowerCase();
|
|
94
|
+
return normalizedType === 'agentmessage' || normalizedType === 'assistantmessage' || normalizedType === 'plan';
|
|
95
|
+
}
|
|
96
|
+
function classifyObservedOutput(item, completed) {
|
|
97
|
+
return item.type.toLowerCase() === 'plan' ? 'commentary' : classifyAgentOutput(item.phase, completed);
|
|
98
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { AccessPresetValue, ActiveTurnMessageMode, AppLocale, AppThread, ApprovalPolicyValue, ChatSessionSettings, CollaborationModeValue, ModelInfo, ReasoningEffortValue, SandboxModeValue } from '../types.js';
|
|
2
|
+
import type { ResolvedAccessMode } from './access.js';
|
|
3
|
+
type InlineButton = {
|
|
4
|
+
text: string;
|
|
5
|
+
callback_data: string;
|
|
6
|
+
};
|
|
7
|
+
export type SetupFocusSection = 'overview' | 'model' | 'effort' | 'fast' | 'access' | 'mode' | 'active';
|
|
8
|
+
export interface SetupPanelContext {
|
|
9
|
+
focus: SetupFocusSection;
|
|
10
|
+
models: ModelInfo[];
|
|
11
|
+
settings: ChatSessionSettings | null;
|
|
12
|
+
access: ResolvedAccessMode;
|
|
13
|
+
}
|
|
14
|
+
interface ThreadLike {
|
|
15
|
+
/** 1-based global ordinal for this row (pagination); keyboard and /open must match. */
|
|
16
|
+
index?: number;
|
|
17
|
+
threadId: string;
|
|
18
|
+
name: string | null;
|
|
19
|
+
preview: string;
|
|
20
|
+
cwd: string | null;
|
|
21
|
+
modelProvider: string | null;
|
|
22
|
+
status: AppThread['status'];
|
|
23
|
+
updatedAt: number;
|
|
24
|
+
archived?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Pagination + filter context for the threads panel (Telegram inline keyboard). */
|
|
27
|
+
export interface ThreadListPresentationState {
|
|
28
|
+
offset: number;
|
|
29
|
+
pageSize: number;
|
|
30
|
+
hasPreviousPage: boolean;
|
|
31
|
+
hasNextPage: boolean;
|
|
32
|
+
searchTerm: string | null;
|
|
33
|
+
archived?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function formatThreadsMessage(locale: AppLocale, threads: ThreadLike[], currentThreadId: string | null, searchTerm?: string | null, listState?: ThreadListPresentationState): string;
|
|
36
|
+
export declare function buildThreadsKeyboard(locale: AppLocale, threads: ThreadLike[]): Array<Array<{
|
|
37
|
+
text: string;
|
|
38
|
+
callback_data: string;
|
|
39
|
+
}>>;
|
|
40
|
+
/** Threads keyboard plus Prev/Next and optional clear-filter row (Telegram only). */
|
|
41
|
+
export declare function buildThreadListKeyboard(locale: AppLocale, threads: ThreadLike[], listState: ThreadListPresentationState): Array<Array<{
|
|
42
|
+
text: string;
|
|
43
|
+
callback_data: string;
|
|
44
|
+
}>>;
|
|
45
|
+
export declare function formatWhereMessage(locale: AppLocale, thread: AppThread, settings: ChatSessionSettings | null, defaultCwd: string, access: ResolvedAccessMode, fastLabel?: string): string;
|
|
46
|
+
export declare function formatCollaborationModeLabel(locale: AppLocale, mode: CollaborationModeValue | null | undefined): string;
|
|
47
|
+
export declare function formatAccessSettingsMessage(locale: AppLocale, access: ResolvedAccessMode): string;
|
|
48
|
+
export declare function buildAccessSettingsKeyboard(locale: AppLocale, access: ResolvedAccessMode): InlineButton[][];
|
|
49
|
+
/** Threads row shape for Weixin copy-paste lines (matches cached thread list fields). */
|
|
50
|
+
export interface WeixinCopyPasteThreadRow {
|
|
51
|
+
threadId: string;
|
|
52
|
+
name: string | null;
|
|
53
|
+
preview: string;
|
|
54
|
+
archived?: boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare function formatWeixinThreadsCopyPaste(locale: AppLocale, threads: WeixinCopyPasteThreadRow[], searchTerm?: string | null,
|
|
57
|
+
/** 0-based offset so /open numbers align with cached global indices when paginating. */
|
|
58
|
+
pageOffset?: number): string;
|
|
59
|
+
export declare function formatWeixinModelCopyPaste(locale: AppLocale, models: ModelInfo[], settings: ChatSessionSettings | null): string;
|
|
60
|
+
export declare function formatWeixinAccessCopyPaste(locale: AppLocale): string;
|
|
61
|
+
export declare function formatWeixinWhereNavCopyPaste(locale: AppLocale, hasBinding: boolean, defaultCwd?: string): string;
|
|
62
|
+
export declare function formatSetupPanelMessage(locale: AppLocale, ctx: SetupPanelContext): string;
|
|
63
|
+
export declare function buildSetupPanelKeyboard(locale: AppLocale, ctx: SetupPanelContext): InlineButton[][];
|
|
64
|
+
export declare function resolveSetupSummaryLine(ctx: SetupPanelContext, locale?: AppLocale): string;
|
|
65
|
+
export declare function formatServiceTierStatusLabel(locale: AppLocale, model: ModelInfo | null, serviceTier: string | null | undefined): string;
|
|
66
|
+
export declare function formatActiveTurnMessageModeLabel(locale: AppLocale, mode: ActiveTurnMessageMode | null | undefined): string;
|
|
67
|
+
export declare function resolveActiveTurnMessageMode(mode: ActiveTurnMessageMode | null | undefined): ActiveTurnMessageMode;
|
|
68
|
+
export declare function formatModelSettingsMessage(locale: AppLocale, models: ModelInfo[], settings: ChatSessionSettings | null): string;
|
|
69
|
+
export declare function buildModelSettingsKeyboard(locale: AppLocale, models: ModelInfo[], settings: ChatSessionSettings | null): InlineButton[][];
|
|
70
|
+
export declare function resolveRequestedModel(models: ModelInfo[], requested: string): ModelInfo | null;
|
|
71
|
+
export declare function resolveCurrentModel(models: ModelInfo[], currentModel: string | null): ModelInfo | null;
|
|
72
|
+
export declare function normalizeRequestedEffort(value: string): ReasoningEffortValue | null;
|
|
73
|
+
export declare function clampEffortToModel(model: ModelInfo | null, effort: ReasoningEffortValue | null): {
|
|
74
|
+
effort: ReasoningEffortValue | null;
|
|
75
|
+
adjustedFrom: ReasoningEffortValue | null;
|
|
76
|
+
};
|
|
77
|
+
export declare function formatAccessPresetLabel(locale: AppLocale, preset: AccessPresetValue): string;
|
|
78
|
+
export declare function formatApprovalPolicyLabel(locale: AppLocale, policy: ApprovalPolicyValue): string;
|
|
79
|
+
export declare function formatSandboxModeLabel(locale: AppLocale, mode: SandboxModeValue): string;
|
|
80
|
+
export {};
|