@agent-api/app-engine 0.0.6 → 0.0.8
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/README.md +24 -8
- package/dist/agent/runner.d.ts +1 -0
- package/dist/agent/runner.js +35 -4
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +1 -1
- package/dist/core.d.ts +17 -0
- package/dist/core.js +9 -0
- package/dist/engine/index.d.ts +3 -50
- package/dist/engine/index.js +3 -26
- package/dist/terminal.d.ts +6 -0
- package/dist/terminal.js +4 -0
- package/dist/workbench/render-model.d.ts +1 -0
- package/dist/workbench/render-model.js +37 -8
- package/dist/workbench.d.ts +28 -0
- package/dist/workbench.js +14 -0
- package/package.json +14 -2
package/README.md
CHANGED
|
@@ -15,9 +15,9 @@ npm install @agent-api/app-engine
|
|
|
15
15
|
```ts
|
|
16
16
|
import {
|
|
17
17
|
configureAgentAppRuntime,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from "@agent-api/app-engine";
|
|
18
|
+
loginWithAPIKey,
|
|
19
|
+
runAgentTurn,
|
|
20
|
+
} from "@agent-api/app-engine/core";
|
|
21
21
|
|
|
22
22
|
configureAgentAppRuntime({
|
|
23
23
|
appName: "my-agent-app",
|
|
@@ -25,17 +25,33 @@ configureAgentAppRuntime({
|
|
|
25
25
|
appVersion: "1.0.0",
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
await loginWithAPIKey({
|
|
29
|
+
profile: "default",
|
|
30
|
+
baseURL: "https://api.agentsway.dev",
|
|
31
|
+
apiKey: process.env.AGENT_API_KEY!,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const result = await runAgentTurn({
|
|
35
|
+
profile: "default",
|
|
36
|
+
promptParts: ["Hello"],
|
|
37
|
+
});
|
|
30
38
|
```
|
|
31
39
|
|
|
32
40
|
Host applications should call `configureAgentAppRuntime()` during startup so config, profiles, and runtime files live under the host app's own platform config directory.
|
|
33
41
|
|
|
42
|
+
## Import Layers
|
|
43
|
+
|
|
44
|
+
- `@agent-api/app-engine/core`: UI-neutral APIs for auth, config, profiles, conversations, updates, local workdir setup, and agent turns.
|
|
45
|
+
- `@agent-api/app-engine/workbench`: optional app/workbench state controllers for apps that want Agent API's conversation workflow.
|
|
46
|
+
- `@agent-api/app-engine/terminal`: optional terminal-facing helpers for transcript wrapping, input viewport rendering, and spinner glyphs.
|
|
47
|
+
- `@agent-api/app-engine`: compatibility barrel that re-exports the layers above.
|
|
48
|
+
|
|
34
49
|
## Boundaries
|
|
35
50
|
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
51
|
+
- Core APIs own application state and side effects.
|
|
52
|
+
- Workbench APIs own reusable conversation/workbench semantics.
|
|
53
|
+
- Terminal APIs are optional helpers for terminal renderers.
|
|
54
|
+
- Renderers own widgets, native input controls, layout, keyboard mapping, and screen drawing.
|
|
39
55
|
|
|
40
56
|
## Local Development
|
|
41
57
|
|
package/dist/agent/runner.d.ts
CHANGED
|
@@ -115,3 +115,4 @@ export declare function agentResponseFailureMessage(response: AgentResponse): st
|
|
|
115
115
|
export declare function agentTurnEventFromStreamEvent(event: ResponseStreamEvent): AgentTurnEvent | null;
|
|
116
116
|
export declare function resolveAgentRequestTools(client: PresetToolCatalogClient, preset?: string, tools?: readonly Tool[], options?: ResolveAgentRequestToolsOptions): Promise<Tool[] | undefined>;
|
|
117
117
|
export declare function clearPresetToolCatalogCache(baseURL?: string): void;
|
|
118
|
+
export declare function localToolExecutionErrorResult(toolName: string, args: Record<string, unknown>, error: unknown): Record<string, unknown>;
|
package/dist/agent/runner.js
CHANGED
|
@@ -425,11 +425,19 @@ async function executeLocalFunctionCalls(response, registry, abortSignal, onEven
|
|
|
425
425
|
const outputs = [];
|
|
426
426
|
for (const call of pendingFunctionCalls(response)) {
|
|
427
427
|
throwIfAborted(abortSignal);
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
let args = {};
|
|
429
|
+
let result;
|
|
430
|
+
try {
|
|
431
|
+
args = call.arguments ? JSON.parse(call.arguments) : {};
|
|
432
|
+
if (!registry.has(call.name)) {
|
|
433
|
+
throw new Error(`no local handler registered for function ${call.name}`);
|
|
434
|
+
}
|
|
435
|
+
result = await registry.execute(call.name, args, abortSignal);
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
throwIfAborted(abortSignal);
|
|
439
|
+
result = localToolExecutionErrorResult(call.name, args, error);
|
|
430
440
|
}
|
|
431
|
-
const args = call.arguments ? JSON.parse(call.arguments) : {};
|
|
432
|
-
const result = await registry.execute(call.name, args, abortSignal);
|
|
433
441
|
throwIfAborted(abortSignal);
|
|
434
442
|
const action = typeof result.action === "string"
|
|
435
443
|
? result.action
|
|
@@ -461,11 +469,34 @@ async function executeLocalFunctionCalls(response, registry, abortSignal, onEven
|
|
|
461
469
|
}
|
|
462
470
|
return { outputs };
|
|
463
471
|
}
|
|
472
|
+
export function localToolExecutionErrorResult(toolName, args, error) {
|
|
473
|
+
return {
|
|
474
|
+
ok: false,
|
|
475
|
+
tool: toolName,
|
|
476
|
+
action: typeof args.action === "string" ? args.action : undefined,
|
|
477
|
+
error: {
|
|
478
|
+
message: userFacingError(error),
|
|
479
|
+
name: error instanceof Error ? error.name : undefined,
|
|
480
|
+
code: errorCode(error),
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
}
|
|
464
484
|
function throwIfAborted(signal) {
|
|
465
485
|
if (!signal?.aborted)
|
|
466
486
|
return;
|
|
467
487
|
throw new Error("Agent turn aborted.");
|
|
468
488
|
}
|
|
489
|
+
function userFacingError(error) {
|
|
490
|
+
if (error instanceof Error)
|
|
491
|
+
return error.message;
|
|
492
|
+
return String(error);
|
|
493
|
+
}
|
|
494
|
+
function errorCode(error) {
|
|
495
|
+
if (typeof error !== "object" || error === null)
|
|
496
|
+
return undefined;
|
|
497
|
+
const code = error.code;
|
|
498
|
+
return typeof code === "string" || typeof code === "number" ? code : undefined;
|
|
499
|
+
}
|
|
469
500
|
function requestAbortOptions(signal) {
|
|
470
501
|
return signal ? { signal } : undefined;
|
|
471
502
|
}
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { type AgentRunOptions, type AgentTurnEvent, type AgentTurnResult, type LocalToolApprovalRequest, type WorkdirAccessMode, agentResponseFailureMessage, agentTurnEventFromStreamEvent, clearPresetToolCatalogCache, isAvailablePreset, listAvailablePresets, resolveAgentRequestTools, resumeAgentAfterLocalApproval, runAgent, runAgentTurn, } from "./agent/runner.js";
|
|
1
|
+
export { type AgentRunOptions, type AgentTurnEvent, type AgentTurnResult, type LocalToolApprovalRequest, type WorkdirAccessMode, agentResponseFailureMessage, agentTurnEventFromStreamEvent, clearPresetToolCatalogCache, isAvailablePreset, listAvailablePresets, localToolExecutionErrorResult, resolveAgentRequestTools, resumeAgentAfterLocalApproval, runAgent, runAgentTurn, } from "./agent/runner.js";
|
|
2
2
|
export { conversationSummary, deleteConversation, ensureConversation, getConversation, listConversations, startFreshConversation, } from "./conversation/index.js";
|
package/dist/agent.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { agentResponseFailureMessage, agentTurnEventFromStreamEvent, clearPresetToolCatalogCache, isAvailablePreset, listAvailablePresets, resolveAgentRequestTools, resumeAgentAfterLocalApproval, runAgent, runAgentTurn, } from "./agent/runner.js";
|
|
1
|
+
export { agentResponseFailureMessage, agentTurnEventFromStreamEvent, clearPresetToolCatalogCache, isAvailablePreset, listAvailablePresets, localToolExecutionErrorResult, resolveAgentRequestTools, resumeAgentAfterLocalApproval, runAgent, runAgentTurn, } from "./agent/runner.js";
|
|
2
2
|
export { conversationSummary, deleteConversation, ensureConversation, getConversation, listConversations, startFreshConversation, } from "./conversation/index.js";
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type { AgentEngineApp, AgentEngineAppOptions, AgentEngineLifecycleOptions, } from "./engine/agent-engine.js";
|
|
2
|
+
export { createAgentEngine, } from "./engine/agent-engine.js";
|
|
3
|
+
export type { AgentRunOptions, AgentTurnEvent, AgentTurnResult, LocalToolApprovalRequest, WorkdirAccessMode, } from "./agent.js";
|
|
4
|
+
export { agentResponseFailureMessage, agentTurnEventFromStreamEvent, clearPresetToolCatalogCache, conversationSummary, deleteConversation, ensureConversation, getConversation, isAvailablePreset, listAvailablePresets, listConversations, localToolExecutionErrorResult, resolveAgentRequestTools, resumeAgentAfterLocalApproval, runAgent, runAgentTurn, startFreshConversation, } from "./agent.js";
|
|
5
|
+
export type { ChatOptions } from "./chat-options.js";
|
|
6
|
+
export { normalizeChatOptions } from "./chat-options.js";
|
|
7
|
+
export type { AgentEngineServices } from "./engine/services.js";
|
|
8
|
+
export { defaultBaseURL } from "./config.js";
|
|
9
|
+
export type { AuthProfile, ConversationState, Profile, WorkbenchPreferences, } from "./config.js";
|
|
10
|
+
export { activeProfile, loadAppConfiguration, loadConfig, loadConversationConfiguration, loadWorkbenchPreferences, redactSecret, saveAppConfiguration, saveConfig, saveConversationConfiguration, updateWorkbenchPreferences, } from "./config.js";
|
|
11
|
+
export type { AuthStatus, RuntimeProfile, } from "./profile.js";
|
|
12
|
+
export { AuthSessionExpiredError, browserAccessTokenExpiresWithin, deleteProfile, formatDeviceUserCode, getAuthStatus, listProfiles, loginWithAPIKey, loginWithBrowser, openBrowserURL, profileSummary, refreshActiveProfileIfNeeded, refreshBrowserSession, refreshIfNeeded, resolveRuntimeProfile, saveBrowserProfile, startBrowserAuthChallenge, useProfile, waitForBrowserAuthChallenge, } from "./profile.js";
|
|
13
|
+
export { appVersion, configureAgentAppRuntime, currentAgentAppRuntime, defaultAppAuthor, defaultAppName, defaultAppVersion, ensureRuntime, runtime, } from "./runtime/index.js";
|
|
14
|
+
export type { AgentAppRuntimeContext, AgentAppRuntimeOptions, } from "./runtime/index.js";
|
|
15
|
+
export { checkForUpdate, compareVersions, formatUpdateNotice, } from "./update.js";
|
|
16
|
+
export type { WorkdirContextOptions, WorkdirOptions, WorkdirService, } from "./workdir/index.js";
|
|
17
|
+
export { buildWorkdirContextBlock, openWorkdir, } from "./workdir/index.js";
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { createAgentEngine, } from "./engine/agent-engine.js";
|
|
2
|
+
export { agentResponseFailureMessage, agentTurnEventFromStreamEvent, clearPresetToolCatalogCache, conversationSummary, deleteConversation, ensureConversation, getConversation, isAvailablePreset, listAvailablePresets, listConversations, localToolExecutionErrorResult, resolveAgentRequestTools, resumeAgentAfterLocalApproval, runAgent, runAgentTurn, startFreshConversation, } from "./agent.js";
|
|
3
|
+
export { normalizeChatOptions } from "./chat-options.js";
|
|
4
|
+
export { defaultBaseURL } from "./config.js";
|
|
5
|
+
export { activeProfile, loadAppConfiguration, loadConfig, loadConversationConfiguration, loadWorkbenchPreferences, redactSecret, saveAppConfiguration, saveConfig, saveConversationConfiguration, updateWorkbenchPreferences, } from "./config.js";
|
|
6
|
+
export { AuthSessionExpiredError, browserAccessTokenExpiresWithin, deleteProfile, formatDeviceUserCode, getAuthStatus, listProfiles, loginWithAPIKey, loginWithBrowser, openBrowserURL, profileSummary, refreshActiveProfileIfNeeded, refreshBrowserSession, refreshIfNeeded, resolveRuntimeProfile, saveBrowserProfile, startBrowserAuthChallenge, useProfile, waitForBrowserAuthChallenge, } from "./profile.js";
|
|
7
|
+
export { appVersion, configureAgentAppRuntime, currentAgentAppRuntime, defaultAppAuthor, defaultAppName, defaultAppVersion, ensureRuntime, runtime, } from "./runtime/index.js";
|
|
8
|
+
export { checkForUpdate, compareVersions, formatUpdateNotice, } from "./update.js";
|
|
9
|
+
export { buildWorkdirContextBlock, openWorkdir, } from "./workdir/index.js";
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -1,50 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export { agentResponseFailureMessage, agentTurnEventFromStreamEvent, clearPresetToolCatalogCache, conversationSummary, deleteConversation, ensureConversation, getConversation, isAvailablePreset, listAvailablePresets, listConversations, resumeAgentAfterLocalApproval, runAgent, resolveAgentRequestTools, runAgentTurn, startFreshConversation, } from "../agent.js";
|
|
5
|
-
export type { ChatOptions } from "../chat-options.js";
|
|
6
|
-
export { normalizeChatOptions } from "../chat-options.js";
|
|
7
|
-
export type { AgentEngineServices } from "./services.js";
|
|
8
|
-
export { defaultBaseURL } from "../config.js";
|
|
9
|
-
export type { AuthProfile, ConversationState, Profile, WorkbenchPreferences, } from "../config.js";
|
|
10
|
-
export { activeProfile, loadAppConfiguration, loadConfig, loadConversationConfiguration, loadWorkbenchPreferences, redactSecret, saveAppConfiguration, saveConfig, saveConversationConfiguration, updateWorkbenchPreferences, } from "../config.js";
|
|
11
|
-
export type { AuthStatus, RuntimeProfile, } from "../profile.js";
|
|
12
|
-
export { AuthSessionExpiredError, browserAccessTokenExpiresWithin, deleteProfile, formatDeviceUserCode, getAuthStatus, listProfiles, loginWithAPIKey, loginWithBrowser, openBrowserURL, profileSummary, refreshActiveProfileIfNeeded, refreshBrowserSession, refreshIfNeeded, resolveRuntimeProfile, saveBrowserProfile, startBrowserAuthChallenge, useProfile, waitForBrowserAuthChallenge, } from "../profile.js";
|
|
13
|
-
export { appVersion, configureAgentAppRuntime, currentAgentAppRuntime, defaultAppAuthor, defaultAppName, defaultAppVersion, ensureRuntime, runtime, } from "../runtime/index.js";
|
|
14
|
-
export type { AgentAppRuntimeContext, AgentAppRuntimeOptions, } from "../runtime/index.js";
|
|
15
|
-
export { checkForUpdate, compareVersions, formatUpdateNotice, } from "../update.js";
|
|
16
|
-
export type { WorkdirContextOptions, WorkdirOptions, WorkdirService, } from "../workdir/index.js";
|
|
17
|
-
export { buildWorkdirContextBlock, openWorkdir, } from "../workdir/index.js";
|
|
18
|
-
export type { WorkbenchAuthController } from "../workbench/auth-controller.js";
|
|
19
|
-
export { authStatusText, createWorkbenchAuthController, } from "../workbench/auth-controller.js";
|
|
20
|
-
export type { AuthGateState, WorkbenchAuthGateController, } from "../workbench/auth-gate-controller.js";
|
|
21
|
-
export { authMethods, createWorkbenchAuthGateController, } from "../workbench/auth-gate-controller.js";
|
|
22
|
-
export type { WorkbenchCommandController } from "../workbench/command-controller.js";
|
|
23
|
-
export { createWorkbenchCommandController } from "../workbench/command-controller.js";
|
|
24
|
-
export type { WorkbenchConversationController } from "../workbench/conversation-controller.js";
|
|
25
|
-
export { createConversationName, createWorkbenchConversationController, defaultTranscriptExportPath, } from "../workbench/conversation-controller.js";
|
|
26
|
-
export type { WorkbenchEngine, WorkbenchSubmission, } from "../workbench/engine.js";
|
|
27
|
-
export { createWorkbenchEngine } from "../workbench/engine.js";
|
|
28
|
-
export type { WorkbenchInputController } from "../workbench/input-controller.js";
|
|
29
|
-
export { createWorkbenchInputController } from "../workbench/input-controller.js";
|
|
30
|
-
export type { IsolatorInstallConfig, IsolatorInstallOptions, IsolatorInstallResult, } from "../workbench/isolator-installer.js";
|
|
31
|
-
export { defaultIsolatorInstallPath, ensureConfiguredIsolator, installConfiguredIsolator, normalizeInstallTargetPath, normalizeInstallPath, normalizeSourceURL, relocateInstalledIsolator, validateIsolatorInstallTarget, validateInstalledIsolator, } from "../workbench/isolator-installer.js";
|
|
32
|
-
export type { WorkbenchLifecycleController, WorkbenchLifecycleEffect, } from "../workbench/lifecycle-controller.js";
|
|
33
|
-
export { createWorkbenchLifecycleController, updateNoticeEffects, } from "../workbench/lifecycle-controller.js";
|
|
34
|
-
export type { WorkbenchLocalController } from "../workbench/local-controller.js";
|
|
35
|
-
export { createWorkbenchLocalController } from "../workbench/local-controller.js";
|
|
36
|
-
export type { WorkbenchRenderModel } from "../workbench/render-model.js";
|
|
37
|
-
export { buildWorkbenchRenderModel, busySpinner, pendingLocalLabel, } from "../workbench/render-model.js";
|
|
38
|
-
export type { WorkbenchRuntimeController } from "../workbench/runtime-controller.js";
|
|
39
|
-
export { createWorkbenchRuntimeController } from "../workbench/runtime-controller.js";
|
|
40
|
-
export type { WorkbenchSession, WorkbenchSessionOptions, } from "../workbench/session.js";
|
|
41
|
-
export { createWorkbenchSession, sessionState, } from "../workbench/session.js";
|
|
42
|
-
export type { WorkbenchSettingsController, WorkbenchSettingsSnapshot, } from "../workbench/settings-controller.js";
|
|
43
|
-
export { createWorkbenchSettingsController, formatPresetList, UnknownPresetError, } from "../workbench/settings-controller.js";
|
|
44
|
-
export type { ShellIsolationMode, ShellIsolationPreferences, } from "../workbench/shell-isolation.js";
|
|
45
|
-
export { localShellIsolationOptions } from "../workbench/shell-isolation.js";
|
|
46
|
-
export type { WorkbenchTurnController } from "../workbench/turn-controller.js";
|
|
47
|
-
export { createWorkbenchTurnController } from "../workbench/turn-controller.js";
|
|
48
|
-
export { buildTranscriptLines, buildTranscriptViewModel, elapsedDots, spinnerGlyph, } from "../workbench/view-model.js";
|
|
49
|
-
export type { ActivityLevel, InputHistory, LocalToolApproval, RenderMode, WorkbenchAction, WorkbenchActivity, WorkbenchCommand, WorkbenchMessage, WorkbenchRole, WorkbenchState, WorkbenchWorkdirStatus, } from "../workbench/state.js";
|
|
50
|
-
export { activityColor, createInitialWorkbenchState, createInputHistory, formatTranscript, formatTranscriptPreview, helpText, parsePendingApprovalCommand, parseWorkbenchCommand, workbenchReducer, workdirText, } from "../workbench/state.js";
|
|
1
|
+
export * from "../core.js";
|
|
2
|
+
export * from "../workbench.js";
|
|
3
|
+
export * from "../terminal.js";
|
package/dist/engine/index.js
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export { defaultBaseURL } from "../config.js";
|
|
5
|
-
export { activeProfile, loadAppConfiguration, loadConfig, loadConversationConfiguration, loadWorkbenchPreferences, redactSecret, saveAppConfiguration, saveConfig, saveConversationConfiguration, updateWorkbenchPreferences, } from "../config.js";
|
|
6
|
-
export { AuthSessionExpiredError, browserAccessTokenExpiresWithin, deleteProfile, formatDeviceUserCode, getAuthStatus, listProfiles, loginWithAPIKey, loginWithBrowser, openBrowserURL, profileSummary, refreshActiveProfileIfNeeded, refreshBrowserSession, refreshIfNeeded, resolveRuntimeProfile, saveBrowserProfile, startBrowserAuthChallenge, useProfile, waitForBrowserAuthChallenge, } from "../profile.js";
|
|
7
|
-
export { appVersion, configureAgentAppRuntime, currentAgentAppRuntime, defaultAppAuthor, defaultAppName, defaultAppVersion, ensureRuntime, runtime, } from "../runtime/index.js";
|
|
8
|
-
export { checkForUpdate, compareVersions, formatUpdateNotice, } from "../update.js";
|
|
9
|
-
export { buildWorkdirContextBlock, openWorkdir, } from "../workdir/index.js";
|
|
10
|
-
export { authStatusText, createWorkbenchAuthController, } from "../workbench/auth-controller.js";
|
|
11
|
-
export { authMethods, createWorkbenchAuthGateController, } from "../workbench/auth-gate-controller.js";
|
|
12
|
-
export { createWorkbenchCommandController } from "../workbench/command-controller.js";
|
|
13
|
-
export { createConversationName, createWorkbenchConversationController, defaultTranscriptExportPath, } from "../workbench/conversation-controller.js";
|
|
14
|
-
export { createWorkbenchEngine } from "../workbench/engine.js";
|
|
15
|
-
export { createWorkbenchInputController } from "../workbench/input-controller.js";
|
|
16
|
-
export { defaultIsolatorInstallPath, ensureConfiguredIsolator, installConfiguredIsolator, normalizeInstallTargetPath, normalizeInstallPath, normalizeSourceURL, relocateInstalledIsolator, validateIsolatorInstallTarget, validateInstalledIsolator, } from "../workbench/isolator-installer.js";
|
|
17
|
-
export { createWorkbenchLifecycleController, updateNoticeEffects, } from "../workbench/lifecycle-controller.js";
|
|
18
|
-
export { createWorkbenchLocalController } from "../workbench/local-controller.js";
|
|
19
|
-
export { buildWorkbenchRenderModel, busySpinner, pendingLocalLabel, } from "../workbench/render-model.js";
|
|
20
|
-
export { createWorkbenchRuntimeController } from "../workbench/runtime-controller.js";
|
|
21
|
-
export { createWorkbenchSession, sessionState, } from "../workbench/session.js";
|
|
22
|
-
export { createWorkbenchSettingsController, formatPresetList, UnknownPresetError, } from "../workbench/settings-controller.js";
|
|
23
|
-
export { localShellIsolationOptions } from "../workbench/shell-isolation.js";
|
|
24
|
-
export { createWorkbenchTurnController } from "../workbench/turn-controller.js";
|
|
25
|
-
export { buildTranscriptLines, buildTranscriptViewModel, elapsedDots, spinnerGlyph, } from "../workbench/view-model.js";
|
|
26
|
-
export { activityColor, createInitialWorkbenchState, createInputHistory, formatTranscript, formatTranscriptPreview, helpText, parsePendingApprovalCommand, parseWorkbenchCommand, workbenchReducer, workdirText, } from "../workbench/state.js";
|
|
1
|
+
export * from "../core.js";
|
|
2
|
+
export * from "../workbench.js";
|
|
3
|
+
export * from "../terminal.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { WorkbenchInputController } from "./workbench/input-controller.js";
|
|
2
|
+
export { createWorkbenchInputController } from "./workbench/input-controller.js";
|
|
3
|
+
export type { WorkbenchRenderModel } from "./workbench/render-model.js";
|
|
4
|
+
export { buildWorkbenchRenderModel, busySpinner, pendingLocalLabel, } from "./workbench/render-model.js";
|
|
5
|
+
export { buildTranscriptLines, buildTranscriptViewModel, elapsedDots, spinnerGlyph, } from "./workbench/view-model.js";
|
|
6
|
+
export { activityColor } from "./workbench/state.js";
|
package/dist/terminal.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createWorkbenchInputController } from "./workbench/input-controller.js";
|
|
2
|
+
export { buildWorkbenchRenderModel, busySpinner, pendingLocalLabel, } from "./workbench/render-model.js";
|
|
3
|
+
export { buildTranscriptLines, buildTranscriptViewModel, elapsedDots, spinnerGlyph, } from "./workbench/view-model.js";
|
|
4
|
+
export { activityColor } from "./workbench/state.js";
|
|
@@ -16,9 +16,10 @@ export function buildWorkbenchRenderModel(input) {
|
|
|
16
16
|
width: transcriptWidth,
|
|
17
17
|
});
|
|
18
18
|
const cursor = Math.max(0, Math.min(input.draft.length, input.cursor ?? input.draft.length));
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
19
|
+
const fullAccess = input.state.accessMode === "full";
|
|
20
|
+
const label = input.state.busy ? "working" : "you";
|
|
21
|
+
const inputViewportColumns = Math.max(12, terminalColumns - 10 - label.length - (fullAccess ? 14 : 0));
|
|
22
|
+
const inputViewport = inputViewportText(input.draft, cursor, inputViewportColumns);
|
|
22
23
|
return {
|
|
23
24
|
activityHeight,
|
|
24
25
|
footerText: [
|
|
@@ -43,14 +44,15 @@ export function buildWorkbenchRenderModel(input) {
|
|
|
43
44
|
workdir: input.state.workdir?.root || input.workdirFallback,
|
|
44
45
|
},
|
|
45
46
|
input: {
|
|
46
|
-
afterCursor,
|
|
47
|
-
beforeCursor,
|
|
47
|
+
afterCursor: inputViewport.afterCursor,
|
|
48
|
+
beforeCursor: inputViewport.beforeCursor,
|
|
48
49
|
busy: input.state.busy,
|
|
49
50
|
cursor,
|
|
50
|
-
cursorText,
|
|
51
|
+
cursorText: inputViewport.cursorText,
|
|
51
52
|
draft: input.draft,
|
|
52
|
-
fullAccess
|
|
53
|
-
label
|
|
53
|
+
fullAccess,
|
|
54
|
+
label,
|
|
55
|
+
viewportColumns: inputViewportColumns,
|
|
54
56
|
waitingText: `waiting for agent ${elapsedDots(input.spinnerFrame)}`,
|
|
55
57
|
},
|
|
56
58
|
terminalColumns,
|
|
@@ -70,3 +72,30 @@ export function pendingLocalLabel(state) {
|
|
|
70
72
|
export function busySpinner(frame) {
|
|
71
73
|
return spinnerGlyph(frame);
|
|
72
74
|
}
|
|
75
|
+
function inputViewportText(draft, cursor, maxColumns) {
|
|
76
|
+
if (draft.length === 0) {
|
|
77
|
+
return { beforeCursor: "", cursorText: " ", afterCursor: "" };
|
|
78
|
+
}
|
|
79
|
+
const fullWidth = Math.max(1, maxColumns - (cursor >= draft.length ? 1 : 0));
|
|
80
|
+
if (draft.length <= fullWidth) {
|
|
81
|
+
return {
|
|
82
|
+
beforeCursor: draft.slice(0, cursor),
|
|
83
|
+
cursorText: draft[cursor] ?? " ",
|
|
84
|
+
afterCursor: draft.slice(cursor + (cursor < draft.length ? 1 : 0)),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const windowColumns = Math.max(4, maxColumns - 3);
|
|
88
|
+
const maxStart = Math.max(0, draft.length - windowColumns);
|
|
89
|
+
const preferredStart = cursor >= draft.length
|
|
90
|
+
? maxStart
|
|
91
|
+
: Math.max(0, cursor - Math.floor(windowColumns * 0.65));
|
|
92
|
+
const start = Math.min(preferredStart, maxStart);
|
|
93
|
+
const end = Math.min(draft.length, start + windowColumns);
|
|
94
|
+
const visibleCursor = Math.max(start, Math.min(cursor, end));
|
|
95
|
+
const hasLeft = start > 0;
|
|
96
|
+
const hasRight = end < draft.length;
|
|
97
|
+
const beforeCursor = `${hasLeft ? "‹" : ""}${draft.slice(start, visibleCursor)}`;
|
|
98
|
+
const cursorText = draft[visibleCursor] ?? " ";
|
|
99
|
+
const afterCursor = `${draft.slice(visibleCursor + (visibleCursor < draft.length ? 1 : 0), end)}${hasRight ? "›" : ""}`;
|
|
100
|
+
return { beforeCursor, cursorText, afterCursor };
|
|
101
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type { WorkbenchAuthController } from "./workbench/auth-controller.js";
|
|
2
|
+
export { authStatusText, createWorkbenchAuthController, } from "./workbench/auth-controller.js";
|
|
3
|
+
export type { AuthGateState, WorkbenchAuthGateController, } from "./workbench/auth-gate-controller.js";
|
|
4
|
+
export { authMethods, createWorkbenchAuthGateController, } from "./workbench/auth-gate-controller.js";
|
|
5
|
+
export type { WorkbenchCommandController } from "./workbench/command-controller.js";
|
|
6
|
+
export { createWorkbenchCommandController } from "./workbench/command-controller.js";
|
|
7
|
+
export type { WorkbenchConversationController } from "./workbench/conversation-controller.js";
|
|
8
|
+
export { createConversationName, createWorkbenchConversationController, defaultTranscriptExportPath, } from "./workbench/conversation-controller.js";
|
|
9
|
+
export type { WorkbenchEngine, WorkbenchSubmission, } from "./workbench/engine.js";
|
|
10
|
+
export { createWorkbenchEngine } from "./workbench/engine.js";
|
|
11
|
+
export type { IsolatorInstallConfig, IsolatorInstallOptions, IsolatorInstallResult, } from "./workbench/isolator-installer.js";
|
|
12
|
+
export { defaultIsolatorInstallPath, ensureConfiguredIsolator, installConfiguredIsolator, normalizeInstallTargetPath, normalizeInstallPath, normalizeSourceURL, relocateInstalledIsolator, validateIsolatorInstallTarget, validateInstalledIsolator, } from "./workbench/isolator-installer.js";
|
|
13
|
+
export type { WorkbenchLifecycleController, WorkbenchLifecycleEffect, } from "./workbench/lifecycle-controller.js";
|
|
14
|
+
export { createWorkbenchLifecycleController, updateNoticeEffects, } from "./workbench/lifecycle-controller.js";
|
|
15
|
+
export type { WorkbenchLocalController } from "./workbench/local-controller.js";
|
|
16
|
+
export { createWorkbenchLocalController } from "./workbench/local-controller.js";
|
|
17
|
+
export type { WorkbenchRuntimeController } from "./workbench/runtime-controller.js";
|
|
18
|
+
export { createWorkbenchRuntimeController } from "./workbench/runtime-controller.js";
|
|
19
|
+
export type { WorkbenchSession, WorkbenchSessionOptions, } from "./workbench/session.js";
|
|
20
|
+
export { createWorkbenchSession, sessionState, } from "./workbench/session.js";
|
|
21
|
+
export type { WorkbenchSettingsController, WorkbenchSettingsSnapshot, } from "./workbench/settings-controller.js";
|
|
22
|
+
export { createWorkbenchSettingsController, formatPresetList, UnknownPresetError, } from "./workbench/settings-controller.js";
|
|
23
|
+
export type { ShellIsolationMode, ShellIsolationPreferences, } from "./workbench/shell-isolation.js";
|
|
24
|
+
export { localShellIsolationOptions } from "./workbench/shell-isolation.js";
|
|
25
|
+
export type { WorkbenchTurnController } from "./workbench/turn-controller.js";
|
|
26
|
+
export { createWorkbenchTurnController } from "./workbench/turn-controller.js";
|
|
27
|
+
export type { ActivityLevel, InputHistory, LocalToolApproval, RenderMode, WorkbenchAction, WorkbenchActivity, WorkbenchCommand, WorkbenchMessage, WorkbenchRole, WorkbenchState, WorkbenchWorkdirStatus, } from "./workbench/state.js";
|
|
28
|
+
export { createInitialWorkbenchState, createInputHistory, formatTranscript, formatTranscriptPreview, helpText, parsePendingApprovalCommand, parseWorkbenchCommand, workbenchReducer, workdirText, } from "./workbench/state.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { authStatusText, createWorkbenchAuthController, } from "./workbench/auth-controller.js";
|
|
2
|
+
export { authMethods, createWorkbenchAuthGateController, } from "./workbench/auth-gate-controller.js";
|
|
3
|
+
export { createWorkbenchCommandController } from "./workbench/command-controller.js";
|
|
4
|
+
export { createConversationName, createWorkbenchConversationController, defaultTranscriptExportPath, } from "./workbench/conversation-controller.js";
|
|
5
|
+
export { createWorkbenchEngine } from "./workbench/engine.js";
|
|
6
|
+
export { defaultIsolatorInstallPath, ensureConfiguredIsolator, installConfiguredIsolator, normalizeInstallTargetPath, normalizeInstallPath, normalizeSourceURL, relocateInstalledIsolator, validateIsolatorInstallTarget, validateInstalledIsolator, } from "./workbench/isolator-installer.js";
|
|
7
|
+
export { createWorkbenchLifecycleController, updateNoticeEffects, } from "./workbench/lifecycle-controller.js";
|
|
8
|
+
export { createWorkbenchLocalController } from "./workbench/local-controller.js";
|
|
9
|
+
export { createWorkbenchRuntimeController } from "./workbench/runtime-controller.js";
|
|
10
|
+
export { createWorkbenchSession, sessionState, } from "./workbench/session.js";
|
|
11
|
+
export { createWorkbenchSettingsController, formatPresetList, UnknownPresetError, } from "./workbench/settings-controller.js";
|
|
12
|
+
export { localShellIsolationOptions } from "./workbench/shell-isolation.js";
|
|
13
|
+
export { createWorkbenchTurnController } from "./workbench/turn-controller.js";
|
|
14
|
+
export { createInitialWorkbenchState, createInputHistory, formatTranscript, formatTranscriptPreview, helpText, parsePendingApprovalCommand, parseWorkbenchCommand, workbenchReducer, workdirText, } from "./workbench/state.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-api/app-engine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Renderer-neutral application engine for Agent API apps",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/scalebox-dev/agent-tui#readme",
|
|
@@ -18,6 +18,18 @@
|
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"import": "./dist/index.js"
|
|
20
20
|
},
|
|
21
|
+
"./core": {
|
|
22
|
+
"types": "./dist/core.d.ts",
|
|
23
|
+
"import": "./dist/core.js"
|
|
24
|
+
},
|
|
25
|
+
"./workbench": {
|
|
26
|
+
"types": "./dist/workbench.d.ts",
|
|
27
|
+
"import": "./dist/workbench.js"
|
|
28
|
+
},
|
|
29
|
+
"./terminal": {
|
|
30
|
+
"types": "./dist/terminal.d.ts",
|
|
31
|
+
"import": "./dist/terminal.js"
|
|
32
|
+
},
|
|
21
33
|
"./package.json": "./package.json"
|
|
22
34
|
},
|
|
23
35
|
"scripts": {
|
|
@@ -29,7 +41,7 @@
|
|
|
29
41
|
"pack:local": "npm pack --pack-destination ./artifacts"
|
|
30
42
|
},
|
|
31
43
|
"dependencies": {
|
|
32
|
-
"@agent-api/sdk": "^1.3.
|
|
44
|
+
"@agent-api/sdk": "^1.3.1",
|
|
33
45
|
"zod": "^4.4.3"
|
|
34
46
|
},
|
|
35
47
|
"devDependencies": {
|