@allternit/gizzi-code 1.0.0 → 1.0.1

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 (158) hide show
  1. package/bin/gizzi +4 -0
  2. package/bin/gizzi-ink +5 -0
  3. package/package.json +137 -31
  4. package/src/Tool.ts +26 -0
  5. package/src/bootstrap/state.ts +165 -322
  6. package/src/commands.ts +209 -0
  7. package/src/context/QueuedMessageContext.tsx +63 -0
  8. package/src/context/fpsMetrics.tsx +30 -0
  9. package/src/context/mailbox.tsx +38 -0
  10. package/src/context/modalContext.tsx +58 -0
  11. package/src/context/notifications.tsx +240 -0
  12. package/src/context/overlayContext.tsx +151 -0
  13. package/src/context/promptOverlayContext.tsx +125 -0
  14. package/src/context/stats.tsx +220 -0
  15. package/src/context/voice.tsx +88 -0
  16. package/src/hooks/useCanUseTool.ts +11 -0
  17. package/src/hooks/useExitOnCtrlCD.ts +40 -187
  18. package/src/hooks/useExitOnCtrlCDWithKeybindings.ts +68 -0
  19. package/src/hooks/useKeybinding.ts +68 -209
  20. package/src/hooks/useTerminalSize.ts +31 -99
  21. package/src/hooks.ts +37 -0
  22. package/src/ink.ts +204 -0
  23. package/src/main.ts +7 -0
  24. package/src/types/command.ts +216 -0
  25. package/src/types/connectorText.ts +39 -0
  26. package/src/types/fileSuggestion.ts +15 -0
  27. package/src/types/generated/events_mono/claude_code/v1/claude_code_internal_event.ts +865 -0
  28. package/src/types/generated/events_mono/common/v1/auth.ts +100 -0
  29. package/src/types/generated/events_mono/growthbook/v1/growthbook_experiment_event.ts +223 -0
  30. package/src/types/generated/google/protobuf/timestamp.ts +187 -0
  31. package/src/types/hooks.ts +319 -0
  32. package/src/types/ids.ts +44 -0
  33. package/src/types/logs.ts +331 -0
  34. package/src/types/merged/index.ts +5 -0
  35. package/src/types/merged/message.ts +552 -0
  36. package/src/types/message.ts +927 -186
  37. package/src/types/messageQueueTypes.ts +21 -0
  38. package/src/types/notebook.ts +72 -0
  39. package/src/types/permissions.ts +447 -0
  40. package/src/types/plugin.ts +363 -0
  41. package/src/types/statusLine.ts +15 -0
  42. package/src/types/textInputTypes.ts +387 -0
  43. package/src/types/tools.ts +149 -0
  44. package/src/types/utils.ts +20 -0
  45. package/src/utils/advisor.ts +12 -0
  46. package/src/utils/api.ts +29 -0
  47. package/src/utils/array.ts +7 -0
  48. package/src/utils/attachments.ts +60 -0
  49. package/src/utils/auth.ts +3 -0
  50. package/src/utils/claudeInChrome/chromeNativeHost.ts +15 -0
  51. package/src/utils/claudeInChrome/common.ts +12 -0
  52. package/src/utils/claudeInChrome/mcpServer.ts +15 -0
  53. package/src/utils/computerUse/common.ts +19 -0
  54. package/src/utils/computerUse/mcpServer.ts +15 -0
  55. package/src/utils/config.ts +35 -0
  56. package/src/utils/context.ts +19 -0
  57. package/src/utils/cwd.ts +3 -0
  58. package/src/utils/debug.ts +3 -0
  59. package/src/utils/earlyInput.ts +7 -0
  60. package/src/utils/effort.ts +13 -0
  61. package/src/utils/embeddedTools.ts +12 -0
  62. package/src/utils/envUtils.ts +3 -0
  63. package/src/utils/errors.ts +3 -0
  64. package/src/utils/execFileNoThrow.ts +24 -0
  65. package/src/utils/feature-flags.ts +112 -0
  66. package/src/utils/file.ts +3 -0
  67. package/src/utils/fileHistory.ts +17 -0
  68. package/src/utils/fingerprint.ts +7 -0
  69. package/src/utils/format.ts +75 -305
  70. package/src/utils/frontmatterParser.ts +33 -0
  71. package/src/utils/fsOperations.ts +31 -0
  72. package/src/utils/fullscreen.ts +40 -350
  73. package/src/utils/git.ts +15 -0
  74. package/src/utils/imageResizer.ts +30 -0
  75. package/src/utils/lazySchema.ts +9 -0
  76. package/src/utils/log.ts +3 -0
  77. package/src/utils/markdownConfigLoader.ts +12 -0
  78. package/src/utils/messages.ts +13 -0
  79. package/src/utils/migration.ts +137 -0
  80. package/src/utils/model/providers.ts +15 -0
  81. package/src/utils/path.ts +3 -0
  82. package/src/utils/permissions/PermissionResult.ts +14 -0
  83. package/src/utils/permissions/autoModeState.ts +12 -0
  84. package/src/utils/permissions/filesystem.ts +12 -0
  85. package/src/utils/plugins/loadPluginOutputStyles.ts +12 -0
  86. package/src/utils/plugins/schemas.ts +25 -0
  87. package/src/utils/process.ts +16 -0
  88. package/src/utils/sandbox/sandbox-adapter.ts +19 -0
  89. package/src/utils/sessionStorage.ts +238 -472
  90. package/src/utils/settings/constants.ts +10 -0
  91. package/src/utils/settings/settings.ts +19 -0
  92. package/src/utils/settings/types.ts +18 -0
  93. package/src/utils/shell/shellToolUtils.ts +9 -0
  94. package/src/utils/sinks.ts +11 -0
  95. package/src/utils/sleep.ts +7 -0
  96. package/src/utils/sliceAnsi.ts +7 -0
  97. package/src/utils/slowOperations.ts +3 -0
  98. package/src/utils/startupProfiler.ts +11 -0
  99. package/src/utils/stringUtils.ts +106 -0
  100. package/src/utils/systemPromptType.ts +9 -0
  101. package/src/utils/teleport/api.ts +15 -0
  102. package/src/utils/textHighlighting.ts +16 -0
  103. package/src/utils/theme.ts +17 -0
  104. package/src/utils/thinking.ts +58 -0
  105. package/src/utils/tokens.ts +11 -0
  106. package/src/utils/toolResultStorage.ts +17 -0
  107. package/src/utils/worktreeModeEnabled.ts +7 -0
  108. package/WORKSPACE_INTEGRATION.md +0 -290
  109. package/chat-sessions/sessions-index.json +0 -98
  110. package/package.json.original +0 -31
  111. package/package.json.publish +0 -47
  112. package/src/bootstrap/state.d.ts +0 -169
  113. package/src/bootstrap/state.js +0 -261
  114. package/src/context/pack-builder.d.ts +0 -24
  115. package/src/context/pack-builder.js +0 -281
  116. package/src/hooks/useExitOnCtrlCD.d.ts +0 -86
  117. package/src/hooks/useExitOnCtrlCD.js +0 -130
  118. package/src/hooks/useKeybinding.d.ts +0 -89
  119. package/src/hooks/useKeybinding.js +0 -163
  120. package/src/hooks/useTerminalSize.d.ts +0 -41
  121. package/src/hooks/useTerminalSize.js +0 -90
  122. package/src/index.d.ts +0 -23
  123. package/src/index.js +0 -24
  124. package/src/runtime/brand/brand.d.ts +0 -488
  125. package/src/runtime/brand/brand.js +0 -464
  126. package/src/runtime/brand/brand.ts +0 -667
  127. package/src/runtime/services/tokenEstimation.d.ts +0 -187
  128. package/src/runtime/services/tokenEstimation.js +0 -423
  129. package/src/runtime/services/tokenEstimation.ts +0 -547
  130. package/src/runtime/tools/Tool.d.ts +0 -239
  131. package/src/runtime/tools/Tool.js +0 -285
  132. package/src/runtime/tools/Tool.ts +0 -524
  133. package/src/scheduler/TaskScheduler.d.ts +0 -98
  134. package/src/scheduler/TaskScheduler.js +0 -201
  135. package/src/scheduler/TaskScheduler.ts +0 -259
  136. package/src/state/AppStateStore.d.ts +0 -347
  137. package/src/state/AppStateStore.js +0 -439
  138. package/src/state/AppStateStore.ts +0 -658
  139. package/src/state/WorkspaceStateStore.d.ts +0 -43
  140. package/src/state/WorkspaceStateStore.js +0 -224
  141. package/src/state/WorkspaceStateStore.ts +0 -297
  142. package/src/types/message.d.ts +0 -190
  143. package/src/types/message.js +0 -77
  144. package/src/utils/format.d.ts +0 -126
  145. package/src/utils/format.js +0 -230
  146. package/src/utils/fullscreen.d.ts +0 -161
  147. package/src/utils/fullscreen.js +0 -277
  148. package/src/utils/sessionStorage.d.ts +0 -210
  149. package/src/utils/sessionStorage.js +0 -435
  150. package/src/watcher/WorkspaceWatcher.d.ts +0 -70
  151. package/src/watcher/WorkspaceWatcher.js +0 -191
  152. package/src/watcher/WorkspaceWatcher.ts +0 -251
  153. package/src/workspace/loader.d.ts +0 -30
  154. package/src/workspace/loader.js +0 -117
  155. package/src/workspace/types.d.ts +0 -91
  156. package/src/workspace/types.js +0 -7
  157. package/threads/thread_1775361175022.json +0 -9
  158. package/tsconfig.json +0 -14
