mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-04-13 01:03:33 -07:00
* Use git service for backups and dynamic AI menus
Switch backup actions to call gitService.commitAndSync(commitOnly) so local backups work without remote auth and AI commit generation is triggered by omitting commitMessage. Make AI-related menu items always registered but use dynamic visibility/enabled checks (isAIEnabled) so they appear/disappear at runtime. Update menu item types/imports accordingly. Optimize workspace persistence to write only the single updated workspace to settings.json (stripping syncable fields when tidgi.config exists) instead of saving all workspaces; remove the old saveWorkspacesToSettings method. Add warnings/logging: warn if git worker observable is undefined, log/notify when cloud sync is skipped due to missing auth/gitUrl. Misc: remove a redundant debug log in tidgiConfig, remove native process monitoring startup call, include commitMessage for CommitDetailsPanel sync, and drop entriesFingerprint/debug noise from git log data.
* fix: avoid rewriting unchanged workspace config
* fix: separate plain and ai backup flows
* feat: add searchable settings views
* fix: narrow sync adaptor revision type
* chore: release tidgi-shared 0.1.3
* Preferences: unify Scheduled/Background tasks and fix skeleton nav
- Remove legacy background task UI/dialogs (use ScheduledTask unified system)
- Attach invisible anchors to skeleton placeholders so sidebar scrollIntoView works while loading
- Add English/zh translation keys for AddAlarm/AddHeartbeat
- Add requestIdleCallback polyfill (tests) and speed up to 0ms for tests
- Search: match English translations (txEn) in SearchResultsView
* Fix view zero-size on minimize; realign on restore/show
Guard view bounds from 0x0 content size to prevent BrowserView disappearing when window is minimized; fall back to safe offscreen size. Add window 'restore' and 'show' handlers to realign views. Add getMemoryUsage() in wiki worker and expose RSS/heap via getWorkersInfo; show worker memory in Developer Tools diagnostics.
* Fix background/quit behavior: synchronous close handler; platform-specific runOnBackground default; add getWindowMetaSync; add forced-exit timeout for before-quit cleanup
* Refactor preferences: add definitions and registry
Add a new structured preferences system: introduce definition schemas, typed item/section types, explicit section files, a registry (allSections/sectionById), side effects, action handlers, and helper builders (zodPreferencesSchema). Add custom preference UI items and registration (customItems, registerCustomSections) and tests validating schemas. Replace previous zod/settings schema files with the new definitions and make IPreferences an explicit TypeScript interface. Small UI updates: use LanguageSelectorItem and WikiUserNameItem in Guide and Help pages. Also remove net.isOnline() pre-checks from Git.commitAndSync and Git.forcePull to avoid false-negative network detections.
* Fix blank wiki after hide+reopen: re-attach orphaned views on realign
Root cause: three compounding issues when the main window is hidden and then re-shown via a second-instance shortcut click.
1. getView() now auto-removes stale entries whose webContents.isDestroyed() == true.
This allows addView() / showWorkspaceView() to recreate destroyed views instead of
silently skipping them (which left the new window blank).
2. realignView() now calls browserWindow.contentView.addChildView(view) before setBounds().
If a view survived window destruction but became orphaned (detached from its parent
BrowserWindow), re-attaching it makes it visible again. addChildView is idempotent
so normal re-entrant calls are safe.
3. window.open() existing-window branch now calls addViewForAllBrowserViews(activeWorkspace)
before realignActiveWorkspace(). This ensures that any destroyed/missing view is
recreated BEFORE the realign attempts to reposition it. The call is a no-op when
views already exist and are healthy.
* Fix blank WebContentsView after restoring hidden window (Windows bug)
Electron on Windows sometimes fails to repaint a WebContentsView that remains attached to a window that is hidden and then shown again. By unconditionally calling \
emoveChildView\ followed by \ddChildView\ during \
ealignView\ and \showView\, we force the Chromium compositor to reparent and paint the view correctly, ensuring the Wiki becomes visible as soon as the user restores the app from the background.
* Fix blank WebView on window restore: show view before realign, fix same-workspace click
Two root causes identified and fixed:
1. openWorkspaceTiddler silently skipped setActiveWorkspaceView when the user
clicked the already-active workspace icon (guard: oldId !== newId). The view
was blank and clicking its icon did nothing. Guard removed setActiveWorkspaceView
is now always called; it is safe with the same ID (hibernation guard is already
correct for that case).
2. The 'show' event handler and window.open() existing-window path were calling
realignActiveWorkspace() which only calls setBounds. On Windows, when a window
transitions from hidden/background to visible the Chromium compositor may not
repaint a WebContentsView whose bounds have not changed. Both paths now call
refreshActiveWorkspaceView() a new lightweight helper that calls showView()
(removeChildView + addChildView + setBounds + webContents.focus) before realigning.
This forces a compositor repaint and makes the wiki page visible immediately.
* Refactor view restore chain: clean up redundant repaint/realign calls
Full chain analysis identified 4 structural problems:
1. refreshActiveWorkspaceView() called TWICE concurrently on window restore:
window.open() called existedWindow.show() which fired the 'show' event
refreshActiveWorkspaceView() AND THEN immediately called refreshActiveWorkspaceView()
again explicitly, creating a race condition on removeChildView+addChildView.
2. realignView() contained removeChildView+addChildView, which ran immediately after
showView() already did removeChildView+addChildView+setBounds+focus. The second
remove+add clobbered the focus state set by showView, breaking keyboard focus.
3. setActiveWorkspaceView() called showWorkspaceView + realignActiveWorkspace, meaning
the view was remove+add+setBounds+focused by showView, then immediately remove+add+
setBounds-without-focus again by realignView. Double bounds, lost focus.
4. Same pattern in refreshActiveWorkspaceView: showWorkspaceView + realignActiveWorkspace.
Clean design after refactor:
- showView() = force-repaint path: remove+add+setBounds+focus (unchanged)
- realignView() = bounds-only: setBounds ONLY, no remove+add
- showWorkspaceView = calls showView for main+mini windows
- realignActiveWorkspace = calls realignView (now just setBounds) + buildMenu;
used for fullscreen/sidebar/resize events
- setActiveWorkspaceView = showWorkspaceView + buildMenu (not +realignActiveWorkspace)
- refreshActiveWorkspaceView = showWorkspaceView + buildMenu (not +realignActiveWorkspace);
called from 'show' window event (fire-and-forget: no rethrow)
- window.open() existing-window = show() only; 'show' event handler calls
refreshActiveWorkspaceView automatically, no duplicate call
* chore: bump electron-ipc-cat to 2.4.0
Rolling Observable timeout (120s initial, 60s idle) fixes git-upload-pack
timeout for large repos (100+ MB) during mobile sync.
* style: unify layout between Preferences and EditWorkspace
Use PageRoot and PageInner from PreferenceComponents to eliminate subtle padding/background differences. Resize EditWorkspace window to match Preferences. Clean up lint errors.
* Add E2E test for window-restore blank-view bug + log markers
Two changes:
1. Log markers added to aid diagnosis and enable E2E verification:
- [test-id-VIEW_SHOWN] in ViewService.showView()
- [test-id-REFRESH_ACTIVE_VIEW_START/DONE] in WorkspaceView.refreshActiveWorkspaceView()
2. New E2E feature: features/windowRestore.feature
Scenario 1: 'Wiki WebContentsView is visible immediately after restoring hidden window'
- hides main window (same path as close+runOnBackground)
- triggers second-instance via app.emit('second-instance')
- asserts [test-id-REFRESH_ACTIVE_VIEW_DONE] and [test-id-VIEW_SHOWN] log markers
- asserts browser view is within visible window bounds
- asserts wiki content is readable
Scenario 2: 'Clicking already-active workspace icon re-shows the WebContentsView'
- verifies the removed oldId !== newId guard: clicking current workspace must
now call setActiveWorkspaceView which fires showView
Two step definitions added to features/stepDefinitions/application.ts:
- 'I hide the main window as if closing with runOnBackground'
calls BrowserWindow.hide() directly in main process
- 'I reopen the main window as second instance would'
emits app 'second-instance' event in main process
* Fix E2E test: correct second-instance emit args, add wiki-ready wait in Background
Three issues found and fixed by running the tests:
1. app.emit('second-instance') argument order wrong
DeepLinkService listener: (_event, commandLine) => commandLine.pop()
Our emit: app.emit('second-instance', [], process.cwd(), {})
This made 'process.cwd()' land in commandLine, .pop() failed on a string.
Fix: app.emit('second-instance', {}, [], '', {}) fake Event first,
then empty argv array, then workingDirectory.
2. In test mode, window.open() skips existedWindow.show() to avoid UI popups.
The 'show' event never fired so refreshActiveWorkspaceView was never called
and the window stayed hidden from Playwright's perspective.
Fix: explicitly call mainWindow.show() via app.evaluate() after emitting
second-instance, replicating what production window.open() does.
3. Background used 'the browser view should be loaded and visible' which has
a 21-second timeout and fails before TiddlyWiki finishes initializing in
the test environment (pre-existing issue in defaultWiki.feature too).
Fix: replaced with deterministic log marker waits:
[test-id-WIKI_WORKER_STARTED] + [test-id-VIEW_LOADED]
plus 'I confirm the main window browser view is positioned within visible
window bounds' for a structural check without content dependency.
Result: both @window-restore scenarios pass (31/31 steps green, ~48s).
* Fix reopened main window restore after recreation and rebind view resize
Root cause on Windows was not the hide/show path, but the close+recreate path when tidgi mini window keeps the app alive while runOnBackground is false.
What was actually happening:
1. The user closed the main window.
2. The app stayed alive because tidgi mini window still existed.
3. A second-instance launch recreated a new main BrowserWindow.
4. The old workspace WebContentsView still existed in ViewService.
5. But the new main window missed the automatic restore because the BrowserWindow 'show' event fired inside handleCreateBasicWindow() before registerBrowserViewWindowListeners() attached the 'show' listener.
6. If the user then clicked the workspace icon, showView() reattached the old view manually, but its resize listener was still bound to the old destroyed BrowserWindow, so resizing the new window no longer resized the view.
Fix:
- ViewService now rebinds the debounced resize handler every time showView() attaches an existing view to a BrowserWindow.
- Window.open() now detects the recreate-main-window case for BrowserView windows and immediately calls refreshActiveWorkspaceView() if the active workspace already has an existing view instance.
This restores the view without waiting for a workspace icon click.
Why old E2E missed it:
- It simulated hide/show (runOnBackground=true) instead of the real user path (main window close + app kept alive by tidgi mini window).
- It only checked that the view was within visible bounds; it did not resize the window and assert the view filled the content area after the reopen.
New E2E coverage:
- Configures tidgiMiniWindow=true and runOnBackground=false before launch.
- Closes the main window, reopens it via second-instance, verifies refresh/view-shown markers, verifies bounds, resizes the recreated main window, and asserts the BrowserView fills the content area after the debounced resize handler runs.
- Scenario passes locally: 1 scenario, 20 steps, all green.
* Update pnpm-lock.yaml
* fix: address Copilot PR review issues
- Restore workspaceID from window.meta() in EditWorkspace (was hard-coded debug value)
- Add missing React/type imports to customComponentRegistry.ts, workspaceCustomComponentRegistry.ts, registerCustomSections.tsx, registerWorkspaceCustomSections.tsx, useSections.ts
- Fix HighlightText regex: use index parity (odd index = match) instead of stateful regex.test() with global flag
- Fix actionHandlers native.pickDirectory to read current preference value instead of passing the key string as a path
- Move PreferenceComponents import before registerCustomSections() call to fix import ordering
* fix: fix import ordering to satisfy dprint/eslint format rules
* fix: stabilize e2e selectors and EditWorkspace loading fallback
- align workspace section testids in e2e features
- migrate background-task e2e to scheduled-task selectors
- add edit workspace fallback loading when metadata/observable is late
- add deterministic switch testid for schema boolean items
- make sync snackbar assertion resilient to progress text changes
- clear draft-check timeout handle in sync service
* fix: add apiKey to test provider config so isAIAvailable() returns true
The AI commit message e2e test expects both commit-now-button and
commit-now-ai-button to appear. The AI button only renders when
isAIGenerateBackupTitleEnabled() returns true, which internally calls
externalAPIService.isAIAvailable(). That method requires a non-empty
apiKey for openAICompatible providers, but the test's
createProviderConfig() never set one, causing isAIAvailable() to
return false and the AI button to never render.
* feat(gitServer): add generateFullArchive for fast mobile clone
- Add generateFullArchive() to IGitServerService interface
- Implement tar archive generation: git archive + system tar append
- Archives working tree + minimal .git metadata (HEAD, refs, objects)
- Cache by HEAD commit hash, auto-cleanup old archives
- Bump tidgi-shared to 0.1.5
* fix(e2e): resolve workspace by runtime name/folder in step defs
* fix(ci): satisfy lint rules in gitServer archive generation
399 lines
14 KiB
TypeScript
399 lines
14 KiB
TypeScript
import { ProxyPropertyType } from 'electron-ipc-cat/common';
|
|
import type { Observable } from 'rxjs';
|
|
|
|
import { AgentChannel } from '@/constants/channels';
|
|
import { AgentDefinition } from '@services/agentDefinition/interface';
|
|
import type { AgentPromptDescription } from '@services/agentInstance/promptConcat/promptConcatSchema/types';
|
|
import type { PromptConcatStreamState } from '@services/agentInstance/promptConcat/promptConcatTypes';
|
|
import type { CreateScheduledTaskInput, ScheduledTask, UpdateScheduledTaskInput } from './scheduledTaskTypes';
|
|
|
|
/**
|
|
* Content of a session instance that user chat with an agent.
|
|
* Inherits import { AgentFrameworkConfig } optional to allow fallback.
|
|
* The instance can override the definition's configuration, or fall back to using it.
|
|
*/
|
|
export interface AgentInstance extends Omit<AgentDefinition, 'name' | 'agentFrameworkConfig'> {
|
|
/** Agent description ID that generates this instance */
|
|
agentDefId: string;
|
|
/** Session name, optional in instance unlike definition */
|
|
name?: string;
|
|
/** Agent framework's config - optional, falls back to AgentDefinition.agentFrameworkConfig if not set */
|
|
agentFrameworkConfig?: Record<string, unknown>;
|
|
/**
|
|
* Message history.
|
|
* latest on top, so it's easy to get first one as user's latest input, and rest as history.
|
|
*/
|
|
messages: AgentInstanceMessage[];
|
|
status: AgentInstanceLatestStatus;
|
|
/** Session creation time (converted from ISO string) */
|
|
created: Date;
|
|
/**
|
|
* Last update time (converted from ISO string).
|
|
* We don't need `created` for message because it might be stream generated, we only care about its complete time.
|
|
*/
|
|
modified?: Date;
|
|
/**
|
|
* Indicates whether this agent instance is closed. Closed instances are not deleted from database
|
|
* but are hidden from the default list and don't consume resources.
|
|
*/
|
|
closed?: boolean;
|
|
/**
|
|
* Indicates whether this agent instance is a preview instance used for testing during agent creation.
|
|
* Preview instances are excluded from normal agent instance lists and should be cleaned up automatically.
|
|
*/
|
|
volatile?: boolean;
|
|
/**
|
|
* Indicates this instance was spawned by another agent (sub-agent).
|
|
* Sub-agent instances are hidden from the default user-facing list.
|
|
*/
|
|
isSubAgent?: boolean;
|
|
/** Parent agent instance ID if this is a sub-agent */
|
|
parentAgentId?: string;
|
|
}
|
|
|
|
/**
|
|
* Represents the state of a task within the A2A protocol.
|
|
* @description An enumeration.
|
|
*/
|
|
export type AgentInstanceState =
|
|
| 'submitted'
|
|
| 'working'
|
|
| 'input-required'
|
|
| 'completed'
|
|
| 'canceled'
|
|
| 'failed'
|
|
| 'unknown';
|
|
|
|
/**
|
|
* Represents the status of a task at a specific point in time.
|
|
*/
|
|
export interface AgentInstanceLatestStatus {
|
|
/**
|
|
* The current state of the task.
|
|
*/
|
|
state: AgentInstanceState;
|
|
|
|
/**
|
|
* An optional message associated with the current status (e.g., progress update, final response).
|
|
* @default undefined
|
|
*/
|
|
message?: AgentInstanceMessage;
|
|
|
|
/** Creation time (converted from ISO string) */
|
|
created?: Date;
|
|
/** Last update time (converted from ISO string) */
|
|
modified?: Date;
|
|
}
|
|
|
|
export interface AgentInstanceMessage {
|
|
/** Message nano ID */
|
|
id: string;
|
|
agentId: string;
|
|
/** Message role */
|
|
role: 'user' | 'assistant' | 'agent' | 'tool' | 'error';
|
|
/** Message content */
|
|
content: string;
|
|
/**
|
|
* Reasoning or thinking content, separated from main content
|
|
* Primarily used with DeepSeek which returns reasoning content separately
|
|
*/
|
|
reasoning_content?: string;
|
|
contentType?: string; // 'text/plain' | 'text/markdown' | 'text/html' | 'application/json' | 'application/json+ndjson';
|
|
/** Creation time (converted from ISO string) */
|
|
created?: Date;
|
|
/** Last update time (converted from ISO string) */
|
|
modified?: Date;
|
|
/** Message metadata */
|
|
metadata?: Record<string, unknown>;
|
|
/** Whether this message should be hidden from UI/history (default: false) */
|
|
hidden?: boolean;
|
|
/**
|
|
* Duration in rounds that this message should be included in AI context
|
|
* When set to a number > 0, the message will only be sent to AI for that many rounds from current position
|
|
* undefined/null means the message persists in AI context indefinitely (default behavior)
|
|
* 0 means the message is excluded from AI context immediately but remains visible in UI
|
|
*/
|
|
duration?: number | null;
|
|
}
|
|
|
|
export interface AgentBackgroundTask {
|
|
agentId: string;
|
|
agentName?: string;
|
|
type: 'heartbeat' | 'alarm';
|
|
intervalSeconds?: number;
|
|
activeHoursStart?: string;
|
|
activeHoursEnd?: string;
|
|
wakeAtISO?: string;
|
|
nextWakeAtISO?: string;
|
|
message?: string;
|
|
repeatIntervalMinutes?: number;
|
|
createdBy?: string;
|
|
lastRunAtISO?: string;
|
|
runCount?: number;
|
|
}
|
|
|
|
export interface SetBackgroundAlarmInput {
|
|
wakeAtISO: string;
|
|
message?: string;
|
|
repeatIntervalMinutes?: number;
|
|
}
|
|
|
|
export interface SetBackgroundHeartbeatInput {
|
|
enabled: boolean;
|
|
intervalSeconds: number;
|
|
message?: string;
|
|
activeHoursStart?: string;
|
|
activeHoursEnd?: string;
|
|
}
|
|
|
|
/**
|
|
* Agent instance service to manage chat instances and messages
|
|
*/
|
|
export interface IAgentInstanceService {
|
|
/**
|
|
* Initialize the service on application startup
|
|
*/
|
|
initialize(): Promise<void>;
|
|
/**
|
|
* For testing purposes, only initialize the built-in handlers without database
|
|
*/
|
|
initializeFrameworks(): Promise<void>;
|
|
|
|
/**
|
|
* Create a new agent instance from a definition
|
|
* @param agentDefinitionID Agent definition ID, if not provided, will use the default agent
|
|
* @param options Additional options for creating the agent instance
|
|
*/
|
|
createAgent(agentDefinitionID?: string, options?: { preview?: boolean; volatile?: boolean }): Promise<AgentInstance>;
|
|
|
|
/**
|
|
* Send a message or file to an agent instance, and put response to observables. Persistence and tool calling is handled by the plugins.
|
|
* @param agentId Agent ID
|
|
* @param content Message content including text, optional file, and optional wiki tiddlers
|
|
*/
|
|
sendMsgToAgent(agentId: string, content: {
|
|
text: string;
|
|
file?: File;
|
|
/**
|
|
* Wiki tiddlers to attach. Each entry contains workspace name and tiddler title.
|
|
* The rendered HTML content of these tiddlers will be fetched and included in the prompt.
|
|
*/
|
|
wikiTiddlers?: Array<{ workspaceName: string; tiddlerTitle: string }>;
|
|
}): Promise<void>;
|
|
|
|
/**
|
|
* Subscribe to agent instance updates
|
|
* @param agentId Agent instance ID
|
|
*/
|
|
subscribeToAgentUpdates(agentId: string): Observable<AgentInstance | undefined>;
|
|
/**
|
|
* Subscribe to agent instance message status updates
|
|
* @param agentId Agent instance ID
|
|
* @param messageId Message ID
|
|
*/
|
|
subscribeToAgentUpdates(agentId: string, messageId: string): Observable<AgentInstanceLatestStatus | undefined>;
|
|
|
|
/**
|
|
* Get agent instance data by ID
|
|
* @param agentId Agent instance ID
|
|
*/
|
|
getAgent(agentId: string): Promise<AgentInstance | undefined>;
|
|
|
|
/**
|
|
* Update agent instance data
|
|
* @param agentId Agent instance ID
|
|
* @param data Updated data
|
|
*/
|
|
updateAgent(agentId: string, data: Partial<AgentInstance>): Promise<AgentInstance>;
|
|
|
|
/**
|
|
* Delete agent instance and all its messages
|
|
* @param agentId Agent instance ID
|
|
*/
|
|
deleteAgent(agentId: string): Promise<void>;
|
|
|
|
/**
|
|
* Cancel current operations for agent instance
|
|
* @param agentId Agent instance ID
|
|
*/
|
|
cancelAgent(agentId: string): Promise<void>;
|
|
|
|
/**
|
|
* Get all agent instances with pagination and optional filters
|
|
* Only return light-weight instance data without messages to avoid unnecessary payload.
|
|
* @param page Page number
|
|
* @param pageSize Number of items per page
|
|
* @param options Filter options
|
|
*/
|
|
getAgents(page: number, pageSize: number, options?: { closed?: boolean; searchName?: string }): Promise<Omit<AgentInstance, 'messages'>[]>;
|
|
|
|
/**
|
|
* Close agent instance without deleting it
|
|
* @param agentId Agent instance ID
|
|
*/
|
|
closeAgent(agentId: string): Promise<void>;
|
|
|
|
/**
|
|
* Pure function to concatenate prompts with given prompt description and messages
|
|
* This is useful for front-end to generate prompts from configurations.
|
|
* Returns an Observable stream that yields intermediate processing states and final result
|
|
* @param promptDescription Configuration for prompt generation
|
|
* @param messages Messages to be included in prompt generation
|
|
* @returns Observable stream of processing states, with final state containing complete results
|
|
*/
|
|
concatPrompt(promptDescription: Pick<AgentPromptDescription, 'agentFrameworkConfig'>, messages: AgentInstanceMessage[]): Observable<PromptConcatStreamState>;
|
|
|
|
/**
|
|
* Get JSON Schema for handler configuration
|
|
* This allows frontend to generate a form based on the schema for a specific handler
|
|
* @param agentFrameworkID Handler ID to get schema for
|
|
* @returns JSON Schema for handler configuration
|
|
*/
|
|
getFrameworkConfigSchema(frameworkId: string): Record<string, unknown>;
|
|
|
|
/**
|
|
* Save user message to database
|
|
* Made public so plugins can use it for message persistence
|
|
* @param userMessage User message to save
|
|
*/
|
|
saveUserMessage(userMessage: AgentInstanceMessage): Promise<void>;
|
|
|
|
/**
|
|
* Debounced message update to reduce database writes
|
|
* Made public so plugins can use it for UI updates
|
|
* @param message Message to update
|
|
* @param agentId Agent ID for status subscribers
|
|
* @param debounceMs Debounce delay in milliseconds
|
|
*/
|
|
debounceUpdateMessage(message: AgentInstanceMessage, agentId?: string, debounceMs?: number): void;
|
|
|
|
/**
|
|
* Resolve a pending tool approval request from the UI
|
|
* @param approvalId The approval request ID
|
|
* @param decision 'allow' or 'deny'
|
|
*/
|
|
resolveToolApproval(approvalId: string, decision: 'allow' | 'deny'): Promise<void>;
|
|
|
|
/**
|
|
* Resolve a pending ask-question request from the UI.
|
|
* The user's answer is sent as a tool result (same turn), not as a new user message.
|
|
* @param agentId The agent instance ID
|
|
* @param questionId The question ID embedded in the ask-question tool result
|
|
* @param answer The user's answer text
|
|
*/
|
|
resolveAskQuestion(agentId: string, questionId: string, answer: string): void;
|
|
|
|
/**
|
|
* Delete specific messages from an agent instance.
|
|
* Used for turn deletion / retry — removes messages from DB and the agent's message list.
|
|
* @param agentId Agent instance ID
|
|
* @param messageIds Array of message IDs to delete
|
|
*/
|
|
deleteMessages(agentId: string, messageIds: string[]): Promise<void>;
|
|
|
|
/**
|
|
* Rollback file changes made during an agent turn.
|
|
* Uses the beforeCommitHash stored in the user message metadata to restore files
|
|
* to their state before the agent turn started.
|
|
* @param agentId Agent instance ID
|
|
* @param userMessageId The user message that started the turn
|
|
* @returns Object with rollback results
|
|
*/
|
|
rollbackTurn(agentId: string, userMessageId: string): Promise<{ rolledBack: number; errors: string[] }>;
|
|
|
|
/**
|
|
* Get the list of files changed during an agent turn by comparing
|
|
* the beforeCommitHash (stored in user message metadata) with current HEAD.
|
|
* @param agentId Agent instance ID
|
|
* @param userMessageId The user message that started the turn
|
|
* @returns Array of changed files with their status
|
|
*/
|
|
getTurnChangedFiles(agentId: string, userMessageId: string): Promise<Array<{ path: string; status: string }>>;
|
|
|
|
/**
|
|
* Get all active background tasks (heartbeats + alarms) for display in settings UI.
|
|
*/
|
|
getBackgroundTasks(): Promise<AgentBackgroundTask[]>;
|
|
|
|
/**
|
|
* Cancel a background task by agent ID and type.
|
|
*/
|
|
cancelBackgroundTask(agentId: string, type: 'heartbeat' | 'alarm'): Promise<void>;
|
|
|
|
/**
|
|
* Create or update an alarm task from settings UI.
|
|
*/
|
|
setBackgroundAlarm(agentId: string, alarm: SetBackgroundAlarmInput): Promise<void>;
|
|
|
|
/**
|
|
* Create or update heartbeat configuration from settings UI.
|
|
*/
|
|
setBackgroundHeartbeat(agentId: string, heartbeat: SetBackgroundHeartbeatInput): Promise<void>;
|
|
|
|
// ── ScheduledTask CRUD (Phase 2) ──────────────────────────────────────────
|
|
|
|
/**
|
|
* Create a new scheduled task and start its timer.
|
|
*/
|
|
createScheduledTask(input: CreateScheduledTaskInput): Promise<ScheduledTask>;
|
|
|
|
/**
|
|
* Update an existing scheduled task (restarts timer with new config).
|
|
*/
|
|
updateScheduledTask(input: UpdateScheduledTaskInput): Promise<ScheduledTask>;
|
|
|
|
/**
|
|
* Delete a scheduled task and stop its timer.
|
|
*/
|
|
deleteScheduledTask(taskId: string): Promise<void>;
|
|
|
|
/**
|
|
* List all active scheduled tasks (from in-memory registry).
|
|
*/
|
|
listScheduledTasks(): Promise<ScheduledTask[]>;
|
|
|
|
/**
|
|
* List active scheduled tasks for a specific agent instance.
|
|
* Used by TabItem to show the clock indicator.
|
|
*/
|
|
listScheduledTasksForAgent(agentInstanceId: string): Promise<ScheduledTask[]>;
|
|
|
|
/**
|
|
* Return next N run times for a cron expression (for UI preview).
|
|
*/
|
|
getCronPreviewDates(expression: string, timezone?: string, count?: number): Promise<string[]>;
|
|
}
|
|
|
|
export const AgentInstanceServiceIPCDescriptor = {
|
|
channel: AgentChannel.instance,
|
|
properties: {
|
|
cancelAgent: ProxyPropertyType.Function,
|
|
closeAgent: ProxyPropertyType.Function,
|
|
concatPrompt: ProxyPropertyType.Function$,
|
|
createAgent: ProxyPropertyType.Function,
|
|
debounceUpdateMessage: ProxyPropertyType.Function,
|
|
deleteAgent: ProxyPropertyType.Function,
|
|
deleteMessages: ProxyPropertyType.Function,
|
|
getAgent: ProxyPropertyType.Function,
|
|
getAgents: ProxyPropertyType.Function,
|
|
getFrameworkConfigSchema: ProxyPropertyType.Function,
|
|
resolveToolApproval: ProxyPropertyType.Function,
|
|
resolveAskQuestion: ProxyPropertyType.Function,
|
|
saveUserMessage: ProxyPropertyType.Function,
|
|
rollbackTurn: ProxyPropertyType.Function,
|
|
sendMsgToAgent: ProxyPropertyType.Function,
|
|
subscribeToAgentUpdates: ProxyPropertyType.Function$,
|
|
getTurnChangedFiles: ProxyPropertyType.Function,
|
|
getBackgroundTasks: ProxyPropertyType.Function,
|
|
cancelBackgroundTask: ProxyPropertyType.Function,
|
|
setBackgroundAlarm: ProxyPropertyType.Function,
|
|
setBackgroundHeartbeat: ProxyPropertyType.Function,
|
|
createScheduledTask: ProxyPropertyType.Function,
|
|
updateScheduledTask: ProxyPropertyType.Function,
|
|
deleteScheduledTask: ProxyPropertyType.Function,
|
|
listScheduledTasks: ProxyPropertyType.Function,
|
|
listScheduledTasksForAgent: ProxyPropertyType.Function,
|
|
getCronPreviewDates: ProxyPropertyType.Function,
|
|
updateAgent: ProxyPropertyType.Function,
|
|
},
|
|
};
|