@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.
Files changed (43) hide show
  1. package/README.md +28 -77
  2. package/package.json +11 -14
  3. package/src/adapters/sqlite-metric-store.ts +11 -2
  4. package/src/adapters/sqlite-session-identity-store.ts +45 -0
  5. package/src/cli-commands/benchmarks.ts +140 -0
  6. package/src/cli-commands/compaction.ts +17 -0
  7. package/src/cli-commands/context.ts +49 -0
  8. package/src/cli-commands/metrics.ts +296 -0
  9. package/src/cli-commands/op.ts +40 -0
  10. package/src/cli-commands/route-args.ts +15 -0
  11. package/src/cli-commands/router.ts +207 -0
  12. package/src/cli-commands/service-daemon.ts +72 -0
  13. package/src/cli-commands/session.ts +42 -0
  14. package/src/cli-commands/support.ts +33 -0
  15. package/src/cli.ts +42 -769
  16. package/src/constants.ts +7 -0
  17. package/src/daemon.ts +13 -3
  18. package/src/db.ts +15 -1
  19. package/src/index.ts +137 -0
  20. package/src/operations/benchmark-operations.ts +12 -0
  21. package/src/operations/context-operations.ts +30 -0
  22. package/src/operations/metrics-operations.ts +77 -0
  23. package/src/operations/model-ranking-operations.ts +16 -0
  24. package/src/operations/router-operations.ts +19 -0
  25. package/src/operations/session-identity-operations.ts +15 -0
  26. package/src/operations/session-scope.ts +31 -0
  27. package/src/operations/types.ts +3 -0
  28. package/src/ports/metric-store.ts +2 -0
  29. package/src/ports/router-controller.ts +9 -9
  30. package/src/ports/session-identity-store.ts +5 -0
  31. package/src/providers/telemetry-sources.ts +2 -1
  32. package/src/router.ts +124 -67
  33. package/src/service.ts +60 -118
  34. package/src/session-identity-service.ts +55 -0
  35. package/docs/USAGE_PRIOR_ART.md +0 -64
  36. package/extension/src/benchmark-tui.ts +0 -105
  37. package/extension/src/footer.ts +0 -366
  38. package/extension/src/index.ts +0 -828
  39. package/extension/src/service-client.ts +0 -26
  40. package/extension/src/settings-tui.ts +0 -153
  41. package/extension/src/settings.ts +0 -103
  42. package/extension/src/tui.ts +0 -270
  43. 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
+ }