@nextclaw/app-runtime 0.14.1 → 0.16.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 (66) hide show
  1. package/dist/index.d.ts +5 -4
  2. package/dist/index.js +2 -1
  3. package/dist/package.js +1 -1
  4. package/dist/services/app-build.service.d.ts +1 -0
  5. package/dist/services/app-build.service.d.ts.map +1 -1
  6. package/dist/services/app-build.service.js +37 -2
  7. package/dist/services/app-build.service.js.map +1 -1
  8. package/dist/services/app-grant.service.d.ts.map +1 -1
  9. package/dist/services/app-grant.service.js +1 -4
  10. package/dist/services/app-grant.service.js.map +1 -1
  11. package/dist/services/app-installation-lifecycle.service.js +29 -2
  12. package/dist/services/app-installation-lifecycle.service.js.map +1 -1
  13. package/dist/services/app-manifest.service.d.ts +1 -0
  14. package/dist/services/app-manifest.service.d.ts.map +1 -1
  15. package/dist/services/app-manifest.service.js +27 -0
  16. package/dist/services/app-manifest.service.js.map +1 -1
  17. package/dist/services/app-permissions.service.d.ts.map +1 -1
  18. package/dist/services/app-permissions.service.js +0 -3
  19. package/dist/services/app-permissions.service.js.map +1 -1
  20. package/dist/services/app-registry-parser.service.js +200 -0
  21. package/dist/services/app-registry-parser.service.js.map +1 -0
  22. package/dist/services/app-registry.service.d.ts +4 -9
  23. package/dist/services/app-registry.service.d.ts.map +1 -1
  24. package/dist/services/app-registry.service.js +40 -164
  25. package/dist/services/app-registry.service.js.map +1 -1
  26. package/dist/services/app-runtime-cli.service.js +1 -1
  27. package/dist/services/app-runtime-cli.service.js.map +1 -1
  28. package/dist/services/app-runtime-options.service.d.ts.map +1 -1
  29. package/dist/services/app-runtime-options.service.js +2 -2
  30. package/dist/services/app-runtime-options.service.js.map +1 -1
  31. package/dist/services/app-runtime-toolchain.service.d.ts +5 -2
  32. package/dist/services/app-runtime-toolchain.service.d.ts.map +1 -1
  33. package/dist/services/app-runtime-toolchain.service.js +36 -4
  34. package/dist/services/app-runtime-toolchain.service.js.map +1 -1
  35. package/dist/services/app-rust-wasi-scaffold-template.service.d.ts +24 -0
  36. package/dist/services/app-rust-wasi-scaffold-template.service.d.ts.map +1 -0
  37. package/dist/services/app-rust-wasi-scaffold-template.service.js +394 -0
  38. package/dist/services/app-rust-wasi-scaffold-template.service.js.map +1 -0
  39. package/dist/services/app-scaffold.service.d.ts +4 -2
  40. package/dist/services/app-scaffold.service.d.ts.map +1 -1
  41. package/dist/services/app-scaffold.service.js +20 -4
  42. package/dist/services/app-scaffold.service.js.map +1 -1
  43. package/dist/services/platform-auth-state.service.js +1 -1
  44. package/dist/types/app-manifest.types.d.ts +8 -1
  45. package/dist/types/app-manifest.types.d.ts.map +1 -1
  46. package/dist/types/app-manifest.types.js.map +1 -1
  47. package/dist/types/app-registry.types.d.ts +8 -1
  48. package/dist/types/app-registry.types.d.ts.map +1 -1
  49. package/package.json +2 -1
  50. package/resources/rust-wasi/Cargo.lock +454 -0
  51. package/resources/wit/deps/clocks@0.2.6/monotonic-clock.wit +50 -0
  52. package/resources/wit/deps/clocks@0.2.6/timezone.wit +55 -0
  53. package/resources/wit/deps/clocks@0.2.6/wall-clock.wit +46 -0
  54. package/resources/wit/deps/clocks@0.2.6/world.wit +11 -0
  55. package/resources/wit/deps/config@0.2.0-draft-2024-09-27/package.wit +1 -0
  56. package/resources/wit/deps/config@0.2.0-draft-2024-09-27/store.wit +9 -0
  57. package/resources/wit/deps/http@0.2.6/handler.wit +49 -0
  58. package/resources/wit/deps/http@0.2.6/package.wit +1 -0
  59. package/resources/wit/deps/http@0.2.6/types.wit +688 -0
  60. package/resources/wit/deps/io@0.2.6/error.wit +34 -0
  61. package/resources/wit/deps/io@0.2.6/poll.wit +47 -0
  62. package/resources/wit/deps/io@0.2.6/streams.wit +290 -0
  63. package/resources/wit/deps/io@0.2.6/world.wit +10 -0
  64. package/resources/wit/deps/spin@2.0.0/package.wit +1 -0
  65. package/resources/wit/deps/spin@2.0.0/sqlite.wit +50 -0
  66. package/resources/wit/portable-service.wit +120 -0
