@gajae-code/coding-agent 0.22.2 → 0.22.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/CHANGELOG.md +115 -0
- package/dist/types/cli/append-system-prompt.d.ts +7 -0
- package/dist/types/cli/doctor/session-owners.d.ts +8 -2
- package/dist/types/cli/public-command-errors.d.ts +1 -0
- package/dist/types/cli/session-picker.d.ts +16 -3
- package/dist/types/cli/update-cli.d.ts +0 -2
- package/dist/types/cli-ordinary.d.ts +1 -1
- package/dist/types/commands/sdk.d.ts +2 -0
- package/dist/types/config/machine-identity.d.ts +11 -0
- package/dist/types/config/model-registry.d.ts +9 -0
- package/dist/types/config/settings-schema.d.ts +84 -4
- package/dist/types/lsp/client.d.ts +9 -0
- package/dist/types/lsp/types.d.ts +2 -0
- package/dist/types/main.d.ts +40 -3
- package/dist/types/modes/components/session-held-warning.d.ts +27 -0
- package/dist/types/modes/components/session-selector.d.ts +32 -1
- package/dist/types/modes/controllers/selector-controller.d.ts +8 -1
- package/dist/types/modes/interactive-mode.d.ts +12 -1
- package/dist/types/sdk/broker/broker.d.ts +3 -0
- package/dist/types/sdk/broker/lifecycle-ledger.d.ts +5 -2
- package/dist/types/sdk/broker/lifecycle.d.ts +2 -0
- package/dist/types/sdk/broker/session-index.d.ts +11 -0
- package/dist/types/sdk/bus/index.d.ts +1 -1
- package/dist/types/sdk/host/control/dispatch.d.ts +3 -0
- package/dist/types/sdk/host/registration-test-hold.d.ts +7 -0
- package/dist/types/sdk/index.d.ts +1 -0
- package/dist/types/sdk/lifecycle/service.d.ts +3 -0
- package/dist/types/sdk/session-api-key.d.ts +11 -4
- package/dist/types/sdk/session-readonly/format.d.ts +7 -0
- package/dist/types/sdk/session.d.ts +11 -0
- package/dist/types/sdk/startup-capability.d.ts +11 -2
- package/dist/types/session/agent-session.d.ts +1 -2
- package/dist/types/session/internal/managed-session-storage.d.ts +1 -1
- package/dist/types/session/internal/session-claim-set.d.ts +168 -13
- package/dist/types/session/session-handover.d.ts +62 -0
- package/dist/types/session/session-manager.d.ts +75 -15
- package/dist/types/session/session-owner-holder.d.ts +77 -0
- package/dist/types/session/session-ownership-mode.d.ts +45 -2
- package/dist/types/session/session-ownership.d.ts +25 -29
- package/dist/types/session/yield-queue.d.ts +13 -0
- package/dist/types/tools/bash.d.ts +7 -0
- package/dist/types/tools/browser/deferred-profile-cleanup.d.ts +3 -0
- package/dist/types/tools/browser/launch.d.ts +24 -1
- package/dist/types/tools/index.d.ts +6 -0
- package/dist/types/tools/output-meta.d.ts +17 -11
- package/dist/types/tools/tool-result.d.ts +1 -0
- package/package.json +9 -7
- package/scripts/compile-args.ts +6 -3
- package/scripts/run-acp-conformance.ts +36 -10
- package/scripts/verify-gjc-sdk-canonicalization.ts +2 -0
- package/src/cli/append-system-prompt.ts +34 -0
- package/src/cli/auth-broker-cli.ts +5 -1
- package/src/cli/doctor/session-owners.ts +8 -2
- package/src/cli/public-command-errors.ts +4 -0
- package/src/cli/session-picker.ts +57 -7
- package/src/cli/update-cli.ts +0 -22
- package/src/cli-ordinary.ts +2 -17
- package/src/commands/sdk.ts +37 -15
- package/src/config/machine-identity.ts +31 -2
- package/src/config/model-registry.ts +40 -6
- package/src/config/settings-schema.ts +50 -6
- package/src/config/settings.ts +65 -3
- package/src/gjc-runtime/launch-tmux.ts +4 -1
- package/src/internal-urls/docs-index.generated.ts +12 -12
- package/src/lsp/client.ts +60 -6
- package/src/lsp/index.ts +2 -6
- package/src/lsp/types.ts +2 -0
- package/src/main.ts +364 -93
- package/src/modes/DESIGN.md +36 -0
- package/src/modes/acp/acp-agent.ts +215 -31
- package/src/modes/components/session-held-warning.ts +62 -0
- package/src/modes/components/session-selector.ts +234 -11
- package/src/modes/controllers/goal-mode-controller.ts +14 -2
- package/src/modes/controllers/selector-controller.ts +192 -3
- package/src/modes/interactive-mode.ts +40 -2
- package/src/prompts/tools/bash.md +1 -1
- package/src/prompts/tools/monitor.md +1 -1
- package/src/runtime-mcp/manager.ts +5 -1
- package/src/sdk/acp/adapter.ts +2 -0
- package/src/sdk/broker/broker.ts +29 -2
- package/src/sdk/broker/lifecycle-ledger.ts +9 -7
- package/src/sdk/broker/lifecycle.ts +280 -39
- package/src/sdk/broker/session-index.ts +24 -0
- package/src/sdk/bus/index.ts +1 -0
- package/src/sdk/bus/lifecycle-commands.ts +4 -0
- package/src/sdk/cli/session-cli.ts +8 -0
- package/src/sdk/host/control/dispatch.ts +18 -0
- package/src/sdk/host/host.ts +5 -0
- package/src/sdk/host/registration-test-hold.ts +51 -0
- package/src/sdk/host/session-runtime.test.ts +42 -0
- package/src/sdk/index.ts +10 -0
- package/src/sdk/lifecycle/service.ts +33 -10
- package/src/sdk/prompt-failure.ts +4 -0
- package/src/sdk/protocol/operation-registry.ts +7 -1
- package/src/sdk/session-api-key.ts +31 -16
- package/src/sdk/session-readonly/format.ts +10 -0
- package/src/sdk/session-readonly/scope.ts +2 -1
- package/src/sdk/session.ts +60 -7
- package/src/sdk/startup-capability.ts +27 -2
- package/src/session/agent-session.ts +411 -58
- package/src/session/internal/managed-session-storage.ts +16 -2
- package/src/session/internal/session-claim-set.ts +527 -49
- package/src/session/session-handover.ts +283 -0
- package/src/session/session-manager.ts +907 -148
- package/src/session/session-owner-holder.ts +177 -0
- package/src/session/session-ownership-mode.ts +84 -12
- package/src/session/session-ownership.ts +115 -89
- package/src/session/yield-queue.ts +43 -0
- package/src/session-import/provider-service.ts +8 -0
- package/src/setup/provider-onboarding.ts +5 -5
- package/src/task/executor.ts +2 -0
- package/src/tools/bash.ts +10 -0
- package/src/tools/browser/deferred-profile-cleanup.ts +20 -0
- package/src/tools/browser/launch.ts +133 -14
- package/src/tools/browser/registry.ts +72 -19
- package/src/tools/index.ts +10 -1
- package/src/tools/monitor.ts +267 -29
- package/src/tools/output-meta.ts +61 -28
- package/src/tools/tool-catalog.generated.ts +2 -2
- package/src/tools/tool-result.ts +5 -0
- package/dist/types/cli/macos-community-app.d.ts +0 -41
- package/src/cli/macos-community-app.ts +0 -1449
package/src/lsp/client.ts
CHANGED
|
@@ -688,6 +688,44 @@ export async function getOrCreateClient(config: ServerConfig, cwd: string, initT
|
|
|
688
688
|
return clientPromise;
|
|
689
689
|
}
|
|
690
690
|
|
|
691
|
+
/**
|
|
692
|
+
* Open documents no gjc operation has used for this long are closed before the next
|
|
693
|
+
* document opens. What a server releases on `didClose` is server-dependent; tsserver
|
|
694
|
+
* keeps the whole tsconfig program of every open document loaded and drops a project
|
|
695
|
+
* once all of its documents are closed, when it handles the next open.
|
|
696
|
+
*/
|
|
697
|
+
export const OPEN_FILE_IDLE_MS = 5 * 60 * 1000;
|
|
698
|
+
|
|
699
|
+
/** Record that a gjc operation is using an open document. */
|
|
700
|
+
function markFileUsed(client: LspClient, uri: string): void {
|
|
701
|
+
const info = client.openFiles.get(uri);
|
|
702
|
+
if (info) info.lastUsedAt = Date.now();
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/** Send `didClose` for a tracked document and forget it and its diagnostics. */
|
|
706
|
+
export async function closeDocument(client: LspClient, uri: string): Promise<void> {
|
|
707
|
+
client.openFiles.delete(uri);
|
|
708
|
+
client.diagnostics.delete(uri);
|
|
709
|
+
await sendNotification(client, "textDocument/didClose", { textDocument: { uri } });
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Close documents no gjc operation has used within {@link OPEN_FILE_IDLE_MS}.
|
|
714
|
+
* Documents with an in-flight open, sync or refresh stay open. Called before a
|
|
715
|
+
* didOpen, so the closes reach the server ahead of that open (tsserver unloads
|
|
716
|
+
* projects with no open documents while handling it). Concurrent opens each run this; an entry another call already
|
|
717
|
+
* closed (or reopened) while this one awaited a send is skipped.
|
|
718
|
+
*/
|
|
719
|
+
async function closeIdleDocuments(client: LspClient): Promise<void> {
|
|
720
|
+
const idleBefore = Date.now() - OPEN_FILE_IDLE_MS;
|
|
721
|
+
for (const [uri, info] of Array.from(client.openFiles)) {
|
|
722
|
+
if (client.openFiles.get(uri) !== info) continue;
|
|
723
|
+
if (info.lastUsedAt > idleBefore) continue;
|
|
724
|
+
if (fileOperationLocks.has(`${client.name}:${uri}`)) continue;
|
|
725
|
+
await closeDocument(client, uri);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
691
729
|
/**
|
|
692
730
|
* Ensure a file is opened in the LSP client.
|
|
693
731
|
* Sends didOpen notification if the file is not already tracked.
|
|
@@ -699,6 +737,7 @@ export async function ensureFileOpen(client: LspClient, filePath: string, signal
|
|
|
699
737
|
|
|
700
738
|
// Check if file is already open
|
|
701
739
|
if (client.openFiles.has(uri)) {
|
|
740
|
+
markFileUsed(client, uri);
|
|
702
741
|
return;
|
|
703
742
|
}
|
|
704
743
|
|
|
@@ -728,6 +767,7 @@ export async function ensureFileOpen(client: LspClient, filePath: string, signal
|
|
|
728
767
|
const languageId = detectLanguageId(filePath);
|
|
729
768
|
throwIfAborted(signal);
|
|
730
769
|
|
|
770
|
+
await closeIdleDocuments(client);
|
|
731
771
|
await sendNotification(client, "textDocument/didOpen", {
|
|
732
772
|
textDocument: {
|
|
733
773
|
uri,
|
|
@@ -737,7 +777,7 @@ export async function ensureFileOpen(client: LspClient, filePath: string, signal
|
|
|
737
777
|
},
|
|
738
778
|
});
|
|
739
779
|
|
|
740
|
-
client.openFiles.set(uri, { version: 1, languageId });
|
|
780
|
+
client.openFiles.set(uri, { version: 1, languageId, lastUsedAt: Date.now() });
|
|
741
781
|
client.lastActivity = Date.now();
|
|
742
782
|
})();
|
|
743
783
|
|
|
@@ -772,6 +812,7 @@ export async function syncContent(
|
|
|
772
812
|
const uri = fileToUri(filePath);
|
|
773
813
|
const lockKey = `${client.name}:${uri}`;
|
|
774
814
|
throwIfAborted(signal);
|
|
815
|
+
markFileUsed(client, uri);
|
|
775
816
|
|
|
776
817
|
const existingLock = fileOperationLocks.get(lockKey);
|
|
777
818
|
if (existingLock) {
|
|
@@ -788,6 +829,7 @@ export async function syncContent(
|
|
|
788
829
|
// Open file with provided content instead of reading from disk
|
|
789
830
|
const languageId = detectLanguageId(filePath);
|
|
790
831
|
throwIfAborted(signal);
|
|
832
|
+
await closeIdleDocuments(client);
|
|
791
833
|
await sendNotification(client, "textDocument/didOpen", {
|
|
792
834
|
textDocument: {
|
|
793
835
|
uri,
|
|
@@ -796,7 +838,7 @@ export async function syncContent(
|
|
|
796
838
|
text: content,
|
|
797
839
|
},
|
|
798
840
|
});
|
|
799
|
-
client.openFiles.set(uri, { version: 1, languageId });
|
|
841
|
+
client.openFiles.set(uri, { version: 1, languageId, lastUsedAt: Date.now() });
|
|
800
842
|
client.lastActivity = Date.now();
|
|
801
843
|
return;
|
|
802
844
|
}
|
|
@@ -826,6 +868,7 @@ export async function notifySaved(client: LspClient, filePath: string, signal?:
|
|
|
826
868
|
const uri = fileToUri(filePath);
|
|
827
869
|
const info = client.openFiles.get(uri);
|
|
828
870
|
if (!info) return; // File not open, nothing to notify
|
|
871
|
+
info.lastUsedAt = Date.now();
|
|
829
872
|
|
|
830
873
|
throwIfAborted(signal);
|
|
831
874
|
await sendNotification(client, "textDocument/didSave", {
|
|
@@ -842,6 +885,7 @@ export async function refreshFile(client: LspClient, filePath: string, signal?:
|
|
|
842
885
|
throwIfAborted(signal);
|
|
843
886
|
const uri = fileToUri(filePath);
|
|
844
887
|
const lockKey = `${client.name}:${uri}`;
|
|
888
|
+
markFileUsed(client, uri);
|
|
845
889
|
|
|
846
890
|
const existingLock = fileOperationLocks.get(lockKey);
|
|
847
891
|
if (existingLock) {
|
|
@@ -866,8 +910,10 @@ export async function refreshFile(client: LspClient, filePath: string, signal?:
|
|
|
866
910
|
content = await Bun.file(filePath).text();
|
|
867
911
|
throwIfAborted(signal);
|
|
868
912
|
} catch (err) {
|
|
869
|
-
if (isEnoent(err))
|
|
870
|
-
|
|
913
|
+
if (!isEnoent(err)) throw err;
|
|
914
|
+
// Deleted outside the LSP: the server must not keep serving its last text.
|
|
915
|
+
await closeDocument(client, uri);
|
|
916
|
+
return;
|
|
871
917
|
}
|
|
872
918
|
const version = ++info.version;
|
|
873
919
|
throwIfAborted(signal);
|
|
@@ -901,8 +947,16 @@ async function shutdownClientInstance(client: LspClient): Promise<void> {
|
|
|
901
947
|
const err = new Error("LSP client shutdown");
|
|
902
948
|
rejectPendingRequests(client, err);
|
|
903
949
|
|
|
904
|
-
|
|
905
|
-
|
|
950
|
+
// LSP shutdown sequence: the `shutdown` request, then the `exit` notification that
|
|
951
|
+
// tells the server to terminate itself. Process teardown only runs for a server
|
|
952
|
+
// that has not exited by the deadline.
|
|
953
|
+
const exited = client.proc.exited.catch(() => undefined);
|
|
954
|
+
const graceful = (async () => {
|
|
955
|
+
await sendRequest(client, "shutdown", null, undefined, 5_000);
|
|
956
|
+
await sendNotification(client, "exit", undefined);
|
|
957
|
+
await exited;
|
|
958
|
+
})().catch(() => {});
|
|
959
|
+
await Promise.race([graceful, Bun.sleep(5_000)]);
|
|
906
960
|
await client.owner?.dispose();
|
|
907
961
|
await client.owner?.awaitExit({ timeoutMs: 1_000 });
|
|
908
962
|
await Promise.race([client.proc.exited.catch(() => undefined), Bun.sleep(1_000)]);
|
package/src/lsp/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { formatPathRelativeToCwd, resolveToCwd } from "../tools/path-utils";
|
|
|
11
11
|
import { ToolAbortError, ToolError, throwIfAborted } from "../tools/tool-errors";
|
|
12
12
|
import { clampTimeout } from "../tools/tool-timeouts";
|
|
13
13
|
import {
|
|
14
|
+
closeDocument,
|
|
14
15
|
ensureFileOpen,
|
|
15
16
|
getActiveClients,
|
|
16
17
|
getOrCreateClient,
|
|
@@ -1578,12 +1579,7 @@ export class LspTool implements AgentTool<typeof lspSchema, LspToolDetails, Them
|
|
|
1578
1579
|
try {
|
|
1579
1580
|
const client = await getOrCreateClient(serverConfig, this.session.cwd);
|
|
1580
1581
|
for (const { oldUri } of pairs) {
|
|
1581
|
-
if (client.openFiles.has(oldUri))
|
|
1582
|
-
await sendNotification(client, "textDocument/didClose", {
|
|
1583
|
-
textDocument: { uri: oldUri },
|
|
1584
|
-
});
|
|
1585
|
-
client.openFiles.delete(oldUri);
|
|
1586
|
-
}
|
|
1582
|
+
if (client.openFiles.has(oldUri)) await closeDocument(client, oldUri);
|
|
1587
1583
|
}
|
|
1588
1584
|
await sendNotification(client, "workspace/didRenameFiles", lspParams);
|
|
1589
1585
|
} catch (err) {
|
package/src/lsp/types.ts
CHANGED
|
@@ -378,6 +378,8 @@ export interface ServerConfig {
|
|
|
378
378
|
export interface OpenFile {
|
|
379
379
|
version: number;
|
|
380
380
|
languageId: string;
|
|
381
|
+
/** When a gjc operation last used this document; long-unused documents close before the next open. */
|
|
382
|
+
lastUsedAt: number;
|
|
381
383
|
}
|
|
382
384
|
|
|
383
385
|
export interface PendingRequest {
|