@@ -0,0 +1,100 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.6.1
4
+ // protoc unknown
5
+ // source: events_mono/common/v1/auth.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ /** PublicApiAuth contains authentication context automatically injected by the API */
10
+ export interface PublicApiAuth {
11
+ account_id?: number | undefined
12
+ organization_uuid?: string | undefined
13
+ account_uuid?: string | undefined
14
+ }
15
+
16
+ function createBasePublicApiAuth(): PublicApiAuth {
17
+ return { account_id: 0, organization_uuid: '', account_uuid: '' }
18
+ }
19
+
20
+ export const PublicApiAuth: MessageFns<PublicApiAuth> = {
21
+ fromJSON(object: any): PublicApiAuth {
22
+ return {
23
+ account_id: isSet(object.account_id)
24
+ ? globalThis.Number(object.account_id)
25
+ : 0,
26
+ organization_uuid: isSet(object.organization_uuid)
27
+ ? globalThis.String(object.organization_uuid)
28
+ : '',
29
+ account_uuid: isSet(object.account_uuid)
30
+ ? globalThis.String(object.account_uuid)
31
+ : '',
32
+ }
33
+ },
34
+
35
+ toJSON(message: PublicApiAuth): unknown {
36
+ const obj: any = {}
37
+ if (message.account_id !== undefined) {
38
+ obj.account_id = Math.round(message.account_id)
39
+ }
40
+ if (message.organization_uuid !== undefined) {
41
+ obj.organization_uuid = message.organization_uuid
42
+ }
43
+ if (message.account_uuid !== undefined) {
44
+ obj.account_uuid = message.account_uuid
45
+ }
46
+ return obj
47
+ },
48
+
49
+ create<I extends Exact<DeepPartial<PublicApiAuth>, I>>(
50
+ base?: I,
51
+ ): PublicApiAuth {
52
+ return PublicApiAuth.fromPartial(base ?? ({} as any))
53
+ },
54
+ fromPartial<I extends Exact<DeepPartial<PublicApiAuth>, I>>(
55
+ object: I,
56
+ ): PublicApiAuth {
57
+ const message = createBasePublicApiAuth()
58
+ message.account_id = object.account_id ?? 0
59
+ message.organization_uuid = object.organization_uuid ?? ''
60
+ message.account_uuid = object.account_uuid ?? ''
61
+ return message
62
+ },
63
+ }
64
+
65
+ type Builtin =
66
+ | Date
67
+ | Function
68
+ | Uint8Array
69
+ | string
70
+ | number
71
+ | boolean
72
+ | undefined
73
+
74
+ type DeepPartial<T> = T extends Builtin
75
+ ? T
76
+ : T extends globalThis.Array<infer U>
77
+ ? globalThis.Array<DeepPartial<U>>
78
+ : T extends ReadonlyArray<infer U>
79
+ ? ReadonlyArray<DeepPartial<U>>
80
+ : T extends {}
81
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
82
+ : Partial<T>
83
+
84
+ type KeysOfUnion<T> = T extends T ? keyof T : never
85
+ type Exact<P, I extends P> = P extends Builtin
86
+ ? P
87
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & {
88
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never
89
+ }
90
+
91
+ function isSet(value: any): boolean {
92
+ return value !== null && value !== undefined
93
+ }
94
+
95
+ interface MessageFns<T> {
96
+ fromJSON(object: any): T
97
+ toJSON(message: T): unknown
98
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T
99
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T
100
+ }
@@ -0,0 +1,223 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.6.1
4
+ // protoc unknown
5
+ // source: events_mono/growthbook/v1/growthbook_experiment_event.proto
6
+
7
+ /* eslint-disable */
8
+ import { Timestamp } from '../../../google/protobuf/timestamp.js'
9
+ import { PublicApiAuth } from '../../common/v1/auth.js'
10
+
11
+ /**
12
+ * GrowthBook experiment assignment event
13
+ * This event tracks when a user is exposed to an experiment variant
14
+ * See: https://docs.growthbook.io/guide/bigquery
15
+ */
16
+ export interface GrowthbookExperimentEvent {
17
+ /** Unique event identifier (for deduplication) */
18
+ event_id?: string | undefined
19
+ /** When user was exposed to experiment (maps to GrowthBook's timestamp column) */
20
+ timestamp?: Date | undefined
21
+ /** Experiment tracking key (maps to GrowthBook's experiment_id column) */
22
+ experiment_id?: string | undefined
23
+ /** Variation index: 0=control, 1+=variants (maps to GrowthBook's variation_id column) */
24
+ variation_id?: number | undefined
25
+ /** Environment where assignment occurred */
26
+ environment?: string | undefined
27
+ /** User attributes at time of assignment */
28
+ user_attributes?: string | undefined
29
+ /** Experiment metadata */
30
+ experiment_metadata?: string | undefined
31
+ /** Device identifier for the client */
32
+ device_id?: string | undefined
33
+ /** Authentication context automatically injected by the API */
34
+ auth?: PublicApiAuth | undefined
35
+ /** Session identifier for tracking user sessions */
36
+ session_id?: string | undefined
37
+ /** Anonymous identifier for unauthenticated users */
38
+ anonymous_id?: string | undefined
39
+ /** Event metadata variables (automatically populated by internal-tools-common event_logging library) */
40
+ event_metadata_vars?: string | undefined
41
+ }
42
+
43
+ function createBaseGrowthbookExperimentEvent(): GrowthbookExperimentEvent {
44
+ return {
45
+ event_id: '',
46
+ timestamp: undefined,
47
+ experiment_id: '',
48
+ variation_id: 0,
49
+ environment: '',
50
+ user_attributes: '',
51
+ experiment_metadata: '',
52
+ device_id: '',
53
+ auth: undefined,
54
+ session_id: '',
55
+ anonymous_id: '',
56
+ event_metadata_vars: '',
57
+ }
58
+ }
59
+
60
+ export const GrowthbookExperimentEvent: MessageFns<GrowthbookExperimentEvent> =
61
+ {
62
+ fromJSON(object: any): GrowthbookExperimentEvent {
63
+ return {
64
+ event_id: isSet(object.event_id)
65
+ ? globalThis.String(object.event_id)
66
+ : '',
67
+ timestamp: isSet(object.timestamp)
68
+ ? fromJsonTimestamp(object.timestamp)
69
+ : undefined,
70
+ experiment_id: isSet(object.experiment_id)
71
+ ? globalThis.String(object.experiment_id)
72
+ : '',
73
+ variation_id: isSet(object.variation_id)
74
+ ? globalThis.Number(object.variation_id)
75
+ : 0,
76
+ environment: isSet(object.environment)
77
+ ? globalThis.String(object.environment)
78
+ : '',
79
+ user_attributes: isSet(object.user_attributes)
80
+ ? globalThis.String(object.user_attributes)
81
+ : '',
82
+ experiment_metadata: isSet(object.experiment_metadata)
83
+ ? globalThis.String(object.experiment_metadata)
84
+ : '',
85
+ device_id: isSet(object.device_id)
86
+ ? globalThis.String(object.device_id)
87
+ : '',
88
+ auth: isSet(object.auth)
89
+ ? PublicApiAuth.fromJSON(object.auth)
90
+ : undefined,
91
+ session_id: isSet(object.session_id)
92
+ ? globalThis.String(object.session_id)
93
+ : '',
94
+ anonymous_id: isSet(object.anonymous_id)
95
+ ? globalThis.String(object.anonymous_id)
96
+ : '',
97
+ event_metadata_vars: isSet(object.event_metadata_vars)
98
+ ? globalThis.String(object.event_metadata_vars)
99
+ : '',
100
+ }
101
+ },
102
+
103
+ toJSON(message: GrowthbookExperimentEvent): unknown {
104
+ const obj: any = {}
105
+ if (message.event_id !== undefined) {
106
+ obj.event_id = message.event_id
107
+ }
108
+ if (message.timestamp !== undefined) {
109
+ obj.timestamp = message.timestamp.toISOString()
110
+ }
111
+ if (message.experiment_id !== undefined) {
112
+ obj.experiment_id = message.experiment_id
113
+ }
114
+ if (message.variation_id !== undefined) {
115
+ obj.variation_id = Math.round(message.variation_id)
116
+ }
117
+ if (message.environment !== undefined) {
118
+ obj.environment = message.environment
119
+ }
120
+ if (message.user_attributes !== undefined) {
121
+ obj.user_attributes = message.user_attributes
122
+ }
123
+ if (message.experiment_metadata !== undefined) {
124
+ obj.experiment_metadata = message.experiment_metadata
125
+ }
126
+ if (message.device_id !== undefined) {
127
+ obj.device_id = message.device_id
128
+ }
129
+ if (message.auth !== undefined) {
130
+ obj.auth = PublicApiAuth.toJSON(message.auth)
131
+ }
132
+ if (message.session_id !== undefined) {
133
+ obj.session_id = message.session_id
134
+ }
135
+ if (message.anonymous_id !== undefined) {
136
+ obj.anonymous_id = message.anonymous_id
137
+ }
138
+ if (message.event_metadata_vars !== undefined) {
139
+ obj.event_metadata_vars = message.event_metadata_vars
140
+ }
141
+ return obj
142
+ },
143
+
144
+ create<I extends Exact<DeepPartial<GrowthbookExperimentEvent>, I>>(
145
+ base?: I,
146
+ ): GrowthbookExperimentEvent {
147
+ return GrowthbookExperimentEvent.fromPartial(base ?? ({} as any))
148
+ },
149
+ fromPartial<I extends Exact<DeepPartial<GrowthbookExperimentEvent>, I>>(
150
+ object: I,
151
+ ): GrowthbookExperimentEvent {
152
+ const message = createBaseGrowthbookExperimentEvent()
153
+ message.event_id = object.event_id ?? ''
154
+ message.timestamp = object.timestamp ?? undefined
155
+ message.experiment_id = object.experiment_id ?? ''
156
+ message.variation_id = object.variation_id ?? 0
157
+ message.environment = object.environment ?? ''
158
+ message.user_attributes = object.user_attributes ?? ''
159
+ message.experiment_metadata = object.experiment_metadata ?? ''
160
+ message.device_id = object.device_id ?? ''
161
+ message.auth =
162
+ object.auth !== undefined && object.auth !== null
163
+ ? PublicApiAuth.fromPartial(object.auth)
164
+ : undefined
165
+ message.session_id = object.session_id ?? ''
166
+ message.anonymous_id = object.anonymous_id ?? ''
167
+ message.event_metadata_vars = object.event_metadata_vars ?? ''
168
+ return message
169
+ },
170
+ }
171
+
172
+ type Builtin =
173
+ | Date
174
+ | Function
175
+ | Uint8Array
176
+ | string
177
+ | number
178
+ | boolean
179
+ | undefined
180
+
181
+ type DeepPartial<T> = T extends Builtin
182
+ ? T
183
+ : T extends globalThis.Array<infer U>
184
+ ? globalThis.Array<DeepPartial<U>>
185
+ : T extends ReadonlyArray<infer U>
186
+ ? ReadonlyArray<DeepPartial<U>>
187
+ : T extends {}
188
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
189
+ : Partial<T>
190
+
191
+ type KeysOfUnion<T> = T extends T ? keyof T : never
192
+ type Exact<P, I extends P> = P extends Builtin
193
+ ? P
194
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & {
195
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never
196
+ }
197
+
198
+ function fromTimestamp(t: Timestamp): Date {
199
+ let millis = (t.seconds || 0) * 1_000
200
+ millis += (t.nanos || 0) / 1_000_000
201
+ return new globalThis.Date(millis)
202
+ }
203
+
204
+ function fromJsonTimestamp(o: any): Date {
205
+ if (o instanceof globalThis.Date) {
206
+ return o
207
+ } else if (typeof o === 'string') {
208
+ return new globalThis.Date(o)
209
+ } else {
210
+ return fromTimestamp(Timestamp.fromJSON(o))
211
+ }
212
+ }
213
+
214
+ function isSet(value: any): boolean {
215
+ return value !== null && value !== undefined
216
+ }
217
+
218
+ interface MessageFns<T> {
219
+ fromJSON(object: any): T
220
+ toJSON(message: T): unknown
221
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T
222
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T
223
+ }
@@ -0,0 +1,187 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.6.1
4
+ // protoc unknown
5
+ // source: google/protobuf/timestamp.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ /**
10
+ * A Timestamp represents a point in time independent of any time zone or local
11
+ * calendar, encoded as a count of seconds and fractions of seconds at
12
+ * nanosecond resolution. The count is relative to an epoch at UTC midnight on
13
+ * January 1, 1970, in the proleptic Gregorian calendar which extends the
14
+ * Gregorian calendar backwards to year one.
15
+ *
16
+ * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
17
+ * second table is needed for interpretation, using a [24-hour linear
18
+ * smear](https://developers.google.com/time/smear).
19
+ *
20
+ * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
21
+ * restricting to that range, we ensure that we can convert to and from [RFC
22
+ * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
23
+ *
24
+ * # Examples
25
+ *
26
+ * Example 1: Compute Timestamp from POSIX `time()`.
27
+ *
28
+ * Timestamp timestamp;
29
+ * timestamp.set_seconds(time(NULL));
30
+ * timestamp.set_nanos(0);
31
+ *
32
+ * Example 2: Compute Timestamp from POSIX `gettimeofday()`.
33
+ *
34
+ * struct timeval tv;
35
+ * gettimeofday(&tv, NULL);
36
+ *
37
+ * Timestamp timestamp;
38
+ * timestamp.set_seconds(tv.tv_sec);
39
+ * timestamp.set_nanos(tv.tv_usec * 1000);
40
+ *
41
+ * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
42
+ *
43
+ * FILETIME ft;
44
+ * GetSystemTimeAsFileTime(&ft);
45
+ * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
46
+ *
47
+ * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
48
+ * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
49
+ * Timestamp timestamp;
50
+ * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
51
+ * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
52
+ *
53
+ * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
54
+ *
55
+ * long millis = System.currentTimeMillis();
56
+ *
57
+ * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
58
+ * .setNanos((int) ((millis % 1000) * 1000000)).build();
59
+ *
60
+ * Example 5: Compute Timestamp from Java `Instant.now()`.
61
+ *
62
+ * Instant now = Instant.now();
63
+ *
64
+ * Timestamp timestamp =
65
+ * Timestamp.newBuilder().setSeconds(now.getEpochSecond())
66
+ * .setNanos(now.getNano()).build();
67
+ *
68
+ * Example 6: Compute Timestamp from current time in Python.
69
+ *
70
+ * timestamp = Timestamp()
71
+ * timestamp.GetCurrentTime()
72
+ *
73
+ * # JSON Mapping
74
+ *
75
+ * In JSON format, the Timestamp type is encoded as a string in the
76
+ * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
77
+ * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
78
+ * where {year} is always expressed using four digits while {month}, {day},
79
+ * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
80
+ * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
81
+ * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
82
+ * is required. A proto3 JSON serializer should always use UTC (as indicated by
83
+ * "Z") when printing the Timestamp type and a proto3 JSON parser should be
84
+ * able to accept both UTC and other timezones (as indicated by an offset).
85
+ *
86
+ * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
87
+ * 01:30 UTC on January 15, 2017.
88
+ *
89
+ * In JavaScript, one can convert a Date object to this format using the
90
+ * standard
91
+ * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
92
+ * method. In Python, a standard `datetime.datetime` object can be converted
93
+ * to this format using
94
+ * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
95
+ * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
96
+ * the Joda Time's [`ISODateTimeFormat.dateTime()`](
97
+ * http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
98
+ * ) to obtain a formatter capable of generating timestamps in this format.
99
+ */
100
+ export interface Timestamp {
101
+ /**
102
+ * Represents seconds of UTC time since Unix epoch
103
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
104
+ * 9999-12-31T23:59:59Z inclusive.
105
+ */
106
+ seconds?: number | undefined
107
+ /**
108
+ * Non-negative fractions of a second at nanosecond resolution. Negative
109
+ * second values with fractions must still have non-negative nanos values
110
+ * that count forward in time. Must be from 0 to 999,999,999
111
+ * inclusive.
112
+ */
113
+ nanos?: number | undefined
114
+ }
115
+
116
+ function createBaseTimestamp(): Timestamp {
117
+ return { seconds: 0, nanos: 0 }
118
+ }
119
+
120
+ export const Timestamp: MessageFns<Timestamp> = {
121
+ fromJSON(object: any): Timestamp {
122
+ return {
123
+ seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0,
124
+ nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0,
125
+ }
126
+ },
127
+
128
+ toJSON(message: Timestamp): unknown {
129
+ const obj: any = {}
130
+ if (message.seconds !== undefined) {
131
+ obj.seconds = Math.round(message.seconds)
132
+ }
133
+ if (message.nanos !== undefined) {
134
+ obj.nanos = Math.round(message.nanos)
135
+ }
136
+ return obj
137
+ },
138
+
139
+ create<I extends Exact<DeepPartial<Timestamp>, I>>(base?: I): Timestamp {
140
+ return Timestamp.fromPartial(base ?? ({} as any))
141
+ },
142
+ fromPartial<I extends Exact<DeepPartial<Timestamp>, I>>(
143
+ object: I,
144
+ ): Timestamp {
145
+ const message = createBaseTimestamp()
146
+ message.seconds = object.seconds ?? 0
147
+ message.nanos = object.nanos ?? 0
148
+ return message
149
+ },
150
+ }
151
+
152
+ type Builtin =
153
+ | Date
154
+ | Function
155
+ | Uint8Array
156
+ | string
157
+ | number
158
+ | boolean
159
+ | undefined
160
+
161
+ type DeepPartial<T> = T extends Builtin
162
+ ? T
163
+ : T extends globalThis.Array<infer U>
164
+ ? globalThis.Array<DeepPartial<U>>
165
+ : T extends ReadonlyArray<infer U>
166
+ ? ReadonlyArray<DeepPartial<U>>
167
+ : T extends {}
168
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
169
+ : Partial<T>
170
+
171
+ type KeysOfUnion<T> = T extends T ? keyof T : never
172
+ type Exact<P, I extends P> = P extends Builtin
173
+ ? P
174
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & {
175
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never
176
+ }
177
+
178
+ function isSet(value: any): boolean {
179
+ return value !== null && value !== undefined
180
+ }
181
+
182
+ interface MessageFns<T> {
183
+ fromJSON(object: any): T
184
+ toJSON(message: T): unknown
185
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T
186
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T
187
+ }