@@ -0,0 +1,34 @@
1
+ package wasi:io@0.2.6;
2
+
3
+ @since(version = 0.2.0)
4
+ interface error {
5
+ /// A resource which represents some error information.
6
+ ///
7
+ /// The only method provided by this resource is `to-debug-string`,
8
+ /// which provides some human-readable information about the error.
9
+ ///
10
+ /// In the `wasi:io` package, this resource is returned through the
11
+ /// `wasi:io/streams/stream-error` type.
12
+ ///
13
+ /// To provide more specific error information, other interfaces may
14
+ /// offer functions to "downcast" this error into more specific types. For example,
15
+ /// errors returned from streams derived from filesystem types can be described using
16
+ /// the filesystem's own error-code type. This is done using the function
17
+ /// `wasi:filesystem/types/filesystem-error-code`, which takes a `borrow<error>`
18
+ /// parameter and returns an `option<wasi:filesystem/types/error-code>`.
19
+ ///
20
+ /// The set of functions which can "downcast" an `error` into a more
21
+ /// concrete type is open.
22
+ @since(version = 0.2.0)
23
+ resource error {
24
+ /// Returns a string that is suitable to assist humans in debugging
25
+ /// this error.
26
+ ///
27
+ /// WARNING: The returned string should not be consumed mechanically!
28
+ /// It may change across platforms, hosts, or other implementation
29
+ /// details. Parsing this string is a major platform-compatibility
30
+ /// hazard.
31
+ @since(version = 0.2.0)
32
+ to-debug-string: func() -> string;
33
+ }
34
+ }
@@ -0,0 +1,47 @@
1
+ package wasi:io@0.2.6;
2
+
3
+ /// A poll API intended to let users wait for I/O events on multiple handles
4
+ /// at once.
5
+ @since(version = 0.2.0)
6
+ interface poll {
7
+ /// `pollable` represents a single I/O event which may be ready, or not.
8
+ @since(version = 0.2.0)
9
+ resource pollable {
10
+
11
+ /// Return the readiness of a pollable. This function never blocks.
12
+ ///
13
+ /// Returns `true` when the pollable is ready, and `false` otherwise.
14
+ @since(version = 0.2.0)
15
+ ready: func() -> bool;
16
+
17
+ /// `block` returns immediately if the pollable is ready, and otherwise
18
+ /// blocks until ready.
19
+ ///
20
+ /// This function is equivalent to calling `poll.poll` on a list
21
+ /// containing only this pollable.
22
+ @since(version = 0.2.0)
23
+ block: func();
24
+ }
25
+
26
+ /// Poll for completion on a set of pollables.
27
+ ///
28
+ /// This function takes a list of pollables, which identify I/O sources of
29
+ /// interest, and waits until one or more of the events is ready for I/O.
30
+ ///
31
+ /// The result `list<u32>` contains one or more indices of handles in the
32
+ /// argument list that is ready for I/O.
33
+ ///
34
+ /// This function traps if either:
35
+ /// - the list is empty, or:
36
+ /// - the list contains more elements than can be indexed with a `u32` value.
37
+ ///
38
+ /// A timeout can be implemented by adding a pollable from the
39
+ /// wasi-clocks API to the list.
40
+ ///
41
+ /// This function does not return a `result`; polling in itself does not
42
+ /// do any I/O so it doesn't fail. If any of the I/O sources identified by
43
+ /// the pollables has an error, it is indicated by marking the source as
44
+ /// being ready for I/O.
45
+ @since(version = 0.2.0)
46
+ poll: func(in: list<borrow<pollable>>) -> list<u32>;
47
+ }
@@ -0,0 +1,290 @@
1
+ package wasi:io@0.2.6;
2
+
3
+ /// WASI I/O is an I/O abstraction API which is currently focused on providing
4
+ /// stream types.
5
+ ///
6
+ /// In the future, the component model is expected to add built-in stream types;
7
+ /// when it does, they are expected to subsume this API.
8
+ @since(version = 0.2.0)
9
+ interface streams {
10
+ @since(version = 0.2.0)
11
+ use error.{error};
12
+ @since(version = 0.2.0)
13
+ use poll.{pollable};
14
+
15
+ /// An error for input-stream and output-stream operations.
16
+ @since(version = 0.2.0)
17
+ variant stream-error {
18
+ /// The last operation (a write or flush) failed before completion.
19
+ ///
20
+ /// More information is available in the `error` payload.
21
+ ///
22
+ /// After this, the stream will be closed. All future operations return
23
+ /// `stream-error::closed`.
24
+ last-operation-failed(error),
25
+ /// The stream is closed: no more input will be accepted by the
26
+ /// stream. A closed output-stream will return this error on all
27
+ /// future operations.
28
+ closed
29
+ }
30
+
31
+ /// An input bytestream.
32
+ ///
33
+ /// `input-stream`s are *non-blocking* to the extent practical on underlying
34
+ /// platforms. I/O operations always return promptly; if fewer bytes are
35
+ /// promptly available than requested, they return the number of bytes promptly
36
+ /// available, which could even be zero. To wait for data to be available,
37
+ /// use the `subscribe` function to obtain a `pollable` which can be polled
38
+ /// for using `wasi:io/poll`.
39
+ @since(version = 0.2.0)
40
+ resource input-stream {
41
+ /// Perform a non-blocking read from the stream.
42
+ ///
43
+ /// When the source of a `read` is binary data, the bytes from the source
44
+ /// are returned verbatim. When the source of a `read` is known to the
45
+ /// implementation to be text, bytes containing the UTF-8 encoding of the
46
+ /// text are returned.
47
+ ///
48
+ /// This function returns a list of bytes containing the read data,
49
+ /// when successful. The returned list will contain up to `len` bytes;
50
+ /// it may return fewer than requested, but not more. The list is
51
+ /// empty when no bytes are available for reading at this time. The
52
+ /// pollable given by `subscribe` will be ready when more bytes are
53
+ /// available.
54
+ ///
55
+ /// This function fails with a `stream-error` when the operation
56
+ /// encounters an error, giving `last-operation-failed`, or when the
57
+ /// stream is closed, giving `closed`.
58
+ ///
59
+ /// When the caller gives a `len` of 0, it represents a request to
60
+ /// read 0 bytes. If the stream is still open, this call should
61
+ /// succeed and return an empty list, or otherwise fail with `closed`.
62
+ ///
63
+ /// The `len` parameter is a `u64`, which could represent a list of u8 which
64
+ /// is not possible to allocate in wasm32, or not desirable to allocate as
65
+ /// as a return value by the callee. The callee may return a list of bytes
66
+ /// less than `len` in size while more bytes are available for reading.
67
+ @since(version = 0.2.0)
68
+ read: func(
69
+ /// The maximum number of bytes to read
70
+ len: u64
71
+ ) -> result<list<u8>, stream-error>;
72
+
73
+ /// Read bytes from a stream, after blocking until at least one byte can
74
+ /// be read. Except for blocking, behavior is identical to `read`.
75
+ @since(version = 0.2.0)
76
+ blocking-read: func(
77
+ /// The maximum number of bytes to read
78
+ len: u64
79
+ ) -> result<list<u8>, stream-error>;
80
+
81
+ /// Skip bytes from a stream. Returns number of bytes skipped.
82
+ ///
83
+ /// Behaves identical to `read`, except instead of returning a list
84
+ /// of bytes, returns the number of bytes consumed from the stream.
85
+ @since(version = 0.2.0)
86
+ skip: func(
87
+ /// The maximum number of bytes to skip.
88
+ len: u64,
89
+ ) -> result<u64, stream-error>;
90
+
91
+ /// Skip bytes from a stream, after blocking until at least one byte
92
+ /// can be skipped. Except for blocking behavior, identical to `skip`.
93
+ @since(version = 0.2.0)
94
+ blocking-skip: func(
95
+ /// The maximum number of bytes to skip.
96
+ len: u64,
97
+ ) -> result<u64, stream-error>;
98
+
99
+ /// Create a `pollable` which will resolve once either the specified stream
100
+ /// has bytes available to read or the other end of the stream has been
101
+ /// closed.
102
+ /// The created `pollable` is a child resource of the `input-stream`.
103
+ /// Implementations may trap if the `input-stream` is dropped before
104
+ /// all derived `pollable`s created with this function are dropped.
105
+ @since(version = 0.2.0)
106
+ subscribe: func() -> pollable;
107
+ }
108
+
109
+
110
+ /// An output bytestream.
111
+ ///
112
+ /// `output-stream`s are *non-blocking* to the extent practical on
113
+ /// underlying platforms. Except where specified otherwise, I/O operations also
114
+ /// always return promptly, after the number of bytes that can be written
115
+ /// promptly, which could even be zero. To wait for the stream to be ready to
116
+ /// accept data, the `subscribe` function to obtain a `pollable` which can be
117
+ /// polled for using `wasi:io/poll`.
118
+ ///
119
+ /// Dropping an `output-stream` while there's still an active write in
120
+ /// progress may result in the data being lost. Before dropping the stream,
121
+ /// be sure to fully flush your writes.
122
+ @since(version = 0.2.0)
123
+ resource output-stream {
124
+ /// Check readiness for writing. This function never blocks.
125
+ ///
126
+ /// Returns the number of bytes permitted for the next call to `write`,
127
+ /// or an error. Calling `write` with more bytes than this function has
128
+ /// permitted will trap.
129
+ ///
130
+ /// When this function returns 0 bytes, the `subscribe` pollable will
131
+ /// become ready when this function will report at least 1 byte, or an
132
+ /// error.
133
+ @since(version = 0.2.0)
134
+ check-write: func() -> result<u64, stream-error>;
135
+
136
+ /// Perform a write. This function never blocks.
137
+ ///
138
+ /// When the destination of a `write` is binary data, the bytes from
139
+ /// `contents` are written verbatim. When the destination of a `write` is
140
+ /// known to the implementation to be text, the bytes of `contents` are
141
+ /// transcoded from UTF-8 into the encoding of the destination and then
142
+ /// written.
143
+ ///
144
+ /// Precondition: check-write gave permit of Ok(n) and contents has a
145
+ /// length of less than or equal to n. Otherwise, this function will trap.
146
+ ///
147
+ /// returns Err(closed) without writing if the stream has closed since
148
+ /// the last call to check-write provided a permit.
149
+ @since(version = 0.2.0)
150
+ write: func(
151
+ contents: list<u8>
152
+ ) -> result<_, stream-error>;
153
+
154
+ /// Perform a write of up to 4096 bytes, and then flush the stream. Block
155
+ /// until all of these operations are complete, or an error occurs.
156
+ ///
157
+ /// This is a convenience wrapper around the use of `check-write`,
158
+ /// `subscribe`, `write`, and `flush`, and is implemented with the
159
+ /// following pseudo-code:
160
+ ///
161
+ /// ```text
162
+ /// let pollable = this.subscribe();
163
+ /// while !contents.is_empty() {
164
+ /// // Wait for the stream to become writable
165
+ /// pollable.block();
166
+ /// let Ok(n) = this.check-write(); // eliding error handling
167
+ /// let len = min(n, contents.len());
168
+ /// let (chunk, rest) = contents.split_at(len);
169
+ /// this.write(chunk ); // eliding error handling
170
+ /// contents = rest;
171
+ /// }
172
+ /// this.flush();
173
+ /// // Wait for completion of `flush`
174
+ /// pollable.block();
175
+ /// // Check for any errors that arose during `flush`
176
+ /// let _ = this.check-write(); // eliding error handling
177
+ /// ```
178
+ @since(version = 0.2.0)
179
+ blocking-write-and-flush: func(
180
+ contents: list<u8>
181
+ ) -> result<_, stream-error>;
182
+
183
+ /// Request to flush buffered output. This function never blocks.
184
+ ///
185
+ /// This tells the output-stream that the caller intends any buffered
186
+ /// output to be flushed. the output which is expected to be flushed
187
+ /// is all that has been passed to `write` prior to this call.
188
+ ///
189
+ /// Upon calling this function, the `output-stream` will not accept any
190
+ /// writes (`check-write` will return `ok(0)`) until the flush has
191
+ /// completed. The `subscribe` pollable will become ready when the
192
+ /// flush has completed and the stream can accept more writes.
193
+ @since(version = 0.2.0)
194
+ flush: func() -> result<_, stream-error>;
195
+
196
+ /// Request to flush buffered output, and block until flush completes
197
+ /// and stream is ready for writing again.
198
+ @since(version = 0.2.0)
199
+ blocking-flush: func() -> result<_, stream-error>;
200
+
201
+ /// Create a `pollable` which will resolve once the output-stream
202
+ /// is ready for more writing, or an error has occurred. When this
203
+ /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an
204
+ /// error.
205
+ ///
206
+ /// If the stream is closed, this pollable is always ready immediately.
207
+ ///
208
+ /// The created `pollable` is a child resource of the `output-stream`.
209
+ /// Implementations may trap if the `output-stream` is dropped before
210
+ /// all derived `pollable`s created with this function are dropped.
211
+ @since(version = 0.2.0)
212
+ subscribe: func() -> pollable;
213
+
214
+ /// Write zeroes to a stream.
215
+ ///
216
+ /// This should be used precisely like `write` with the exact same
217
+ /// preconditions (must use check-write first), but instead of
218
+ /// passing a list of bytes, you simply pass the number of zero-bytes
219
+ /// that should be written.
220
+ @since(version = 0.2.0)
221
+ write-zeroes: func(
222
+ /// The number of zero-bytes to write
223
+ len: u64
224
+ ) -> result<_, stream-error>;
225
+
226
+ /// Perform a write of up to 4096 zeroes, and then flush the stream.
227
+ /// Block until all of these operations are complete, or an error
228
+ /// occurs.
229
+ ///
230
+ /// This is a convenience wrapper around the use of `check-write`,
231
+ /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with
232
+ /// the following pseudo-code:
233
+ ///
234
+ /// ```text
235
+ /// let pollable = this.subscribe();
236
+ /// while num_zeroes != 0 {
237
+ /// // Wait for the stream to become writable
238
+ /// pollable.block();
239
+ /// let Ok(n) = this.check-write(); // eliding error handling
240
+ /// let len = min(n, num_zeroes);
241
+ /// this.write-zeroes(len); // eliding error handling
242
+ /// num_zeroes -= len;
243
+ /// }
244
+ /// this.flush();
245
+ /// // Wait for completion of `flush`
246
+ /// pollable.block();
247
+ /// // Check for any errors that arose during `flush`
248
+ /// let _ = this.check-write(); // eliding error handling
249
+ /// ```
250
+ @since(version = 0.2.0)
251
+ blocking-write-zeroes-and-flush: func(
252
+ /// The number of zero-bytes to write
253
+ len: u64
254
+ ) -> result<_, stream-error>;
255
+
256
+ /// Read from one stream and write to another.
257
+ ///
258
+ /// The behavior of splice is equivalent to:
259
+ /// 1. calling `check-write` on the `output-stream`
260
+ /// 2. calling `read` on the `input-stream` with the smaller of the
261
+ /// `check-write` permitted length and the `len` provided to `splice`
262
+ /// 3. calling `write` on the `output-stream` with that read data.
263
+ ///
264
+ /// Any error reported by the call to `check-write`, `read`, or
265
+ /// `write` ends the splice and reports that error.
266
+ ///
267
+ /// This function returns the number of bytes transferred; it may be less
268
+ /// than `len`.
269
+ @since(version = 0.2.0)
270
+ splice: func(
271
+ /// The stream to read from
272
+ src: borrow<input-stream>,
273
+ /// The number of bytes to splice
274
+ len: u64,
275
+ ) -> result<u64, stream-error>;
276
+
277
+ /// Read from one stream and write to another, with blocking.
278
+ ///
279
+ /// This is similar to `splice`, except that it blocks until the
280
+ /// `output-stream` is ready for writing, and the `input-stream`
281
+ /// is ready for reading, before performing the `splice`.
282
+ @since(version = 0.2.0)
283
+ blocking-splice: func(
284
+ /// The stream to read from
285
+ src: borrow<input-stream>,
286
+ /// The number of bytes to splice
287
+ len: u64,
288
+ ) -> result<u64, stream-error>;
289
+ }
290
+ }
@@ -0,0 +1,10 @@
1
+ package wasi:io@0.2.6;
2
+
3
+ @since(version = 0.2.0)
4
+ world imports {
5
+ @since(version = 0.2.0)
6
+ import streams;
7
+
8
+ @since(version = 0.2.0)
9
+ import poll;
10
+ }
@@ -0,0 +1 @@
1
+ package fermyon:spin@2.0.0;
@@ -0,0 +1,50 @@
1
+ interface sqlite {
2
+ /// A handle to an open sqlite instance
3
+ resource connection {
4
+ /// Open a connection to a named database instance.
5
+ ///
6
+ /// If `database` is "default", the default instance is opened.
7
+ ///
8
+ /// `error::no-such-database` will be raised if the `name` is not recognized.
9
+ open: static func(database: string) -> result<connection, error>;
10
+
11
+ /// Execute a statement returning back data if there is any
12
+ execute: func(statement: string, parameters: list<value>) -> result<query-result, error>;
13
+ }
14
+
15
+ /// The set of errors which may be raised by functions in this interface
16
+ variant error {
17
+ /// The host does not recognize the database name requested.
18
+ no-such-database,
19
+ /// The requesting component does not have access to the specified database (which may or may not exist).
20
+ access-denied,
21
+ /// The provided connection is not valid
22
+ invalid-connection,
23
+ /// The database has reached its capacity
24
+ database-full,
25
+ /// Some implementation-specific error has occurred (e.g. I/O)
26
+ io(string)
27
+ }
28
+
29
+ /// A result of a query
30
+ record query-result {
31
+ /// The names of the columns retrieved in the query
32
+ columns: list<string>,
33
+ /// the row results each containing the values for all the columns for a given row
34
+ rows: list<row-result>
35
+ }
36
+
37
+ /// A set of values for each of the columns in a query-result
38
+ record row-result {
39
+ values: list<value>
40
+ }
41
+
42
+ /// A single column's result from a database query
43
+ variant value {
44
+ integer(s64),
45
+ real(f64),
46
+ text(string),
47
+ blob(list<u8>),
48
+ null
49
+ }
50
+ }
@@ -0,0 +1,120 @@
1
+ package nextclaw:portable-service@0.1.0;
2
+
3
+ interface host {
4
+ enum log-level {
5
+ debug,
6
+ info,
7
+ warn,
8
+ error,
9
+ }
10
+
11
+ record http-response {
12
+ status: u16,
13
+ body: string,
14
+ }
15
+
16
+ record runtime-info {
17
+ runner-pid: u32,
18
+ loaded-components: u32,
19
+ component-id: string,
20
+ }
21
+
22
+ log: func(level: log-level, message: string);
23
+ kv-get: func(key: string) -> result<option<string>, string>;
24
+ kv-set: func(key: string, value: string) -> result<_, string>;
25
+ http-get: func(url: string) -> result<http-response, string>;
26
+ component-call: func(provider-id: string, action: string, input-json: string) -> result<string, string>;
27
+ get-runtime-info: func() -> runtime-info;
28
+ /// Ask the NextClaw-selected model bound to a declared slot to complete a
29
+ /// short request. The record is typed; messages remain JSON so the WIT
30
+ /// stays independent of the product's evolving chat message schema.
31
+ record model-complete-input {
32
+ slot-id: string,
33
+ messages-json: string,
34
+ max-tokens: option<u32>,
35
+ }
36
+
37
+ /// Starts the NextClaw-selected Agent bound to a declared slot. It returns
38
+ /// immediately with a JSON handle; terminal output is published through the
39
+ /// enclosing Job stream rather than becoming a second guest protocol.
40
+ record agent-start-input {
41
+ slot-id: string,
42
+ input-json: string,
43
+ }
44
+
45
+ model-complete: func(input: model-complete-input) -> result<string, string>;
46
+ agent-start: func(input: agent-start-input) -> result<string, string>;
47
+ /// A job-scoped, bounded observation channel. Older Components that do not
48
+ /// import these functions remain link-compatible with this host interface.
49
+ report-progress: func(current: option<u64>, total: option<u64>, message: option<string>) -> result<_, string>;
50
+ emit-chunk: func(content: string) -> result<_, string>;
51
+ check-cancelled: func() -> bool;
52
+ }
53
+
54
+ interface service {
55
+ record action {
56
+ name: string,
57
+ title: string,
58
+ description: string,
59
+ }
60
+
61
+ list-actions: func() -> list<action>;
62
+ invoke: func(action: string, input-json: string) -> result<string, string>;
63
+ start: func(config-json: string) -> result<string, string>;
64
+ handle-event: func(event-json: string) -> result<string, string>;
65
+ stop: func(reason-json: string) -> result<string, string>;
66
+ }
67
+
68
+ /// The 0.2 Resident contract intentionally has its own exported interface.
69
+ /// Existing Components keep exporting `service` unchanged; new Resident
70
+ /// templates export this interface so acknowledgement and retry are typed at
71
+ /// the Component boundary rather than inferred from arbitrary JSON.
72
+ interface resident-v2 {
73
+ record action {
74
+ name: string,
75
+ title: string,
76
+ description: string,
77
+ }
78
+
79
+ record retry {
80
+ delay-ms: option<u32>,
81
+ error-code: option<string>,
82
+ error-message: option<string>,
83
+ }
84
+
85
+ variant event-disposition {
86
+ ack,
87
+ retry(retry),
88
+ }
89
+
90
+ list-actions: func() -> list<action>;
91
+ invoke: func(action: string, input-json: string) -> result<string, string>;
92
+ start: func(config-json: string) -> result<string, string>;
93
+ handle-event: func(event-json: string) -> result<event-disposition, string>;
94
+ stop: func(reason-json: string) -> result<string, string>;
95
+ }
96
+
97
+ world service-app {
98
+ import host;
99
+ import wasi:http/outgoing-handler@0.2.6;
100
+ import wasi:config/store@0.2.0-draft-2024-09-27;
101
+ export service;
102
+ }
103
+
104
+ /// SQLite is opt-in: ordinary Service Components retain their existing import
105
+ /// surface, while Components targeting this world receive Spin's standard
106
+ /// database interface alongside the ordinary Service contract.
107
+ world service-app-sqlite {
108
+ include service-app;
109
+ import fermyon:spin/sqlite@2.0.0;
110
+ }
111
+
112
+ /// New durable Residents use this world. The runner tries it first and then
113
+ /// deliberately adapts the original `service-app` world only for installed
114
+ /// legacy Components.
115
+ world service-app-v2 {
116
+ import host;
117
+ import wasi:http/outgoing-handler@0.2.6;
118
+ import wasi:config/store@0.2.0-draft-2024-09-27;
119
+ export resident-v2;
120
+ }