@danypops/jittor 0.10.0 → 0.12.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/README.md +28 -77
- package/package.json +11 -14
- package/src/adapters/sqlite-metric-store.ts +11 -2
- package/src/adapters/sqlite-session-identity-store.ts +45 -0
- package/src/cli-commands/benchmarks.ts +140 -0
- package/src/cli-commands/compaction.ts +17 -0
- package/src/cli-commands/context.ts +49 -0
- package/src/cli-commands/metrics.ts +296 -0
- package/src/cli-commands/op.ts +40 -0
- package/src/cli-commands/route-args.ts +15 -0
- package/src/cli-commands/router.ts +207 -0
- package/src/cli-commands/service-daemon.ts +72 -0
- package/src/cli-commands/session.ts +42 -0
- package/src/cli-commands/support.ts +33 -0
- package/src/cli.ts +42 -769
- package/src/constants.ts +7 -0
- package/src/daemon.ts +13 -3
- package/src/db.ts +15 -1
- package/src/index.ts +137 -0
- package/src/operations/benchmark-operations.ts +12 -0
- package/src/operations/context-operations.ts +30 -0
- package/src/operations/metrics-operations.ts +77 -0
- package/src/operations/model-ranking-operations.ts +16 -0
- package/src/operations/router-operations.ts +19 -0
- package/src/operations/session-identity-operations.ts +15 -0
- package/src/operations/session-scope.ts +31 -0
- package/src/operations/types.ts +3 -0
- package/src/ports/metric-store.ts +2 -0
- package/src/ports/router-controller.ts +9 -9
- package/src/ports/session-identity-store.ts +5 -0
- package/src/providers/telemetry-sources.ts +2 -1
- package/src/router.ts +124 -67
- package/src/service.ts +60 -118
- package/src/session-identity-service.ts +55 -0
- package/docs/USAGE_PRIOR_ART.md +0 -64
- package/extension/src/benchmark-tui.ts +0 -105
- package/extension/src/footer.ts +0 -366
- package/extension/src/index.ts +0 -828
- package/extension/src/service-client.ts +0 -26
- package/extension/src/settings-tui.ts +0 -153
- package/extension/src/settings.ts +0 -103
- package/extension/src/tui.ts +0 -270
- package/extension/src/usage.ts +0 -320
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HUMAN_TEXT_FIELD_MAX_CHARACTERS } from "../constants.ts";
|
|
2
|
+
import type { JittorClient } from "../client.ts";
|
|
3
|
+
import type { OperationInputs, OperationName, OperationOutputs } from "../service.ts";
|
|
4
|
+
|
|
5
|
+
export interface CliDependencies {
|
|
6
|
+
client: Pick<JittorClient, "call">;
|
|
7
|
+
stdout(line: string): void;
|
|
8
|
+
stderr(line: string): void;
|
|
9
|
+
systemctl(...args: string[]): void;
|
|
10
|
+
installService(): void;
|
|
11
|
+
serve(): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function humanField(value: string): string {
|
|
15
|
+
return value.length <= HUMAN_TEXT_FIELD_MAX_CHARACTERS ? value : `${value.slice(0, HUMAN_TEXT_FIELD_MAX_CHARACTERS - 1)}…`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function callAndPrint<Name extends OperationName>(
|
|
19
|
+
deps: CliDependencies,
|
|
20
|
+
operation: Name,
|
|
21
|
+
input: OperationInputs[Name],
|
|
22
|
+
json: boolean,
|
|
23
|
+
formatHuman: (result: OperationOutputs[Name]) => string,
|
|
24
|
+
): Promise<number> {
|
|
25
|
+
try {
|
|
26
|
+
const result = await deps.client.call(operation, input);
|
|
27
|
+
deps.stdout(json ? JSON.stringify(result) : formatHuman(result));
|
|
28
|
+
return 0;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
deps.stderr(error instanceof Error ? error.message : String(error));
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
}
|