@forge/cli-shared 10.1.0-next.6 → 10.1.0-next.7

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.
@@ -1,4 +1,7 @@
1
+ export type SessionAttributionResolver = (attribution: Record<string, unknown>) => Record<string, string>;
1
2
  export declare class ForgeCliAttribution {
3
+ private static sessionResolver;
4
+ static setSessionResolver(resolver: SessionAttributionResolver | undefined): void;
2
5
  static isAgent(): boolean;
3
6
  static isCI(): boolean;
4
7
  static isAgentV2(): Promise<boolean>;
@@ -8,6 +11,7 @@ export declare class ForgeCliAttribution {
8
11
  static agentHint(): Promise<string>;
9
12
  static isStudio(): boolean;
10
13
  static build(): Promise<Record<string, unknown>>;
14
+ private static resolveSession;
11
15
  private static getWildcardAttribution;
12
16
  private static getValidAttributionEnvValue;
13
17
  private static isValidAttributionValue;
@@ -1 +1 @@
1
- {"version":3,"file":"forge-cli-attribution.d.ts","sourceRoot":"","sources":["../../src/shared/forge-cli-attribution.ts"],"names":[],"mappings":"AA2DA,qBAAa,mBAAmB;WAShB,OAAO,IAAI,OAAO;WASlB,IAAI,IAAI,OAAO;WAST,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;WAKnC,MAAM,IAAI,OAAO;WASjB,MAAM,IAAI,MAAM;WAIhB,SAAS,IAAI,MAAM;WASb,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;WAwBlC,QAAQ,IAAI,OAAO;WAWb,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IA6B7D,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAgDrC,OAAO,CAAC,MAAM,CAAC,2BAA2B;IAK1C,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAStC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAIjC,OAAO,CAAC,MAAM,CAAC,YAAY;IAK3B,OAAO,CAAC,MAAM,CAAC,eAAe;IAS9B,OAAO,CAAC,MAAM,CAAC,UAAU;CAG1B"}
1
+ {"version":3,"file":"forge-cli-attribution.d.ts","sourceRoot":"","sources":["../../src/shared/forge-cli-attribution.ts"],"names":[],"mappings":"AA4DA,MAAM,MAAM,0BAA0B,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1G,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAC,eAAe,CAAyC;WAMzD,kBAAkB,CAAC,QAAQ,EAAE,0BAA0B,GAAG,SAAS,GAAG,IAAI;WAY1E,OAAO,IAAI,OAAO;WASlB,IAAI,IAAI,OAAO;WAST,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;WAKnC,MAAM,IAAI,OAAO;WASjB,MAAM,IAAI,MAAM;WAIhB,SAAS,IAAI,MAAM;WASb,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;WAwBlC,QAAQ,IAAI,OAAO;WAWb,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IA8B7D,OAAO,CAAC,MAAM,CAAC,cAAc;IAQ7B,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAgDrC,OAAO,CAAC,MAAM,CAAC,2BAA2B;IAK1C,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAStC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAIjC,OAAO,CAAC,MAAM,CAAC,YAAY;IAK3B,OAAO,CAAC,MAAM,CAAC,eAAe;IAS9B,OAAO,CAAC,MAAM,CAAC,UAAU;CAG1B"}
@@ -19,11 +19,16 @@ const RESERVED_ATTRIBUTION_FIELDS = new Set([
19
19
  'isStudio',
20
20
  'service',
21
21
  'skillName',
22
+ 'sessionIdSource',
22
23
  'ciHint',
23
24
  'isTerminal',
24
25
  'isUnrecognizedNonTTY'
25
26
  ].map((field) => field.toLowerCase()));
26
27
  export class ForgeCliAttribution {
28
+ static sessionResolver;
29
+ static setSessionResolver(resolver) {
30
+ this.sessionResolver = resolver;
31
+ }
27
32
  static isAgent() {
28
33
  return !process.stdin.isTTY && !process.stdout.isTTY && !this.isCI();
29
34
  }
@@ -72,7 +77,7 @@ export class ForgeCliAttribution {
72
77
  const isAgentV2 = agentHint !== UNKNOWN;
73
78
  const isCIV2 = ciHint !== UNKNOWN;
74
79
  const signals = readRunnerSignals(isAgentV2, isCIV2);
75
- return {
80
+ const attribution = {
76
81
  isAgent: this.isAgent(),
77
82
  isCI: this.isCI(),
78
83
  skillName: this.skillName(),
@@ -85,6 +90,15 @@ export class ForgeCliAttribution {
85
90
  isUnrecognizedNonTTY: String(signals.isUnrecognizedNonTTY),
86
91
  ...this.getWildcardAttribution()
87
92
  };
93
+ return { ...attribution, ...this.resolveSession(attribution) };
94
+ }
95
+ static resolveSession(attribution) {
96
+ try {
97
+ return this.sessionResolver?.(attribution) ?? {};
98
+ }
99
+ catch {
100
+ return {};
101
+ }
88
102
  }
89
103
  static getWildcardAttribution() {
90
104
  const wildcardAttribution = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/cli-shared",
3
- "version": "10.1.0-next.6",
3
+ "version": "10.1.0-next.7",
4
4
  "description": "Common functionality for Forge CLI",
5
5
  "author": "Atlassian",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",